texts
sequence
tags
sequence
[ "Git/svn - keeping synced two repositories with different access rights", "There is just too much information online for me to understand and be able to get my own picture, so I gently ask the community to provide light to my journey...\n\nMy situation:\n\n\nwe have a SVN server behind a firewall within our company. Impossible to move to DMZ.\nwe need some third party (our client) to access part of the source code from a remote location, since they are contributing to the development. BUT they are not from our company, so I cannot provide them VPN access. I need them to be able not only to read source, but also commit changes.\nour SVN repo contains ALL our product. I want to give access to ONLY some folders to my client.\nMy company is VERY reluctant to let us buy a private GitHub account... for security reason, not cost...\n\n\nWe are trying for a few months the following, but it just doesn't work since it requires manual sync:\n\n\nrent a virtual machine online. Install a Git server. provide access to both our developers and our client.\nmake an initial checkout of the reduced number of svn folders I want to share.\nWe all work: either improving the code in these folders or creating new source code and folders.\nour developers are supposed to update/commits the two repos by hand... And this just does occur...\n\n\nSo I'm looking for solutions to automatically sync, but keeping in mind the access rights...\nI've seen this... Would it work for me? http://git-scm.com/docs/git-svn \n\nAnother worry is that our company will during next year migrate all our SVN to Git...\nI have no issue in anticipating this and running our own git server instead of the SVN, but it will have to be kept behind the firewall. Then I'm lost with the \"clone\", \"mirror\" aspects and to maintain the correct access rights...\n\nWhat solution/advice could you provide us in terms of this distributed architecture?" ]
[ "git", "svn", "git-svn" ]
[ "Interview data in Python: Count a certain co-occurence separated by speaker", "This is a social scientist asking. I think I found the first perfect use case (for me) to use Python, but I'm not there yet. I would like to analyze hundreds of formalized interview transcripts, in fact, the basis are protocols of parliamentary debates. It could also be a random interview. I would like to count certain words -- the \"cheers\" every party gets, ordered by parties --, but as a newcomer to Py I'm struggling to find the correct formula to define the conditions. Simply put, I'm interested in the following research question: Who is cheering whom? There are a few \"if's\" that I would like to be taken care of to produce the desired outcome. \n\nThe raw data is complex, but well ordered.\n\nEach discussion is ordered by speaker, who's formally introduced by: \"The floor goes to... X\". Then there's the speaker's text, there are also blank lines separating the text. When the speaker is finished, the next one is introduced with the same phrase. During the speech members of certain parties \"cheer\" the speaker, which is indicated in the data bei \"(Cheering ... PARTY NAME).\" These entries can go over 1 or 2 lines. And I would like to count these \"cheers\". \n\nHere's an example of the raw data (simplified): \n\nThe floor goes to member of the parliament Muller by the\nLeft Party.\n\nBla bla\nbla \n(Cheers Left Party, Green Party, Blue\nParty )\n\nBla\n\n(Cheers Nazi Party) \nBye Bla\n\nThe floor goes to member of the parliament Tsing by the Green Party.\n\nBla bla\nbla \n(Cheers Left Party, Green Party)\n\n\nHow do I tell Python to loop through text that follows after a certain string in a certain line (the speaker) has occured? Plus, how do I count co-occurences in a line, thus skipping empty/irrelevant characters (counting the \"cheers\")? Using a basic word count code I was able to count all the cheers in a file, but that's just a simple start.\n\ncount = 0\nfhand = open('3_parliament.txt') \nfor line in fhand:\n line = line.rstrip()\n if not line.startswith('(Cheers '): continue\n words = line.split()\n count = count + 1\n print(words[1]) \n\nprint(\"There were\", count, \"lines in the file with >(Cheers< as the first word\")\n\n\nI found additional example code where \"paragraphs\" were defined, but this does not work here because of the empty lines, and the complex nature of the text in general. textwrapping seemed to produce similar issues. I also find it challenging to count co-occurences in a line (\"Cheers ... Party X\". Do you have any tipps or hints?\n\nI'm using the latest Python 3.8 on Win 10, via Atom." ]
[ "python", "loops", "counting", "paragraph" ]
[ "Long min limit in Visual Studio", "Why does Visual Studio treats the constant -2147483648 (0x80000000) as unsigned?\n\nFrom what I know this value is still within min limit for long.\n\nExample, if you compile the following:\n\nlong a = -2147483648\n\n\nThe compiler will issue the following warning:\n\nwarning C4146: unary minus operator applied to unsigned type, result still unsigned type" ]
[ "c", "visual-studio-2010", "compiler-warnings" ]
[ "Ajax click for facebook app iframe on iPhone", "I'd like to fix this issue but I can't do it so far. My iPhone has to click twice to show the Ajax friends selector for facebook App. The first click shows only the background tint, and I have to click the tint to remove it, and the second click show the friends selector jquery.friend.selector-1.2.js. The Android phone seems to be working. It would be great if anyone knows how to fix this.\n\n<script type=\"text/javascript\">\n function logResponse(response) {\n if (console && console.log) {\n console.log('The response was', response);\n }\n }\n var friends = [];\n $(function(){\n FB.init({\n appId : '<?php echo AppInfo::appID(); ?>', // App ID\n channelUrl : 'https://<?php echo $_SERVER[\"HTTP_HOST\"]; ?>/channel.html', // Channel File\n status : true, // check login status\n cookie : true, // enable cookies to allow the server to access the session\n xfbml : true // parse XFBML\n });\n FB.Canvas.setAutoGrow(200);\n FB.Canvas.scrollTo(0,0);\n FB.Canvas.setSize({width: 810, height: 1000});\n\nvar i = 0;\n $(\".selectFriend\").click(function(e){\n\n var selector = $(this);\n\n\n // init new selector\n\n selector.fSelector({\n max: 5,\n closeOnSubmit : true ,\n onSubmit: function(response){\n if(response){\n// to rest old selected\nvar friend = $('.selectedFriendNames').attr('id');\nvar friendname = $('.selectedFriendNames').val();\nvar match = jQuery.inArray(friend,friends);\nif($('.selectedFlower') && match >= 0){\n//commented out for testing\n//reduce count\n//i--;\n/*friends.splice(match,1);\n$('.selectFriend').show();\n$('.selectedFlower').find('.selectedFriendClass').html('');\n$('.selectedFlower').find('#flowerName').removeAttr( 'style' );\n$('.selectedFlower').find('.description').removeAttr( 'style' );\n$('.selectedFlower').find('.comment').html('');\n$('.selectedFlower').removeClass(\"selectedFlower\");\n$('#selections').val('');\n$('#image').val('');\n$('#icon').val('');\n$('#desc').val('');\n$('#fdesc').val('');\n*/\n} \n i++; \n var selections = response.join(',');\n $.post('renderSelectedUsers.php',{selections: selections,id:i},function(resp) {\n selector.closest('li').find('.selectedFriendClass').html(resp);\n selector.closest('li').find('.description').css(\"position\", \"relative\");\n selector.closest('li').find('#flowerName').css(\"position\", \"absolute\");\n selector.closest('li').find('#flowerName').css(\"top\", \"10px\");\n selector.closest('li').find('#flowerName').css(\"left\", \"40px\");\n selector.closest('li').find('.comment').html(\"<textarea name ='comment\" + i + \"' id= 'comment' placeholder= 'message!'/>\");\n $('#selectedFriendsHtml' + i).val(resp);\n $('#count').val(i);\n selector.closest('li').find('.username').html($('.selectedFriendNames').html());\n friends.push($('.selectedFriendNames').attr('id'));\n var desc = selector.closest('li').find('p').first().text();\n var fdesc = selector.closest('li').find('.forConfirm').html();\n selector.closest('li').addClass(\"selectedFlower\");\n var image_to_post = \"<?php echo AppInfo::getUrl(); ?>\"+selector.closest('li').find('img').first().attr\n (\"src\");\n var image = \"<?php echo AppInfo::getUrl(); ?>\"+selector.closest('li').find('.icon img').attr\n (\"src\");\n var icon = \"<?php echo AppInfo::getUrl(); ?>\"+selector.closest('li').find('#flowerName').attr\n (\"src\");\n $('#selections' + i).val(selections);\n $('#image' + i).val(image);\n $('#icon' + i).val(icon);\n $('#desc' + i).val(desc);\n $('#fdesc' + i).val(fdesc);\n $('#imageToPost' + i).val(image_to_post);\n });\n selector.hide();\n }\n }\n });\n });\n });\n function submitForm(){\n if( $('#selections').val() !='' && $('#comment').val() !='' )\n\n $('#flowerForm').submit();\n else{\n alert(\"Select Friends\");\n }\n }\n</script>" ]
[ "jquery", "iphone", "ajax", "facebook", "facebook-iframe" ]
[ "How to send password securely from client side?", "I'm trying to make my REST API more secure. For the moment I'm hashing my password in my angular app with CryptoJs.SHA256 before sending it to my C# backend. But I realize it's better to hash password on server side. So how can I send a password only readable by the server? I'm going to add SSL but I know HTTPS is also breakable. Is there an other solution?\n\nThanks" ]
[ "javascript", "c#", "api", "rest", "security" ]
[ "Can this function be re-written recursively or more cleanly?", "This function match sets an attribute (collapsed) to true or false depending on\nthe value of a string : \n\nfunction match(children) {\n\n var data = $scope.treeData\n for (var i = 0; i < data.length; i++) {\n var s = data[i]\n for (var i2 = 0; i2 < s.children.length; i2++) {\n var s2 = s.children[i2]\n for (var i3 = 0; i3 < s2.children.length; i3++) {\n for (var i4 = 0; i4 < s2.children[i3].children.length; i4++) {\n var text = \"\";\n if ($scope.searchText == undefined) {\n text = \"\"\n } else {\n text = $scope.searchText\n }\n if (s2.children[i3].children[i4].label\n .toLowerCase() === text.toLowerCase()) {\n s2.children[i3].collapsed = false\n }\n }\n }\n\n }\n }\n}\n\n\nExcluding the bad use of variable names i3,i2 etc is there a cleaner method ?\n As the inner most loop requires access to the outer loop can recursion still be used ?\n\nUpdate : \n\nData structure : \n\n[{\"label\":\"test\",\"collapsed\":false,\"children\":[{\"label\":\"test\",\"collapsed\":false,\"children\":[],\"$$hashKey\":\"002\"}],\"$$hashKey\":\"001\"}]\n\n\nUpdate 2 : \n\nUsing a recursive function but the string 'test' is not being matched : \n\nhttp://jsfiddle.net/U3pVM/19196/\n\nfiddle src : \n\n<div ng-app>\n <h2>Todo</h2>\n <div ng-controller=\"TodoCtrl\">\n\n </div>\n</div>\n\nfunction TodoCtrl($scope) {\n\n var json = [{\"label\":\"test\",\"collapsed\":false,\"children\":[{\"label\":\"test\",\"collapsed\":false,\"children\":[],\"$$hashKey\":\"002\"}],\"$$hashKey\":\"001\"}]\n\n var searchText = 'test'\n\n function match(node, searchText){\n angular.forEach(node.children, function(idx, child){\n node.collapsed = child.label.toLowerCase === searchText.toLowerCase\n console.log(node.collapsed)\n if(child.children.length > 0){\n match(child, searchText);\n }\n });\n }\n\n match(json, searchText);\n\n\n}" ]
[ "javascript", "jquery", "angularjs" ]
[ "CustomInventory on click wont work bukkit", "I never like resorting to this because I'm trying to resolve the code myself and figure out why it's not working, this time I really don't understand why this doesn't work.\nHere is the inventory that I made:\n\npackage io.github.bxnie.gui;\n\nimport java.util.ArrayList;\n\nimport org.bukkit.Bukkit;\nimport org.bukkit.ChatColor;\nimport org.bukkit.Material;\nimport org.bukkit.command.Command;\nimport org.bukkit.command.CommandExecutor;\nimport org.bukkit.command.CommandSender;\nimport org.bukkit.entity.Player;\nimport org.bukkit.event.EventHandler;\nimport org.bukkit.event.Listener;\nimport org.bukkit.event.inventory.ClickType;\nimport org.bukkit.event.inventory.InventoryClickEvent;\nimport org.bukkit.inventory.Inventory;\nimport org.bukkit.inventory.ItemFlag;\nimport org.bukkit.inventory.ItemStack;\nimport org.bukkit.inventory.meta.ItemMeta;\n\nimport net.minecraft.server.v1_12_R1.CommandExecute;\n\npublic class build extends CommandExecute implements Listener, CommandExecutor {\n\n public String build = \"build\";\n\n //open main GUI for building /build\n public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {\n Player p = (Player) sender;\n if (!(sender instanceof Player)) {\n sender.sendMessage(\"Only players may execute this command!\");\n return true;\n }\n if (cmd.getName().equalsIgnoreCase(build) && sender instanceof Player) {\n if (p.hasPermission(\"fp.build\")) {\n //Creates the Inventory\n Inventory gui = Bukkit.createInventory(null, 27, ChatColor.BLUE + \"Build Menu\");\n\n //Where the Items and Meta are made\n ItemStack creative = new ItemStack(Material.CONCRETE, 1, (short) 3);\n ItemMeta creativemeta = creative.getItemMeta();\n creativemeta.setDisplayName(ChatColor.BLUE + \"Creative Mode\");\n creativemeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);\n ArrayList<String> creativelore = new ArrayList<String>();\n creativelore.add(ChatColor.GRAY + \"Click this to set your gamemode to Creative!\");\n creativemeta.setLore(creativelore);\n creative.setItemMeta(creativemeta);\n\n //Positioning\n gui.setItem(18, creative);\n\n p.openInventory(gui);\n\n } else {\n p.sendMessage(ChatColor.RED + \"Insufficient Permission!\");\n return false;\n }\n }\n\n return false;\n }\n\n}\n\n\nHere is the onclick events for the inventory:\n\npackage io.github.bxnie.events;\n\nimport org.bukkit.Bukkit;\nimport org.bukkit.ChatColor;\nimport org.bukkit.entity.Player;\nimport org.bukkit.event.EventHandler;\nimport org.bukkit.event.Listener;\nimport org.bukkit.event.inventory.InventoryClickEvent;\nimport org.bukkit.inventory.Inventory;\nimport org.bukkit.inventory.ItemStack;\n\npublic class buildmenu implements Listener {\n\n @SuppressWarnings(\"unlikely-arg-type\")\n @EventHandler\n public void InventoryOnClick(InventoryClickEvent event) { \n Player player = (Player) event.getWhoClicked();\n Inventory open = event.getInventory();\n ItemStack item = event.getCurrentItem();\n\n if(open == null) {\n return;\n }\n\n if(open.getName().equals(ChatColor.BLUE + \"Build Menu\")) {\n\n event.setCancelled(true);\n\n if(item == null || !item.hasItemMeta()) {\n return;\n }\n if(item.getItemMeta().getDisplayName().equals(ChatColor.BLUE + \"Creative Mode\")) {\n Bukkit.broadcastMessage(\"Test\");\n return;\n }\n }\n }\n}\n\n\nwhen I use the command /build in the game the inventory opens up with the correct item inside it, however when I click on the item it doesn't run the test broadcast which I have set, for now, moreover, the player can move the items around in the inventory.\nI'm sure this is just a simple mistake, and I'm sorry if I'm wasting your time but I have been trying to fix this for an hour now.\n\nThanks -Ben" ]
[ "minecraft", "bukkit" ]
[ "python profiler not available in Intellij 15.0.2", "My intellij version is 15.0.2. But in the run context menu, there is no option regarding profiling a piece of code. \nAnyone knows what goes wrong?" ]
[ "python", "intellij-idea" ]
[ "Get user sim number android", "In my application, I want to get user's sim number if present, i have tried below code but it returns \"\"\n\nTelephonyManager tMgr = \n(TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);\nString mPhoneNumber = tMgr.getLine1Number();\n\n\nRequired permission\n\n<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>\n\n\nI have searched everywhere to find a method to get user's sim number but nothing worked for me. Some people saying maybe user's sim provider have restriction over this feature but I use imo application that get my sim number and displays in application so I have tried different methods on same mobile but nothing works, if anyone know working method kindly tell me." ]
[ "android", "android-settings" ]
[ "Is it right way to make a copy of instance in Django rest framework?", "The main aim is to create a duplicate of the existing document with the same content but different titles. To achieve this, I decided to implement another serializer with the custom create method. I have to modify the view class and dynamically determine what kind of endpoint was called to choose the appropriate serializer. My solution works for me, but I doubt that the solution is correct.\nIf you have any idea about this please tell me.\nThank you in advance for sharing your experience.\nI had the following at the beginning (before modification):\nmodel.py\n...\nclass Document(models.Model):\n title = models.TextField('name', unique=True)\n content = models.TextField('content', default='')\n\nview.py\n...\nclass DocumentViewSet(viewsets.ModelViewSet):\n queryset = Document.objects.all()\n serializer_class = DocumentSerializer\n\nserializer.py\n...\nclass DocumentSerializer(serializers.HyperlinkedModelSerializer):\n class Meta:\n model = Document\n fields = ['id', 'url', 'title', 'content']\n\nurl.py\n...\nrouter = SimpleRouter()\nrouter.register(r'documents', views.DocumentViewSet, basename='document')\n\nMy current solution is to modify the following files like these:\nserializer.py\n ...\n # add new serializer\n class DuplicateDocumentSerializer(serializers.HyperlinkedModelSerializer):\n parent = serializers.HyperlinkedRelatedField(view_name='document-detail',\n queryset=Document.objects.all(),\n write_only=True)\n content = serializers.ReadOnlyField()\n\n def create(self, validated_data):\n title = validated_data.get('title')\n parent_doc = validated_data.get('parent')\n content = parent_doc.content\n\n return super().create({\n 'title': title,\n 'content': content,\n })\n\n\n class Meta:\n model = Document\n fields = ['id', 'url', 'title', 'content', 'parent']\n\nview.py\n ...\n class DocumentViewSet(viewsets.ModelViewSet):\n queryset = Document.objects.all()\n\n def get_serializer_class(self):\n if self.action == 'copy':\n return DuplicateDocumentSerializer\n return DocumentSerializer\n\n @transaction.atomic\n @action(detail=False, methods=['post'])\n def copy(self, request, *args, **kwargs):\n return self.create(request, *args, **kwargs)\n\nIn this case, I use these endpoints\nTo create a new document\nPOST: http://127.0.0.1:8000/api/documents/\n{\n "title": "new doc",\n "content": "new content"\n}\n\nTo copy an existing document\nPOST: http://127.0.0.1:8000/api/documents/copy\n{\n "title": "new title of doc",\n "parrent": "http://127.0.0.1:8000/api/documents/1"\n}\n\nIn my opinion, it will be better to use URLs like this\nPOST: http://127.0.0.1:8000/api/documents/1/save_as/\n {\n "title": "new title of doc"\n }\n\nUnfortunately, I've not found an elegant solution.\nMaybe I'm wrong in both cases?" ]
[ "python", "django", "django-rest-framework" ]
[ "Vuex getter for filter not updating after mutating array of state", "I'm building a todo app. There is a button to toggle the checked/completed state of all todos. I'm mutating an array of the state, but the getters are not being updating. When I click toggle complete button, the database and the array state.todos update, but the $store.getters.filteredTodos does not update.\n\nSo the some todos are displayed incorrectly (some are checked and others are not when all should be checked or unchecked)\n\n // in getters\n filteredTodos(state) {\n if (state.filter == 'active') {\n return state.todos.filter(todo => !todo.completed);\n }\n\n if (state.filter == 'completed') {\n return state.todos.filter(todo => todo.completed);\n }\n\n return state.todos;\n },\n\n // in mutations\n retrieveTodos(state, todos) {\n Vue.set(state, 'todos', todos);\n\n // tried the following, but also didn't work\n //state.todos.splice(0, state.todos.length, ...todos);\n },\n\n // in actions\n toggleCompleted(context, completed) {\n axios.patch('/todos/toggle-completed', {completed})\n // response.data is the array of the updated todo items\n .then(response => context.commit('retrieveTodos', response.data))\n .catch(e => console.log(e));\n },\n\n\n\nFrom several posts here in StackOverflow and in VueForum, I have seen the same solution:\n\n Vue.set(state, 'todos', todos);\n // or\n state.todos.splice(0, state.todos.length, ...todos);\n\n\nNone of them worked. The $store.state updates, but the $store.getters.filteredTodos does not.\n\nHow to solve this?\n\nUPDATE\n\nI'm following this tutorial series on YouTube to get started with Vue, but I'm doing somethings on my own. In the tutorial, the guy creates the Vue project for the fronend and a Laravel project for the backend. I did the same.\n\n\nMy GitHub repo for the frontend\nMy GitHub repo for the backend" ]
[ "arrays", "vue.js", "state", "vuex", "getter" ]
[ "Scraping ajax sites with r", "Does anyone know whether I can scrape this site or this one with httr and rvest, or should I use selenium or phantomjs?\n\nBoth of the sites seem to be using ajax, and I cant seem to get through it.\n\nEssentially what I am after is the following:\n\n# I want this to return the titles of the listings, but I get character(0)\n\"https://www.sahibinden.com/satilik\" %>% \n read_html() %>% \n html_nodes(\".searchResultsItem .classifiedTitle\") %>% \n html_text() \n\n# I want this to return the prices of the listings, but I get 503\n\"https://www.hurriyetemlak.com/konut\" %>% \n read_html() %>% \n html_nodes(\".listing-item .list-view-price\") %>% \n html_text()\n\n\nAny ideas with v8, or artificial sessions are welcome.\n\nAlso, any purely curl solutions are also welcome. I'll try to translate them into httr later :) \n\nThanks" ]
[ "r", "web-scraping", "rvest", "httr", "rselenium" ]
[ "Create a group model for users in rails", "I built a web app in Rails where i have articles about different subjects like a blog basically. Now I want to add a group model on my users so that I can show some articles for only those that belong to a certain group. I use devise to handle my users today. They have email and a password as login. \n\nI've been looking everywhere for a gem that i could use and i have searched google and stackoverflow but i haven't found anything except Groupify that resemble what I'm looking for and that is poorly documented :( \n\nSo first of all.. are there any gems out there that could help me with this? If not, does anyone has a good way to sort this? \n\nI'm using Rails 4 for my app and Postgres as my database. I use the latest Devise.\n\nI want to point out that I'm pretty new at Rails." ]
[ "ruby-on-rails", "ruby", "ruby-on-rails-4", "devise" ]
[ "Not able to select value of field using jQuery when Multiple forms with fields having same id", "I have a HTML page with multiple forms with different id's. Input box with same id exist in different forms.\n\nI am trying to get the specific field from specific form. \n\nI tried this: \n\n $j(\"#FormName #ID\").attr(\"value\")\n\n\nWorks fine in chrome, mozilla etc.. But this does not works in IE!\n\nHow to select the value of a field from a particular form.\n\nThank you." ]
[ "javascript", "jquery", "html", "forms" ]
[ "I have a source document:", "I have a source document:\n\n<?xml version = \"1.0\" encoding = \"UTF-8\"?>\n<Circuit revision=\"B\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n <Block name=\"Design\">\n <Data>\n <Layer name=\"INDEX_4\" Function=\"PLANE\"></Layer>\n <Layer name=\"INDEX_9\" Function=\"CORE\"></Layer>\n <Group name=\"PRIMARY\">\n <SubGroup name=\"GROUP_PRIMARY\">\n <SubLayer Ref=\"INDEX_4\" thickness=\"0.0350\"></SubLayer>\n <SubLayer Ref=\"INDEX_9\" thickness=\"0.1000\"></SubLayer>\n </SubGroup>\n </Group>\n </Data>\n </Block>\n</Circuit>\n\n\nThis stylesheet using current() extracts the corresponding thickness:\n\n<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"\n xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\n exclude-result-prefixes=\"xs\"\n version=\"2.0\">\n<xsl:template match=\"/Circuit/Block/Data/Layer\">\n <xsl:element name=\"{name()}\">\n <xsl:attribute name=\"id\">\n <xsl:value-of select=\"@name\"/>\n </xsl:attribute>\n <xsl:attribute name=\"Function\">\n <xsl:value-of select=\"@Function\"/>\n </xsl:attribute>\n <xsl:value-of select=\"/Circuit/Block/Data/Group/SubGroup/SubLayer[@Ref=current()/@name]/@thickness\"/>\n </xsl:element>\n</xsl:template>\n </xsl:stylesheet>\n\n\nHere's the second stylesheet to extract the PREVIOUS thickness value:\n\n<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"\n xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\n exclude-result-prefixes=\"xs\"\n version=\"2.0\">\n<xsl:template match=\"/Circuit/Block/Data/Layer\">\n <xsl:element name=\"{name()}\">\n <xsl:attribute name=\"id\">\n <xsl:value-of select=\"@name\"/>\n </xsl:attribute>\n <xsl:attribute name=\"Function\">\n <xsl:value-of select=\"@Function\"/>\n </xsl:attribute>\n <xsl:value-of select=\"/Circuit/Block/Data/Group/SubGroup/SubLayer[@Ref=preceding-sibling::*[1]/@name]/@thickness\"/>\n </xsl:element>\n</xsl:template>\n </xsl:stylesheet>\n\n\nIn both cases I get this:\n\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <Layer id=\"INDEX_4\" Function=\"PLANE\">0.0350</Layer>\n <Layer id=\"INDEX_9\" Function=\"CORE\">0.1000</Layer>\n\n\nI tried the preceding-sibling to get the preceding value - I guess the question is \"What is the context of the preceding-sibling?\"\n\nIs it the group with the Layer element or the group with the SubLayer element?\n\nThanks\n\nRalph B" ]
[ "xslt-2.0" ]
[ "convert memo field to text and eliminate excess spaces", "I tried looking this up in google, but couldnt find any anything... I am running Access 2007/XP/SQLBASE and need to make a query that converts a memo field to text and eliminaes any spaces more than 2 spaces long. Please give me the SQL, based on my snippet below. the memo field is called \"BITS\". I used to be able to accomplish this using the \"SL\" function, but it doesnt seem to work in Access2007 but does work in Access 2000. thanks you very much for your help `\n\nSELECT SYSADM_CUST_ORDER_BINARY.CUST_ORDER_ID, SYSADM_CUST_ORDER_BINARY.BITS\nFROM SYSADM_CUST_ORDER_BINARY\nGROUP BY SYSADM_CUST_ORDER_BINARY.CUST_ORDER_ID, SYSADM_CUST_ORDER_BINARY.BITS;" ]
[ "ms-access-2007" ]
[ "MySQL: List of connected users in a forum-like website?", "Hello and sorry for the unclear title.\n\nBasically, I want to do (in the idea of learning PHP) simple forum-like website.\nI have already created login and registration interface, but now I would like to be able to display a list of currently logged users.\n\nI already have a user table containing their ID, but do I also need to add a 'IsConnect' field or do I need to create another table containing the ID of the currently connected users?\n\nThank's !" ]
[ "php", "mysql", "database", "forum" ]
[ "how to check the user role inside form builder in Symfony2?", "Okay, i'm trying to check if an user has a specific role, i did this\n\nhowever, when i do this:\n\npublic function buildForm(FormBuilder $builder, array $options)\n{\n $builder\n ->add('nombre',null,array('label' => 'Usuario'))\n ->add('email')\n ->add('password', 'repeated', array(\n 'type' => 'password',\n 'invalid_message' => 'Los campos deben coincidir',\n 'first_name' => 'password',\n 'second_name' => 'confirmar password',\n 'options' => array('required' => false)\n ))\n\n ->add('cliente', 'entity', array(\n 'class' => 'ClientesBundle:Cliente',\n 'empty_value' => 'Company', \n 'required' => false,\n 'empty_data' => null)\n **)**\n $user = $this->securityContext->getToken()->getUser();\n **if ($user->getRol() == 'ROLE_SUPER_ADMIN'){**\n ->add('rol') \n **}**\n ;\n\n}\n\n\ntried this as well:\n\n **if ($this->securityContext->getToken()->getUser()->getRol() === 'ROLE_SUPER_ADMIN'){**\n ->add('rol') \n **}**\n\n\nthe bolded lines (the ones with **) have the tiny red line that indicates an error, and it's says unexpected if...\nHow do i fix this?" ]
[ "symfony", "formbuilder", "role" ]
[ "Getting only NAs in the dataframe?", "I am trying to make a dataframe with two columns and 10 rows whereby the first column contains weight (denoted by w in the code) and the second column contains the error rate (denoted by cv.error). However I get a dataframe with only NA in it. I don't know what I am doing wrong. Help would be appreciated.\n\nI want a dataframe in which the first column has \"w\" and the other has cv.error.\n\nFollowing is my code\n\nl <- data.frame(matrix(NA, nrow = 10, ncol = 2))\n\nk_fun <- function(combined_distance,n,j)\n{\n glm_fit <- glm(gcms$train$response ~ combined_distance ,family=binomial, data=gcms$train,control = list(maxit = 50))\n cv.error = cv.glm(gcms$train, glm_fit,K=5)$delta[1]\n l[j,1] = n\n l[j,2] = cv.error\n}\n\nw = c(0.1,0.2,0.25,0.3,0.35,0.4,0.45,0.50,0.7,0.9)\n\nfor(j in 1:10)\n{\n combined_distance <- alkoloiddistance + (1 - alkoloiddistance^w[j]) * solventdistance\n k_fun(combined_distance,w[j],j)\n}" ]
[ "r" ]
[ "Restsharp header always set to \"application/x-www-form-urlencoded\" on POST request", "I'm trying to send json data with a REST POST request in Xamarin but no matter what i try I always get this error in response :\n\n{ \"message\" : \"Unexpected Content-Type 'application/x-www-form-urlencoded', expecting 'application/json'.\"}\n\n\nI tested my request with this website : https://resttesttest.com/ and the response is ok with header set to \"Content-Type\", \"application/json\".\n\nBut within my code it's never working.\nI tried this method :\n\nvar request = new RestRequest(\"api/1/databases/{db}/collections/{coll}\", Method.POST);\nrequest.AddParameter(\"apiKey\", Common.API_KEY);\nrequest.AddUrlSegment(\"db\", Common.DB_NAME);\nrequest.AddUrlSegment(\"coll\", collection);\nrequest.AddHeader(\"Accept\", \"application/json\");\nrequest.AddParameter(\"application/json\", JsonConvert.SerializeObject(objet), ParameterType.RequestBody);\n\n\nAnd this one : \n\nvar request = new RestRequest(\"api/1/databases/{db}/collections/{coll}\", Method.POST);\nrequest.AddParameter(\"apiKey\", Common.API_KEY);\nrequest.AddUrlSegment(\"db\", Common.DB_NAME);\nrequest.AddUrlSegment(\"coll\", collection);\nrequest.AddHeader(\"content-type\", \"application/json; charset=utf-8\");\nif (objet != null)\n request.AddJsonBody(objet);\n\n\nAnd many other but no mater what i do I always get the same response." ]
[ "c#", "json", "rest", "xamarin", "restsharp" ]
[ "Regular expression and Date selecting", "I have the data with this date format: 01.01.1981 to 31.10.2005.\nBut I have to select just the data from May to September for each year. 01.05 to 30.09\nHow can I write the script in Rstudio??? I am using windows 8." ]
[ "r", "regex", "date" ]
[ "How do I validate password on the base of a condition?", "I want the password should be mandatory for web registration only and not for mobile app registration.\nMy validation code is below: \n\n class User < ApplicationRecord\n validate :password_for_web\n validate :password_confirmation_for_web\n\n def password_for_web\n if !app_user && password.blank? \n errors.add(:password, \"can't be blank.\")\n end\nend\n\n def password_confirmation_for_web\n if !app_user && password != self.password_confirmation=\n errors.add(:password_confirmation, \"doesn't match.\")\n end\n end\n\n end\n\n\nValidation is working properly but when in case of mobile app registration it is still requiring password. Help regarding the issue would be appreciable." ]
[ "ruby-on-rails", "validation", "model" ]
[ "Contour selection in opencv", "I have a source image\n\n\n\nI have applied a suitable threshold and got this\n\n\n\nNow I used contour to find the inner black blobs. I used green color to signify outer boundary and red for the inner ones. This is what I got:-\n\n\nI have extracted the blobs using the red color. But I would like to extract only those which doesn't have green inside them or at least give inner boundary only to ones that doesn't have another contour inside them. anyway to do it?\n\nEDIT-1:- I thought of finding the coordinates of green and red pixels and converting all read pixels to green if they are very close to each other. but does anyone know how to get the coordinates?\n\nEDIT-2 I followed Derman's method and I got 80% result. check out another source pic and its mask \n\n\n\nnow following the inputs by Derman, I got this\n \n\nthe code clearly identifies contours marked 1 and 3(as green and red) based on the fact that they either have or dsnt have child contours. But contour 2 is clearly as same as contour 1 and has child contours but still it is taken as red. I will share you guys the code, I know that all it may take is a small modification but it seems elude me-\n\nMat binMask; \nMat lung_src; \nvector<std::vector<cv::Point>> contours;\nvector<cv::Vec4i> hierarchy;\nint count = 0;\n\nfindContours(binMask, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, cv::Point(0, 0));\n\nfor (int i = 0; i < contours.size(); i++)\n{\n if (hierarchy[i][2] != -1) // means it has child contour\n { \n if (count>1)// number of child countors,if its greater than 1 then green else red\n {\n drawContours(lung_src, contours, i, Scalar(0, 255, 0), 1, 8, hierarchy, 0, Point()); \n }\n else // means it's count is 1 or less\n {\n drawContours(lung_src, contours, i, Scalar(0, 0, 255), 1, 8, hierarchy, 0, Point());\n }\n count++;\n } \n else // means it doesn't have any child contour\n {\n drawContours(lung_src, contours, i, Scalar(0, 0, 255), 1, 8, hierarchy, 0, Point());\n }\n}\nimshow(\"lung\", lung_src);\nimwrite(\"lung.tiff\", lung_src);\n\n\nlung_src is the above shown red/green contoured image." ]
[ "c++", "c", "opencv", "image-processing", "image-segmentation" ]
[ "how do you find error in a SWF?", "i feel stupid asking that question, but it seems like i'm unable to find out.\n\ni have a SWF that works perfectly inside flash. once i export as SWF, it doesn't work anymore.\n\ni can't use \"trace\"\n\ni have tryed that function but it doesn't trigger it for some reason. :\n\nfunction quikTrace(string:String){\n\n //INIT VARIABLES\n var tmpTxtField:TextField;\n\n //TEXTFIELD PROPERTIES\n tmpTxtField = new TextField();\n tmpTxtField.text = string;\n tmpTxtField.x = stage.width / 2;\n tmpTxtField.textColor = 0xFFFFFF; //white (black background)\n tmpTxtField.y = stage.height / 2;\n addChild(tmpTxtField);\n}\n\n\nis there any \"outside the box\" way to find errors in a SWF?" ]
[ "actionscript-3", "flash" ]
[ "Support for multiple aliases in yamldotnet deserialization", "I have a YAML document as:\n\nname: foo\ndescription: bar\n\n\nand another YAML document as:\n\nname: foo1\ndesc: bar1\n\n\nI am using YamlDotNet YamlMember 'Alias' property to define the attribute name. But it lets me define only one alias. I want \"description\" and \"desc\" to deserialize to a single variable. Both cannot be present in the YAML file at the same time. Is there any way I can achieve that?" ]
[ "yaml", "yamldotnet" ]
[ "Scaling Connections with BlockingCollection()", "I have a server which communicates with 50 or more devices over TCP LAN. There is a Task.Run for each socket reading message loop. \n\nI buffer each message reach into a blocking queue, where each blocking queue has a Task.Run using a BlockingCollection.Take().\n\nSo something like (semi-pseudocode):\n\nSocket Reading Task\n\nTask.Run(() =>\n{\n while (notCancelled)\n {\n element = ReadXml();\n switch (element)\n {\n case messageheader:\n MessageBlockingQueue.Add(deserialze<messageType>());\n ...\n }\n }\n});\n\n\nMessage Buffer Task\n\nTask.Run(() =>\n{\n while (notCancelled)\n {\n Process(MessageQueue.Take());\n }\n});\n\n\nSo that would make 50+ reading tasks and 50+ tasks blocking on their own buffers.\n\nI did it this way to avoid blocking the reading loop and allow the program to distribute processing time on messages more fairly, or so I believe.\n\nIs this an inefficient way to handle it? what would be a better way?" ]
[ "c#", "multithreading", "performance", "networking", "parallel-processing" ]
[ "Is necessary send email with ActiveJob if I'm using deliver_later method?", "If I am using deliver_later method to send an asynchronous email, do I need to generate an ActiveJob class to perform it later?" ]
[ "ruby-on-rails", "rails-activejob" ]
[ "Time Complexity of Hash Tables in C", "I'm fairly new to the the concept of hash tables, and I've been reading up on different types of hash table lookup and insertion techniques.\n\nI'm wondering what the difference is between the time complexities of linear probing, chaining, and quadratic probing?\n\nI'm mainly interested in the the insertion, deletion, and search of nodes in the hash table. So if I graph the system time per process ( insert/search/delete process ) versus the process number, how would the graphs differ?\n\nI'm guessing that:\n- quadratic probing would be worst-case O(nlogn) or O(logn) for searching\n- linear probing would be worst-case O(n) for search\n- Not sure but I think O(n^2) for chaining\n\nCould someone confirm this? Thanks!" ]
[ "c", "data-structures", "hashtable", "big-o" ]
[ "WebSocket connection to 'ws://localhost:8020/chat/1' failed:", "I have an angular springboot project, I am trying to make a chat with webSocket, this is my first time to do it, so I followed a project from github, this project was launched with server tomcat Port 8080 , when i want to use this code in my project with port 8020 , the web socket dosen' t run and it shows me an error\nWebSocket connection to 'ws://localhost:8020/chat/1' failed: \n\nFront Service Ts\npublic openWebSocket(){\n this.webSocket = new WebSocket('ws://localhost:8020/chat/1');\n this.webSocket.onopen = (event) => {\n console.log('Open: ', event);\n };\n\n this.webSocket.onmessage = (event) => {\n const chatMessageDto = JSON.parse(event.data);\n this.chatMessages.push(chatMessageDto);\n };\n this.webSocket.onclose = (event) => {\n console.log('Close: ', event);\n };\n }\n\nBack Connfiguration Java\n private final static String CHAT_ENDPOINT = "/chat/1";\n @Override\n public void registerWebSocketHandlers(WebSocketHandlerRegistry webSocketHandlerRegistry) {\n webSocketHandlerRegistry.addHandler(getChatWebSocketHandler(), CHAT_ENDPOINT)\n .setAllowedOrigins("*");\n }\n @Bean\n public WebSocketHandler getChatWebSocketHandler(){\n return new ChatWebSocketHandler();\n }" ]
[ "angular", "websocket", "spring-websocket" ]
[ "How do I find all elements of an numpy array less than a value but with completely unique indecies?", "I am working on a particle-particle annihilation problem. In this problem, any particle closer than some distance, r, to another particle will annihilate with that particle. The issue (as well as a few others) is that some particles are closer than r to more than one other particle. So I have to figure out which specific particles i to annihilate with particles j such that no particles annihilate more than once. Ideally this is all done in numpy.\nSuppose we have two 1D arrays x and y which specify the position of N particles. The pairwise distance between all particles may be calculated like\ndist = np.sqrt((x[:,None]-x[None,:])**2 + (y[:,None]- y[None,:])**2)\n\nwhich yields a 2D Hermitian array of shape (N,N). This array can easily be sorted, d_sorted = np.sort(dist) to find the shortest distances between particles. However d_sorted cannot merely be index-culled of all values less than r because some particles have more than one pair-distance less than r.\nSo, how do I find all elements of the dist array less than a specific value such that the (i,j) index collection of the resultant elements has each i,j being unique and no element of {i} being in {j} or vice-versa?\nNote, I initially thought careful application of np.unique would solve my problem, but I was unable to get anything worthwhile." ]
[ "python", "arrays", "numpy", "sorting" ]
[ "Query not working as expected", "Goal\n\nSelect distinct ids from blog_news where \n\n\nactive = 1\ntitle is not empty\nhas at least one picture unless picture is logo, or at least one video\n\n\nThe statement so far\n\nselect distinct n.id from blog_news n \nleft join blog_pics p ON n.id = p.blogid and active = '1' and trim(n.title) != '' \nleft join blog_vdos v ON n.id = v.blogid \nwhere (p.islogo = '0' and p.id is not null) OR (v.id is not null)\norder by `newsdate` desc, `createdate` desc\n\n\nThe issue\n\n\nselects blog_news ids that have pictures, unless they're logos [correct]\nselects blog_news ids that have both videos and pictures [correct]\ndoes not select blog_news ids that have only videos [wrong]" ]
[ "sql", "mysql" ]
[ "angularJS: nested ng-repeat, orderBy not working", "I am working with angular trying to use orderBy on a nested ng-repeat (on both of them), but not being successful. Please take a look:\n\nhere is my view:\n\n<article class=\"unaTienda\"\n ng-repeat=\"tienda in resumenesRondaInventariosPorTienda | orderBy: ID_CO\" >\n <h3 class='bold'>{{tienda[0][0].nombreTienda}}</h3>\n <article class=\"unDocumento\" ng-repeat=\"documento in tienda[$index]\" >\n <h3>{{documento.tipoDocumento}} {{documento.numeroDocumento}}</h3>\n </article>\n</article>\n\n\nThis is my model for that view, $scope.resumenesRondaInventariosPorTienda:\n\n { \n \"0\":[ \n [ \n { \n \"ID_CO\":20,\n \"nombreTienda\":\"GIRARDOT\",\n \"fechaDocumento\":\"20151204\",\n \"tipoDocumento\":\"IF\",\n \"numeroDocumento\":1,\n \"unidades\":-12,\n \"pesos\":-128517\n },\n { \n \"ID_CO\":20,\n \"nombreTienda\":\"GIRARDOT\",\n \"fechaDocumento\":\"20180409\",\n \"tipoDocumento\":\"IF\",\n \"numeroDocumento\":16,\n \"unidades\":5,\n \"pesos\":28870\n }\n ]\n ],\n \"1\":[ \n [ \n { \n \"ID_CO\":2,\n \"nombreTienda\":\"PLAZA CAICEDO\",\n \"fechaDocumento\":\"20160115\",\n \"tipoDocumento\":\"IF\",\n \"numeroDocumento\":1,\n \"unidades\":-8,\n \"pesos\":84701\n },\n { \n \"ID_CO\":2,\n \"nombreTienda\":\"PLAZA CAICEDO\",\n \"fechaDocumento\":\"20180417\",\n \"tipoDocumento\":\"IF\",\n \"numeroDocumento\":16,\n \"unidades\":-6,\n \"pesos\":-59361\n }\n ]\n ]\n}" ]
[ "angularjs" ]
[ "Invoke Facebook's BigPipe onPageletArrive scripts", "I'm trying to scrape information off of Facebook account settings pages for a browser app that will provide feedback to the Facebook member. I'd like to read in several pages and scrape using jQuery without displaying the pages. Unfortunately, I'm having trouble getting Facebook's BigPipe code to run as part of the page load using two of the three methods I've tried.\n\nThe third method below seems to work, but I'm still left wondering why the other two failed. Is there a way to trigger the BigPipe onPageletArrival scripts to run using either the jQuery .load() method or document.implementation.CreateDocument?\n\nUPDATE: I didn't ask the core question as succinctly as I should have: How do I get either of the first two methods to behave like the iFrame method? Put another way: How do I get those BigPipe scripts to execute and fill in the content when I begin with either Attempt 1 or 2?\n\nAttempt 1 (using document.implementation.createDocument): \n\nhtml = getHttpPage( 'http://www.facebook.com/editprofile.php?sk=basic' );\nvar fbPageHdr = /^<!DOCTYPE html><html[^>]+>/,\n fbPageTail = /<\\/html>/;\n\nvar dt = document.implementation.createDocumentType(\"html\", \"-//W3C//DTD HTML 4.01 Transitional//EN\", \"http://www.w3.org/TR/html4/loose.dtd\");\nvar doc = document.implementation.createDocument('','', dt);\n\nvar htmlElem = doc.createElement('html');\nhtml = html.replace( fbPageHdr, \"\");\nhtml = html.replace( fbPageTail, \"\");\nhtmlElem.innerHTML = html;\ndoc.appendChild( htmlElem );\n\n\nAttempt 2 (using jQuery .load() method):\n\nvar $njqNode = $();\n$njqNode.load('http://www.facebook.com/editprofile.php?sk=basic' + ' body');\n\n\nAttempt 3 - this one works! (using jQuery and iFrame):\n\nif ($('#hiddenpage').length == 0){\n var $hiddenPage = $('<iframe id=\"hiddenpage\" width=\"1000px\" height=\"1000px\"></iframe>');\n $('body').append($hiddenPage);\n}\n$('#hiddenpage').attr('src', 'http://www.facebook.com/editprofile.php?sk=basic');" ]
[ "javascript", "ajax", "jquery" ]
[ "How can I conditionally load HTML elements, or remove them BEFORE the page is loaded?", "The thing is, I have a website rented for many years and it has no way of accessing the server, I can only edit the php .twig files.\nI created a mobile and desktop version and used media queries to hide one or the other.\nMy problem is that because the desktop version is loaded before the mobile one, a script that is essential for the page to work, and which I have no access to, targets the desktop version even when it's hidden so the mobile version does not work.\nI have tried to remove the pc version triggering this script on load:\nfunction myFunction() {\n var pcversion = document.getElementById("pcversion");\n pcversion.remove();\n}\n\nbut the content appears for 0.5s before dissapearing, therefore rendering the mobile v. useless again. It would work in theory if the pcversion was deleted BEFORE it was loaded. It loads and the script targets it screwing everything.\nI can put jQuery, js or php code in the .twigs, how would you tackle this problem? I've also tried to conditionally load one version before the other depending on screen size but to no avail :(\nThanks for reading mates." ]
[ "javascript", "php", "html", "jquery" ]
[ "Add silence at the end of a .wav file created from a .mp4 using ffmpeg", "I want to generate .wav files from .mp4 ones using ffmpeg. In this command I want to include an option so that all the wav files have the same duration (add some seconds of silence at the end of each generated file).\n\nI saw here that you can add some options but they don't seem to work in my case.\n\nThis is what I have so far :\n\ncommand = \"ffmpeg -i \" + mp4_file_path + \" -filter_complex [1:a][0:a]concat=n=2:v=0:a=1 -ab 160k -ac 1 -ar 44100 -vn \" + wav_file_path\n\nsubprocess.call(command, shell=True)" ]
[ "python", "ffmpeg", "wav" ]
[ "Remove part of URL using HTACCESS", "I know this is an often asked question, but nothing I found would work for me.\n\nI am trying to remove parts of the url of my little website.\n\nMy url structure right now is like this:\n\nwww.example.com/en/catalog/categoryName\n\nAnd I would like to cut out \"Catalog\" so that it would look like this:\n\nwww.example.com/en/categoryName\n\nBut nothing I have used seems to work. \nThis is my .htaccess file atm.\n\n<IfModule mod_rewrite.c>\n RewriteEngine On\n RewriteRule ^catalog/(.*)$ $1 [QSA]\n\n RewriteCond %{REQUEST_FILENAME} !-f\n RewriteCond %{REQUEST_FILENAME} !-d\n RewriteRule . /index.php [L]\n</IfModule>\n\n\nAlso I will be getting an url that will look like this:\n\nwww.example.com/en/product/productName\n\nAnd ofcourse I would like to cut \"product\" of of that, so that it would look like this.\n\nwww.example.com/en/productName" ]
[ "php", "apache", ".htaccess", "multilingual" ]
[ "How do I apply a binary/Boolean mask to filter a list in Kotlin?", "How do I use a binary mask like so in pure Kotlin? (without kotlin-numpy)\nInput: [ 2, 3, 5, 7, 11] len=5\nMask: [true, false, false, true, false] len=5\n\nOutput: [ 2, 7 ] len=2" ]
[ "kotlin" ]
[ "Bash script doesn't see an array created with Awk", "I want to get a part in every line of a regular file. For this purpose I've used the program awk in my script. I need to put each part in an array. Something like this works:\n\ndeclare -i j=1\nawk 'BEGIN { FS=\"|\" } { a[j]=$6; ((j++)) }' myFile\n\n\nbut I have a problem after in the script, when I need to use the array. Indeed the array in the awk block isn't seen by the remaining lines of the script -- the lines outside that block. How can this problem be solved?" ]
[ "bash", "variables", "awk", "scope", "scripting" ]
[ "Cancelling a specific UILocalNotification", "I have this code for local notification, and I have a scheduleNotification and clearNotification using my own method. These are the codes:\n\n- (void)clearNotification {\n [[UIApplication sharedApplication] cancelAllLocalNotifications];\n}\n\n- (void)scheduleNotification {\n [reminderText resignFirstResponder];\n [[UIApplication sharedApplication] cancelAllLocalNotifications];\n\n Class cls = NSClassFromString(@\"UILocalNotification\");\n if (cls != nil) {\n UILocalNotification *notif = [[cls alloc] init];\n notif.fireDate = [[datePicker date] dateByAddingTimeInterval:-30];\n notif.timeZone = [NSTimeZone defaultTimeZone];\n\n notif.alertBody = @\"Evaluation Planner\";\n notif.alertAction = @\"Details\";\n notif.soundName = UILocalNotificationDefaultSoundName;\n notif.applicationIconBadgeNumber = 1;\n\n NSDictionary *userDict = [NSDictionary dictionaryWithObject:reminderText.text forKey:kRemindMeNotificationDataKey];\n notif.userInfo = userDict;\n [[UIApplication sharedApplication] scheduleLocalNotification:notif];\n [notif release];\n }\n}\n\n\nThese codes works well, but now I want to know how do I know which notification object will it delete. I would like to create an ID for a notification, meaning, one ID is equivalent to one notification. But I don't know at which part I should do that. Plus I need to find a way to include all this to be in a plist.\n\nHope somebody can help me. Thanks." ]
[ "iphone", "objective-c", "ios", "notifications" ]
[ "Convert a CURL command to PHP Curl", "I Have the following command I can run in PHP and it works as expected:\n\n$params = [\n 'file' => $xmlLocalPath,\n 'type' => 'mismo',\n 'file_type' => $xmlFile['file_type'],\n 'filename' => $xmlFile['file_name']\n ];\n\n$cmd =\n 'curl -X POST ' . $this->outboundBaseURL . 'document \\\n -H \"Accept: application/json\" \\\n -H \"Authorization: Bearer ' . $this->token . '\" \\\n -H \"Cache-Control: no-cache\" \\\n -H \"Content-Type: multipart/form-data\" \\\n -F \"file=@' . $params['file'] . ';type=' . $params['file_type'] . '\" \\\n -F \"type=' . $params['type'] . '\" \\\n -F \"filename=' . $params['filename'] . '\"';\n exec($cmd, $result);\n\n\nI need to get this to work using PHP's curl library, but I can't get it to work quite right. I'm on PHP 5.6, and here's what I have right now:\n\n$params = [\n 'file' => $xmlLocalPath,\n 'type' => 'mismo',\n 'file_type' => $xmlFile['file_type'],\n 'filename' => $xmlFile['file_name']\n ];\n\n $ch = curl_init();\n\n curl_setopt_array($ch, [\n CURLOPT_URL => $this->outboundBaseURL . 'document',\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => '',\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 60,\n CURLOPT_CUSTOMREQUEST => \"POST\",\n CURLOPT_POSTFIELDS => $params,\n CURLOPT_HTTPHEADER => [\n 'Accept: application/json',\n 'Authorization: Bearer ' . $this->token,\n 'Cache-Control: no-cache',\n 'Content-Type: multipart/form-data'\n ]\n ]);\n\n curl_setopt($ch, CURLINFO_HEADER_OUT, true); // enable tracking\n\n $response = curl_exec($ch);\n $err = curl_error($ch);\n\n $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);\n\n\nI know the issue has to be with POSTFIELDS, and the file in particular, but I'm not show how to give PHP CURL the parameters in a proper way such that the file and other parameters will send just as the do in the raw curl call. I understand that the \"@\" method is deprecated in PHP Curl and I've also tried using curl_file_create with the local file with no success" ]
[ "php", "curl" ]
[ "Macro expansion ignores token `let` and any following", "I want to define a variable with a macro ident and pass it to a derive macro, but I get an error:\nError\nerror: macro expansion ignores token `let` and any following\n --> database/src/models.rs:15:9\n |\n15 | let struct_name = stringify!($name);\n | ^^^\n...\n50 | / model!(Person {\n51 | | name: String\n52 | | });\n | |___- caused by the macro expansion here\n |\n = note: the usage of `model!` is likely invalid in item context\n\nCode\n#[macro_export]\nmacro_rules! model {\n ( \n $(#[$met: meta])*\n $name: ident { $($attr: ident : $typ: ty),* } \n ) => {\n\n let struct_name = stringify!($name);\n //let table_name = struct_name.to_camel_case();\n \n dbg!("{}", struct_name);\n \n #[derive(Debug)]\n struct $name {\n name: String\n };\n };\n}\n\nmodel!(Person {\n name: String\n});\n\n\nPlayground" ]
[ "rust", "macros" ]
[ "Scrolling Image using android animation", "How can I scroll an imageView(with an image) horizontally such that when head side leaves the edge of the screen, it appears on the other side without any spaces, just like how long marquee text works." ]
[ "android", "animation" ]
[ "How can I prevent parameter 1 is not of type 'Node' error?", "I am getting the below error message\n\nUncaught TypeError: Failed to execute 'serializeToString' on 'XMLSerializer': parameter 1 is not of type 'Node'.\n\n\nI do no know why it is happening. So could someone maybe point me in the right direction? It works on localhost with mamp... but when I try to use Nodejs to run the server... that is when I get the error. The code in which it is related to is below.\n\nfunction e(a) {\n var b = c.console || {}, e = b[a] || b.log || H;\n a=!1;\n try {\n a=!!e.apply\n } catch (l) {}\n return a ? function() {\n var a = [];\n return s(arguments, function(b) {\n a.push(d(b))\n }), e.apply(b, a)\n } : function(a, b) {\n e(a, null == b ? \"\" : b)\n }\n}" ]
[ "javascript", "node.js" ]
[ "Unable to add date time picker in android studio", "I am using bewithdhanu library for showing simple datetime picker. I have followed all the steps mentioned in the documentation. But I am getting an error\n\nAAPT: error: unbound prefix.\n\n\nDependencies\ndependencies {\nimplementation 'androidx.appcompat:appcompat:1.2.0'\n.\n.\n.\n.\n.\nimplementation 'com.github.bewithdhanu:DateTimePicker:dc8a030e3f'\n}\n\nRoot Gradle\nallprojects {\nrepositories {\n jcenter()\n google()\n maven { url 'https://jitpack.io' }\n}\n}\n\nI am very stuck to it and don't know what to do\nAny help would be highly appreciated." ]
[ "android", "android-studio", "github", "android-datepicker" ]
[ "How to direct the mouse wheel input to control under cursor instead of focused?", "I use a number of scrolling controls: TTreeViews, TListViews, DevExpress cxGrids and cxTreeLists, etc. When the mouse wheel is spun, the control with focus receives the input no matter what control the mouse cursor is over.\n\nHow do you direct the mouse wheel input to whatever control the mouse cursor is over? The Delphi IDE works very nicely in this regard." ]
[ "delphi", "mousewheel" ]
[ "JavaScript's xor result different than the one of Java", "SOLUTION\n\nI had a bug in my internal conversion logic.\n\nORIGINAL QUESTION\n\nI need to implement an algorithm both in Java and JavaScript, whereas the Java implementation and calculation result is the reference. However, when invoking the XOR operator on a \"negative\" value (I know that Java and JavaScript make use of 2's complement) causes Java's result to be positive, whereas the JavaScript result is negative, as shown in the output below:\n\nJava output:\n hash A: 16777619\n hash B: 637696617\n hash A: 637696613\n hash B: 988196095\n hash A: 988196062\n hash B: -1759370886\n hash A: 1759370917 <-- here the JavaScript implementation behaves different\n hash B: -1169850945\n\nJavaScript output:\n\n hash A: 16777619\n hash B: 637696617\n hash A: 637696613\n hash B: 988196095\n hash A: 988196062\n hash B: -1759370886\n hash A: -1759370843 <-- this result should be equal to the Java result\n hash B: -1883572545 \n\n\nBelow you can see the Java source code:\n\nprivate static final int FNV_PRIME = 0x1000193;\nprivate static final int FNV_COMPRESS = 0xFFFF;\n...\n\npublic long getHash(int inputNumber)\n{\n int hash = FNVCalculator.FNV_PRIME;\n ByteBuffer intToByteArrayConverter = ByteBuffer.allocate(4);\n intToByteArrayConverter.putInt(inputNumber);\n byte[] inputValues = intToByteArrayConverter.array();\n\n // inputValues.length is always equal to 4\n for (byte processCounter = (byte) 0; processCounter < inputValues.length; processCounter++)\n {\n hash ^= inputValues[processCounter];\n System.out.println(\"hash A: \" + hash);\n hash *= FNV_PRIME;\n System.out.println(\"hash B: \" + hash);\n }\n return (hash & FNVCalculator.FNV_COMPRESS);\n}\n\n\nThe following snippet shows the JavaScript code:\n\nvar Constants =\n{\n FNV_PRIME: parseInt(\"1000193\", 16),\n FNV_COMPRESS: parseInt(\"FFFF\", 16),\n BYTE_ARRAY_LENGTH: 4,\n ...\n};\nObject.freeze(Constants);\n\nvar hash = Constants.FNV_PRIME;\n\nfor (var counter = 0; counter < Constants.BYTE_ARRAY_LENGTH; counter++)\n{\n hash ^= inputNumberArray[counter];\n console.log(\"hash A: \" + hash);\n // mutltiply the hash with the 32 bit FNV prime number: 2^24 + 2^8 + 0x93\n // source: https://github.com/wiedi/node-fnv/blob/master/fnv.js\n hash += ((hash << 24) + (hash << 8) + (hash << 7) + (hash << 4) + (hash << 1));\n hash |= 0;\n console.log(\"hash B: \" + hash);\n}\n\nreturn (hash & Constants.FNV_COMPRESS);\n\n\nThe array with the numbers is equal in the Java as well as in the JavaScript version, as show below (all numbers are decimal numbers):\n\nJava version:\n inputValues[0]: 0\n inputValues[1]: 12\n inputValues[2]: 33\n inputValues[3]: -33\nJavaScript version:\n inputNumberArray[0]: 0\n inputNumberArray[1]: 12\n inputNumberArray[2]: 33\n inputNumberArray[3]: -33\n\n\nI have already tried replacing the byte array with an integer array, but it has not helped. I'm using WebKit's JavaScriptCore engine." ]
[ "javascript", "java", "bitwise-operators", "xor" ]
[ "Plot sphere with Julia and PyPlot", "Recently I tried to plot a sphere using PyPlot/Julia and unfortunately it was harder than I thought.\nProbably there's something wrong with points generation, but I can't figure out why my implementation didn't work. Although everything is fine with original python code.\n\nI've tried to adapt demo2 from matplotlib surface plot doc as MWE:\n\nusing PyPlot\nu = linspace(0,2*π,100);\nv = linspace(0,π,100);\n\nx = cos(u).*sin(v);\ny = sin(u).*sin(v);\nz = cos(v);\n\nsurf(x,y,z)\n\n\nAnd I'm getting instead of \n\nSo, what's exactly wrong in my Julia implementation?" ]
[ "matplotlib", "julia" ]
[ "Django + uwsgi + nginx + SSL", "I am using Django on DotCloud which uses Django on top of uwsgi + nginx. I am trying to redirect all http traffic to https which is leading to a redirect loop. I am using the following http configuration\n\nif ($http_x_forwarded_port != 443) { rewrite ^ https://$http_host/; }\n\n\nIt seems that Django doesn't understand that it is operating on https and the header is not preserved. It redirects https://url.com/ to http://url.com/accounts/login/ which is redirecting again and again leading to a redirect loop. I am not really an expert in nginx and do not understand it well enough. What can I be doing wrong? \n\nIn short how do I run redirect http to https in django running on top of uswsgi and nginx." ]
[ "django", "uwsgi", "dotcloud" ]
[ "How to test whether an element has a specific class?", "I have the following function that refreshes its data as follows\n\nrefresh: function($contentholder) {\n\n $contentholder.each(function() {\n $this = $(this);\n if ($this.hasClass(\"Codes\")) {\n //then it does some stuff in here\n }\n }\n }\n\n\nthe $contentholder comes in with data as follows\n\n<div class=\"Codes\" cod=\"t592\">\n <h3></h3>\n <div class=\"Items\">\n <div class=\"ItemCodes\" id=\"592\" time=\"2016/04/30 12:15\" places=\"1\"></div>\n\n </div>\n</div>\n\n\nThe only way my if-statement gets detected, is if I check it as follows $this.hasClass(\"Codes\"), but I only want the if-statement to get executed if the hasClass(\"codes\") contains the class ItemCodes\n\nThis is what I tried but doesn't work\n\nif ($this.hasClass(\"Codes\").length > 0) //comes back undefined even though there is data\n\n\n\n\nif ($this.hasClass(\"ItemCodes\"))` //doesnt get detected\n\n\nBasically, I want to do something like this\n\nif ($this.hasClass(\"Codes\").find(\"ItemCodes\"))\n\n\nHow do I achieve this?" ]
[ "javascript", "jquery" ]
[ "HTML/Javascript Code works in JSbin but not codepen, plunker, or jsfiddle", "The following code works in JSbin but not when I copy and paste it directly into codepen, plunker, or jsfiddle.\n\n<!DOCTYPE html>\n<html>\n<head>\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js\"></script>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width\">\n <title>JS Bin</title>\n</head>\n<body>\n\n\n<script>\n function getWeather(){\n\n var ipCall = 'http://ip-api.com/json';\n $.getJSON(ipCall, locationCallBack)\n\n function locationCallBack(locationData){\n var lat =locationData.lat; \n var lon = locationData.lon;\n\n var apiCall = 'http://api.openweathermap.org/data/2.5/weather?lat='+lat+'&lon='+lon+'&units=imperial&appid=34e8aa0c1d8d15a560df7a7093711071';\n\n $.getJSON(apiCall, weatherCallBack)\n }\n\n\n\n function weatherCallBack(weatherData){\n var cityName = weatherData.name;\n var cityTemp = weatherData.main.temp;\n var weatherType = weatherData.weather[0].main;\n var weatherIcon = weatherData.weather[0].icon; \n\n $('.cityName').append(cityName);\n $('.cityTemp').append(cityTemp);\n $('.weatherType').append(weatherType +' '+ weatherIcon); \n }\n\n }\ngetWeather()\n</script> \n\n<div class =\"cityName\">\n\n\n</div>\n\n<div class=\"cityTemp\">\n\n</div>\n\n<div class=\"weatherType\">\n\n</div>\n\n</body>\n</html>\n\n\nThe code shows the user location, and weather information for that location. Uses api to get geolocation data and weather info." ]
[ "javascript", "html", "api", "jsbin", "codepen" ]
[ "How can I force visual studio to find a header file when opening a folder", "Visual Studio 2019 does not discover napi.hunless I use relative paths while opening a npm project as a folder. The file is located in node_modules/node-addon-api/napi.h. How can I force VS to find this header? Is there an Additional include directory type option when opening a folder?\n\nThe header is automatically discovered on my laptop with the same version of VS2019 and the same environment path. I have nodejs tools installed for Visual Studio.\n\nI want to be able to do #include <napi.h> and have the header discovered. At the moment I must do #include \"../node_modules/node-addon-api/napi.h\"" ]
[ "c++", "node.js", "visual-studio", "visual-studio-2019", "node-addon-api" ]
[ "Why is this node js request returning 401 status code?", "This is a simple oauth2 request for an access token. Running this returns a 401 status code and a null error object. Passing the same parameters with a curl request completes successfully.\n\nvar request = require('request');\nvar payload = {\n \"grant_type\": \"password\",\n \"client_id\": user.clientID,\n \"client_secret\": user.clientsecret,\n \"username\": user.username,\n \"password\": user.password\n };\n\nvar options = {\n method: 'POST',\n url: baseURL + passrequestURL,\n headers: {\n 'accept': \"application/json\",\n 'content-type': \"application/x-www-form-urlencoded\"\n },\n data: JSON.stringify(payload)\n };\n\nfunction callback(error, response, body) {\n if (!error && response.statusCode == 200) {\n var info = JSON.parse(body);\n console.log(info);\n } else {\n console.log(response.statusCode);\n }\n}\n\nrequest(options, callback);" ]
[ "node.js", "oauth", "oauth-2.0", "httprequest" ]
[ "Kafka Handover Closed Exception in Apache Flink", "I deployed Flink on Kubernetes cluster after deployment in some time it is started through below error and because of flink restart strategy the flink is not processing any data after giving 5 retries to recover the job. Below is error i am seeing in flink task manager logs\n2021-02-09 14:05:05.545 [Source: Custom Source -> Filter -> Map (10/12)] WARN org.apache.flink.streaming.runtime.tasks.StreamTask - Error while canceling task.\norg.apache.flink.streaming.connectors.kafka.internal.Handover$ClosedException: null\n at org.apache.flink.streaming.connectors.kafka.internal.Handover.close(Handover.java:182)\n at org.apache.flink.streaming.connectors.kafka.internal.KafkaFetcher.cancel(KafkaFetcher.java:175)\n at org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumerBase.cancel(FlinkKafkaConsumerBase.java:818)\n at org.apache.flink.streaming.api.operators.StreamSource.cancel(StreamSource.java:147)\n at org.apache.flink.streaming.runtime.tasks.SourceStreamTask.cancelTask(SourceStreamTask.java:136)\n at org.apache.flink.streaming.runtime.tasks.StreamTask.cancel(StreamTask.java:602)\n at org.apache.flink.runtime.taskmanager.Task$TaskCanceler.run(Task.java:1355)\n at java.lang.Thread.run(Thread.java:748)\n2021-02-09 14:05:05.545 [Sink: Unnamed (6/12)] INFO org.apache.flink.runtime.taskmanager.Task - Sink: Unnamed (6/12) (d9c63e510c0a10e749e634e04db2f06f) switched from CANCELING to CANCELED.\n2021-02-09 14:05:05.546 [Sink: Unnamed (6/12)] INFO org.apache.flink.runtime.taskmanager.Task - Freeing task resources for Sink: Unnamed (6/12) (d9c63e510c0a10e749e634e04db2f06f).\n2021-02-09 14:05:05.545 [Source: Custom Source -> Filter -> Map (4/12)] WARN org.apache.flink.streaming.runtime.tasks.StreamTask - Error while canceling task.\norg.apache.flink.streaming.connectors.kafka.internal.Handover$ClosedException: null\n at org.apache.flink.streaming.connectors.kafka.internal.Handover.close(Handover.java:182)\n at org.apache.flink.streaming.connectors.kafka.internal.KafkaFetcher.cancel(KafkaFetcher.java:175)\n at org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumerBase.cancel(FlinkKafkaConsumerBase.java:818)\n at org.apache.flink.streaming.api.operators.StreamSource.cancel(StreamSource.java:147)\n at org.apache.flink.streaming.runtime.tasks.SourceStreamTask.cancelTask(SourceStreamTask.java:136)\n at org.apache.flink.streaming.runtime.tasks.StreamTask.cancel(StreamTask.java:602)\n at org.apache.flink.runtime.taskmanager.Task$TaskCanceler.run(Task.java:1355)\n at java.lang.Thread.run(Thread.java:748)\n2021-02-09 14:05:05.546 [Sink: Unnamed (6/12)] INFO org.apache.flink.runtime.taskmanager.Task - Ensuring all FileSystem streams are closed for task Sink: Unnamed (6/12) (d9c63e510c0a10e749e634e04db2f06f) [CANCELED]\n\nI searched in the internet but didn't get any info on above error but i got this blog saying that the number of partitions should be equal to parallelism in flink. So i have 6 partitions in my topic so i added flink parallelism 6 still getting the above error. It is coming in two scenarios either at boot strap time of the flink application or after processing heavy volume of payloads. I increased network buffers also thought of may be flink is not getting enough network buffers while processing data still no luck. I am using Flink 1.10.0 and flink-connector-kafka_2.12. Please help me in resolving the issue. Thanks in advance." ]
[ "apache-flink", "flink-streaming" ]
[ "Failed to send SMS in Hindi", "I need to send SMS in hindi, for this I need to pass the hindi string through URL.\n\nAs I am coading in php I used urlencode($hindimessage) on string and passed complete URL through file_get_contents(). On executing I got error:\n\nWarning: file_get_contents(http://IP GOES HERE/smpp/sendsms?username=$name&password=******&to=$contact&from=DEMOTT&coding=3&&text=%E0%A4%AE%E0%A4%A8%E0%A5%80%E0%A4%B7+%E0%A4%95%E0%A5%81%E0%A4): failed to open stream: HTTP request failed! HTTP/1.1 505 HTTP Version Not Supported\n\n\nWithout using urlencode(), the server treats text as EMPTY STRING and rejects.\n\nI also tried Using utf8_encode() encoding. I recive message in HTML tags like ही....\n\nBut when I use the API URL directly I am able to recive the message in hindi since API is Unicode API coding=3 enbled for Hindi text.(i.e API is working Properly)\n\nPlease Inform what kind of approach I need to adopt for sending message in both Hindi as well as in English.\n\nThanks in Advance" ]
[ "php", "api", "sms" ]
[ "yaml-cpp doesn't compile with g++", "I need to get yaml-cpp running, but it just won't compile without errors. I'm using Ubuntu 12.04 and yaml-cpp-0.5.1 from here, which was installed using 'cmake' and 'sudo make install' to make sure the libraries are correctly copied to the desired path '/usr/local/include/yaml-cpp'.\n\nFor testing purposes I tried to compile a few lines of code\n\n#include \"yaml-cpp/yaml.h\"\nint main(int argc, char **argv) {\n YAML::Node config = YAML::Load(\"[1,2,3]\");\n return 0;\n}\n\n\nwhich I basically got from this page here. If I now run\n\ng++ -o yaml_test yaml_test.cpp\n\n\nor\n\ng++ -I/usr/local/include -L/usr/local/lib -lyaml-cpp -o yaml_test yaml_test.cpp\n\n\nI get always the same error message\n\n/tmp/ccgvKdN2.o: In function `main':\nyaml_test.cpp:(.text+0x1d): undefined reference to `YAML::Load(char const*)'\n\n\nwhich as far as I know means that the libraries have not been found.\n\nWhat is going on here? Why won't it just compile?" ]
[ "yaml-cpp" ]
[ "Scipy.sparse CSC-matrix performance", "I'm currently trying to solve some equations using implicit euler. Since I was bored of Fortran, I thought it might be a good idea to try it with Python and see how close I can come (from performance point of view) to the existing Fortran program. For my problem, i want to take advantage of sparse matrices. \nI encountered that the current bottleneck of my program is initializing the sparse matrix and subtract something from the diagonal.\n\nThe following minimal example demonstrates this:\n\nimport numpy as np\nfrom scipy.sparse import csc_matrix\nfrom scipy.sparse.linalg import spsolve\nfrom timeit import default_timer\n\n# Example data for Sparse Matrix in CSC format\ndata = np.array([ -6.07315337e+07, -1.08191534e+06, -5.85677031e+07, \\\n 5.96496184e+07, 1.99723260e+07, -3.99136095e+07, \\\n -3.10384281e+04, 1.99412852e+07, 3.10384281e+04, \\\n 4.14012789e+04, -4.13845644e+04, -4.14179805e+04, \\\n 4.13845708e+04, 1.67016486e+01, 6.40664368e+03, \\\n -1.21556953e+02, 6.28508672e+03, -6.40664368e+03, \\\n 1.21556953e+02, 1.87698938e-03, 1.87698938e-03, \\\n -1.87698938e-03, 6.17782975e-05, 6.17782975e-05, \\\n -6.17782975e-05, 3.23024684e+00, 3.23024684e+00, \\\n -3.23024684e+00, 1.59838512e+00, 1.59838512e+00, \\\n -1.59838512e+00, 1.96353333e-02, 1.96353333e-02, \\\n -1.96353333e-02, 4.25269958e+01, 4.25269958e+01, \\\n -4.25269958e+01, 4.84489810e-06, 4.84489810e-06, \\\n -4.84489810e-06, 2.54951658e-07, 2.54951658e-07, \\\n -2.54951658e-07, 6.42250438e-08, 6.42250438e-08, \\\n -6.42250438e-08])\n\nindices = np.array([ 0, 1, 2, 3, 0, 1, 2, 3, 4, 0,\\\n 1, 2, 4, 5, 0, 1, 2, 3, 5, 0,\\\n 3, 4, 0, 4, 5, 0, 5, 6, 0, 6,\\\n 7, 0, 7, 8, 0, 8, 9, 0, 9, 10,\\\n 0, 10, 11, 0, 11, 12], dtype=np.int32)\n\nindptr = np.array([ 0, 4, 9, 14, 19, 22, 25, 28, 31, 34,\\\n 37, 40, 43, 46], dtype=np.int32)\n\n# Stop the time to initialize the Sparse matrix in CSC-format\nstart = default_timer()\nfor i in range(10000):\n J = csc_matrix((data, indices, indptr), shape=(13, 13))\nstop = default_timer()\nprint 'Initialize:'.ljust(15),stop - start\n\n# Set the diagonal of the matrix. The diagonal is in principle known.\nstart = default_timer()\nfor i in range(10000):\n J.setdiag(1./1e-10 + J.diagonal())\nstop = default_timer()\nprint 'Set diagonal:'.ljust(15), stop - start\n\n# Set an array to solve something\nb = np.array([ -4.16737068e+05, 8.32180182e+05, 1.29378997e+03,\\\n -4.15443441e+05,-1.29326784e+03,-2.60963259e-01,\\\n 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\\\n 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\\\n 0.00000000e+00])\n\n# Stop the time to solve the system\nstart = default_timer()\nfor i in range(10000):\n x = spsolve(J,b)\nstop = default_timer()\nprint 'Solve:'.ljust(15), stop - start\n\n\nI know that changing the sparsity of a matrix is usually expensive. In principle I know the indices of the diagonal, but I don't know how to change the data, once it is stored in a scipy csc_matrix. But also the initialization of the Matrix is almost as expensive as solving the system? For me the output of the example program is:\n\nInitialize: 0.516402959824 \n\nSet diagonal: 1.67107796669\n\nSolve: 0.845117807388\n\nIs there a way to get around the scipy sparse matrices or speeding this up? I thought about directly calling Pardiso, but this looked rather complicated for me." ]
[ "python", "numpy", "scipy", "sparse-matrix" ]
[ "How to proper use forloop in ajax", "can anyone help me with my code in ajax....i have some error in my script code in ajax because of improper use of forloop...can anyone help me with my code please.\n\nmy problem is in the ajax script code....the update.php is ok no error it works perfectly.\n\nscript code:\n\n<script type=\"text/javascript\">\n$(document).ready(function () {\n $('#updates').click(function (e) {\n\n e.preventDefault();\n\n\n var $region = $('#t_region').val();\n var $town = $('#t_town').val();\n var $uniq_id = $('#t_uniq_id').val();\n var $position = $('#t_position').val();\n var $salary_grade = $('#t_salary_grade').val();\n var $salary = $('#t_salary').val();\n\n for($n=1;$n<=15;$n++) {\n var $id = $('#id'.$n).val();\n var $aic = $('#aic'.$n).val();\n var $name = $('#name'.$n).val();\n var $optA = $('#optA'.$n).val();\n var $optB = $('#optB'.$n).val();\n var $optC = $('#optC'.$n).val();\n var $optD = $('#optD'.$n).val();\n var $other_qual = $('#other_qual'.$n).val();\n var $interview = $('#interview'.$n).val();\n var $total = $('#total'.$n).val();\n\n\n }\n\n $.ajax({\n type: \"POST\",\n url: \"update.php\",\n data: {\n region_text: $region,\n town_text: $town,\n uniq_id_text: $uniq_id,\n position_text: $position,\n salary_grade_text: $salary_grade,\n salary_text: $salary,\n\n for($x=1;$x<=15;$x++) {\n\n id'.$x.'_text: $id,\n aic'.$x.'_text: $aic,\n name'.$x.'_text: $name,\n optA'.$x.'_text: $optA,\n optB'.$x.'_text: $optB,\n optC'.$x.'_text: $optC,\n optD'.$x.'_text: $optD,\n other_qual'.$x.'_text: $other_qual,\n interview'.$x.'_text: $interview,\n total'.$x.'_text: $total,\n }},\n cache: false,\n success: function (data) {\n\n\n }\n\n });\n\n });\n });\n</script>\n\n\nupdate.php code:\n\n<?php\n include('../connection.php');\n date_default_timezone_set('Asia/Manila'); \n\n $region = @$_POST['region_text'];\n $town = @$_POST['town_text'];\n $uniq_id = @$_POST['uniq_id_text'];\n $position = @$_POST['position_text'];\n $salary_grade = @$_POST['salary_grade_text'];\n $salary = @$_POST['salary_text'];\n\n$dupesql = \"SELECT * FROM afnup_worksheet WHERE funiq_id = '$uniq_id'\";\n$duperow = mysql_query($dupesql);\nif(mysql_num_rows($duperow) > 0){\n exit;\n}else{\n\n for($n=1;$n<=15;$n++) {\n\n\n $id = @$_POST['id'.$n.'_text'];\n $aic = @$_POST['aic'.$n.'_text'];\n $name = @$_POST['name'.$n.'_text'];\n $optA = @$_POST['optA'.$n.'_text'];\n $optB = @$_POST['optB'.$n.'_text'];\n $optC = @$_POST['optC'.$n.'_text'];\n $optD = @$_POST['optD'.$n.'_text'];\n $other_qual = @$_POST['other_qual'.$n.'_text'];\n $interview = @$_POST['interview'.$n.'_text'];\n $total = @$_POST['total'.$n.'_text'];\n\n\n\nif(!empty($name)){\n$query = \"INSERT INTO afnup_worksheet (faic,fregion,ftown,funiq_id,fposition,fsalary_grade,fsalary,fnl_name,edu_attain,experience,seminars,eligibility,other_qual,interview,ftotal,dateinputed) \nVALUES \n('$aic','$region','$town','$uniq_id','$position','$salary_grade','$salary','$name','$optA','$optB','$optC','$optD','$other_qual','$interview','$total',CURRENT_TIMESTAMP)\";\n$resource = mysql_query($query) or die(mysql_error());\n }\n }\n}\n?>" ]
[ "javascript", "php", "jquery", "mysql", "ajax" ]
[ "Nodejs Ferros Buffer error when trying to save to file", "i want to use ferros buffer in my application.\nbut i receive error when trying to save the buffer to file. here is my code : \nplease kindly help to check... \n\nvar fs = require('fs');\nvar B = require('buffer/').Buffer;\n\n var buffin = fs.readFileSync('calibri.ttf');\n\n var b64 = buffin.toString('base64');\n\n var bf = new B(b64,'base64');\n\n fs.writeFile('calibro.ttf', bf, function (err) {\n if (err) throw err;\n console.log('It\\'s saved!');\n });\n\n\nhere is my error message :\n\nD:\\Project\\testbuffer\\node_modules\\buffer\\index.js:703\n return String.fromCharCode.apply(String, res)\n ^\nRangeError: Maximum call stack size exceeded\n at utf8Slice (D:\\Project\\testbuffer\\node_modules\\buffer\\index.js:703:30)\n at Buffer.toString (D:\\Project\\testbuffer\\node_modules\\buffer\\index.js:412:3\n8)\n at fs.js:1079:63\n at FSReqWrap.oncomplete (fs.js:95:15)\n\n\nplease kindly help," ]
[ "javascript", "node.js", "browserify", "fs" ]
[ "insert magento single product with list view on custom page", "I am trying to call a magento single product from a custom phtml file with the list view style but I can't get it right.\n\nI have a phtml file calling a copy of list.phtml. this copy is affichage-demo.phtml\n\nthis phtml file is called from another phtml file with \n\n<?php print $this->getLayout()\n ->createBlock(\"core/template\")\n ->setTemplate(\"page/cms/aide/affichage-demo.phtml\")\n ->toHtml(); ?>\n\n\nin affichage-demo.phtml, I have tried replacing \n\n<?php\n $_productCollection=$this->getLoadedProductCollection();\n $_helper = $this->helper('catalog/output');\n?>\n\n\nby\n\n<?php\n $id=23;\n $_productCollection=Mage::getModel('catalog/product');\n $_productCollection->load($id);\n $_helper = $this->helper('catalog/output');\n?>\n\n\nwhere 23 is the id of the product i want to display. But it does not show nothing and the other attempts where just as unsuccessful.\n\nCan someone guide me in how to modify this file or what else to do to display my single product like it is displayed in the list view?\n\nThank you a lot,\nRegards" ]
[ "php", "magento", "zend-framework" ]
[ "How to prevent EMR Spark step from retrying?", "I have an AWS EMR cluster (emr-4.2.0, Spark 1.5.2), where I am submitting steps from aws cli. My problem is, that if the Spark application fails, then YARN is trying to run the application again (under the same EMR step).\nHow can I prevent this?\n\nI was trying to set --conf spark.yarn.maxAppAttempts=1, which is correctly set in Environment/Spark Properties, but it doesn't prevent YARN from restarting the application." ]
[ "amazon-web-services", "apache-spark", "yarn", "emr" ]
[ "Returning Assembly Version Numbers from a different application", "Let me preface this question by saying I am fairly new to the concept of Assemblies. I am trying to create a method with in a namespace I have called API. The methods look like this: \n\nPartial Public Class AppInfo\n\n ' This function will return the VersionMajor Element of the Assembly Version\n Function VersionMajor() As String\n Dim txt As String = Assembly.GetExecutingAssembly.GetName.Version.Major.ToString()\n If txt.Length > 0 Then\n Return txt\n Else\n Return String.Empty\n End If\n End Function\n\n ' This function will return the VersionMinor Element of the Assembly Version\n Function VersionMinor() As String\n Dim txt As String = Assembly.GetExecutingAssembly.GetName.Version.Minor.ToString()\n If txt.Length > 0 Then\n Return txt\n Else\n Return String.Empty\n End If\n End Function\n\n ' This function will return the VersionPatch Element of the Assembly Version\n Function VersionPatch() As String\n Dim txt As String = Assembly.GetExecutingAssembly().GetName().Version.Build.ToString()\n If txt.Length > 0 Then\n Return txt\n Else\n Return String.Empty\n End If\n End Function\n\n ' This function will return the entire Version Number of the Assembly Version\n Function Version() As String\n Dim Func As New AppInfo\n Dim txt As String = VersionMajor() + \".\" + VersionMinor() + \".\" + VersionPatch()\n If txt.Length > 0 Then\n Return txt\n Else\n Return String.Empty\n End If\n End Function\n\nEnd Class\n\n\nI have other projects within the same solution that call the API as an additional reference. What I'd like to accomplish is say I have a project that references the API project called Test. In the home controller of test I have a view data that calls the Version method. Like this:\n\nFunction Index() As ActionResult\n Dim func As New API.AppInfo\n ViewData(\"1\") = func.Version\n Return View()\nEnd Function\n\n\nI'd like the viewdata to return the Version number of the Test assembly, but instead this returns the API Assembly version. What am I doing wrong here?" ]
[ "vb.net", "api", "methods", ".net-assembly" ]
[ "Binding ng-model to a Service parameter from inside a Template", "I keep a data model in a service so that various controllers can use them. Inside the controller I scope it so that elements can bind to it using ng-model:\n\nIn the controller:\n\nangular.module('hiveApp').controller('weatherController', function($scope, $rootScope, weatherModel, messageService, utilityService, $http, $timeout, $cookies, $window, $controller) {\n\n$scope.weatherModel = weatherModel;\n\n\nThen in the HTML element:\n\n<input type=\"text\" id=\"city\" ng-model=\"weatherModel.city\" />\n\n\nSo far so good, this works. The problem occurs when I bring a directive into the mix. I have a directive that handles a pair of radio buttons, and makes use of a template. That template attempts to use ng-model to reference that same weatherModel service parameters, however while it works from the HTML in the page itself, the directive template doesn't work:\n\napp.directive('radiopair', function() {\nreturn {\n restrict: 'E',\n template: `\n <div style=\"color:white; float:left\">\n <input type=\"radio\" id=\"metric\" name=\"conversion\" value=\"metric\"\n ng-model=\"weatherModel.conversion\" selected> Metric<br>\n <input type=\"radio\" id=\"imperial\" name=\"conversion\" value=\"imperial\"\n ng-model=\"weatherModel.conversion\"> Imperial<br>\n </div>\n `,\n link: function ($scope, element, attrs) {\n element.on('click', function (event) {\n event.currentTarget.selected = true;\n $scope.refreshTable(); \n });\n } \n}\n});\n\n\nWhen I toggle between the two buttons, the ng-model=weatherModel.conversion value never gets updated. I figure this has got to be some scoping issue but I'm hitting a wall as to how to fix it." ]
[ "javascript", "angularjs", "angularjs-directive", "angularjs-templates" ]
[ "ingress configuration for dashboard", "I did nginx ingress controller tutorial from github and\nexposed kubernetes dashboard\n\nkubernetes-dashboard NodePort 10.233.53.77 <none> 443:31925/TCP 20d\n\n\ncreated ingress \n\napiVersion: extensions/v1beta1\nkind: Ingress\nmetadata:\n annotations:\n ingress.kubernetes.io/ssl-passthrough: \"true\"\n nginx.org/ssl-backends: \"kubernetes-dashboard\"\n kubernetes.io/ingress.allow-http: \"false\"\n name: dashboard-ingress\n namespace: kube-system\nspec:\n tls:\n - hosts:\n - serverdnsname\n secretName: kubernetes-dashboard-certs\n rules:\n - host: serverdnsname\n http:\n paths:\n - path: /dashboard\n backend:\n serviceName: kubernetes-dashboard\n servicePort: 443\n\n\n\n\ningress-nginx ingress-nginx NodePort 10.233.21.200 <none> 80:30827/TCP,443:32536/TCP 5h\n\n\nhttps://serverdnsname:32536/dashboard\nbut dashboard throws error \n\n2018/01/18 14:42:51 http: TLS handshake error from ipWhichEndsWith.77:52686: tls: first record does not look like a TLS handshake\n\n\nand ingress controller logs\n\n2018/01/18 14:42:51 [error] 864#864: *37 upstream sent no valid HTTP/1.0 header while reading response header from upstream, client: 10.233.82.1, server: serverdnsname, request: \"GET /dashboard HTTP/2.0\", upstream: \"http://ipWhichEndsWith.249:8443/dashboard\", host: \"serverdnsname:32536\"\n10.233.82.1 - [10.233.82.1] - - [18/Jan/2018:14:42:51 +0000] \"GET /dashboard HTTP/2.0\" 009 7 \"-\" \"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36 OPR/49.0.2725.64\" 25 0.001 [kube-system-kubernetes-dashboard-443] ipWhichEndsWith.249:8443 7 0.001 200\n\n\nOn my mind it is related with nginx redirection to upstream: \"http://ipWhichEndsWith.249:8443/dashboard\" .\ntried to update controller image version to 0.9.0-beta.19 - didnt help\n\nThank you for any help." ]
[ "nginx", "kubernetes", "dashboard", "docker-ingress" ]
[ "how to add a .net 4.0 dll to a project running on dotnet 3.5", "I have a class library build in .net framework 4.0. i want to add it to an old project build in .net framework 3.5 .. is there any way to do it other than upgrading the old project? also it will be helpful if you could tell me how to downgrade my dll to 3.5" ]
[ ".net", "frameworks", "version" ]
[ "How do I get access to PUT data with the ramaze framework?", "I'm attempting to use Ramaze, the ruby framework, to implement a RESTful controller. I can't seem to gain access to the data in the request when I send a PUT, however. Sample code:\n\nrequire 'ramaze'\n\nclass PutController < Ramaze::Controller\n map '/'\n\n def index\n \"Argument of \"+request[:id]\n end\nend\n\nRamaze.start\n\n\nAnd my interacting with it via curl:\n\n% curl -d id=5 \"http://localhost:7000/\"\nArgument of 5\n\n% curl -v -X PUT -d id=5 \"http://localhost:7000/\" > /dev/null\n...\nHTTP/1.1 500 Internal Server Error\n[With a backtrace revealing that the request object is nil]\n\n\nAm I doing something wrong? How am I supposed to be getting at the body of the PUT request in Ramaze?" ]
[ "ruby", "ramaze" ]
[ "Access Parent level object", "public class Activity\n{\n public games _Games {get;set;}\n public sports _Sports {get;set;}\n}\n\npublic class games : PropertyChangedBase\n{\n public int player\n { \n get;\n set; //have if- else statement\n }\n}\n\npublic class sports : PropertyChangedBase\n{\n public int sub{get;set;}\n}\n\n\nAim: when the games player is more than 2, I would like to update sports sub variable to 10. \n\nQuestion: How can I access the parent class and update the sports class variable?" ]
[ "c#", "parent-child", "inotifypropertychanged" ]
[ "How to set Image in Window Title in XAML with MashAPPs.Metro", "I have a window and want to set a Picture instead of the title text, but it only shows the String of the Image Namespace.\n\nCode:\n\n<Controls:MetroWindow x:Class=\"AdminControlCenter.View.MainView\"\n ...\n Title=\"{Binding ImageViewModel.TitleBarImage}\" Height=\"400\" Width=\"600\" \n mc:Ignorable=\"d\"\n d:DataContext=\"{d:DesignInstance vm:MainViewModel}\" Icon=\"{Binding ImageViewModel.Icon}\">\n\n\nPicture:\n\n\n\nThe Icon is shown Correctly and the Image is saved as a BitmapImage.\n\nHow can I set a Image in a window title instead of the normal text ?" ]
[ "c#", "wpf", "xaml", "mahapps.metro" ]
[ "main.vb, main.designer.vb and missing Form Designer", "I have been working with \"visual basic.net\" on a \"windows forms\" application. While manipulating controls and adding event handlers I noticed the resultant code was being generated within a file named 'main.designer.vb'. However, if I look in the solution explorer for my project there is no 'main.designer.vb' file, just 'main.vb'.\n\nThis is not a colossal problem as it runs properly. However, having closed the 'form designer' window I now cannot reopen it! 'main.vb' has no option to 'view in form designer'.\n\nAny advice on this?\n\nWould it be possible to copy the contents of 'main.designer.vb' in to 'main.vb' and delete 'main.designer.vb' entirely? If I did this, the next time I manipulated the form would the code be added to 'main.vb' or would a new 'main.designer.vb' be created?" ]
[ "vb.net", "visual-studio-2013" ]
[ "running parallel function with different inputs being trasnformed in the same input", "I'm trying to run parellel functions with async.js \n\nBut when I try to update rows of a database, the async function doesn't handle different inputs.\nIt updates the same values for the where part, which always updates only one record. How can I turn local variables for parallel runs of the same function different?\n\nThis is my code:\n\nexports.run_mercadolibre_jobs = function() {\n\n var Model = require('../../models/index').Model;\n var async = require(\"async\");\n\n\n var values = {\n attributes: ['environment_hash'],\n raw: true\n };\n\n Model\n .findAll(values)\n .then(function(accounts) {\n async.map(accounts, function (account) {\n module.exports.refresh_access_token(account.environment_hash);\n }); \n });\n\n}\n\n\n\nexports.refresh_access_token = function(environment_hash) {\n\n ...\n\n var env_hash = environment_hash;\n where = { environment_hash: env_hash };\n\n Model.findOne({where: where}).then(function (account) {\n if (!account) {\n // Item not found, create a new one\n\n\n } else {\n // Found an item, update it\n\n\n values = {\n refresh_token: body.refresh_token,\n expires_in: expires_in\n\n };\n\n Model.update(values, {where: where})\n .then(function () {\n console.log('updated!');\n })\n .catch(function (err) {\n console.log('error on update');\n });\n\n }\n });\n\n\n\n\n\n }\n });\n\n\n\n}" ]
[ "javascript", "node.js", "async.js" ]
[ "Julia: Products of sequences in a vectorized way", "Learning to pass from Python to Julia, I am trying to convert an old code that I have, that is calculating a product of sequence of this expression:\n\n\n\nI have two versions of the code in Python, one implemented with for loops, and the other using broadcasting. The for loop version is:\n\nimport numpy as np\nA = np.arange(1.,5.,1)\nG = np.array([[1.,2.],[3.,4.]])\n\ndef calcF(G,A):\n N = A.size\n print A\n print N\n F = []\n for l in range(N):\n F.append(G/A[l])\n print F[l]\n for j in range(N):\n if j != l:\n F[l]*=((G - A[l])/(G + A[j]))*((A[l] - A[j])/(A[l] + A[j]))\n return F\n\nF= calcF(G,A)\nprint F\n\n\nAnd the vectorized version I have learned from a response to my question here, is this function:\n\ndef calcF_vectorized(G,A):\n # Get size of A\n N = A.size\n\n # Perform \"(G - A[l])/(G + A[j]))\" in a vectorized manner\n p1 = (G - A[:,None,None,None])/(G + A[:,None,None])\n\n # Perform \"((A[l] - A[j])/(A[l] + A[j]))\" in a vectorized manner\n p2 = ((A[:,None] - A)/(A[:,None] + A))\n\n # Elementwise multiplications between the previously calculated parts\n p3 = p1*p2[...,None,None]\n\n # Set the escaped portion \"j != l\" output as \"G/A[l]\"\n p3[np.eye(N,dtype=bool)] = G/A[:,None,None]\n\n Fout = p3.prod(1)\n\n # If you need separate arrays just like in the question, split it\n return np.array_split(Fout,N)\n\n\nI tried to naively translate the Python for loops code to Julia:\n\nfunction JuliacalcF(G,A)\n F = Array{Float64}[]\n for l in eachindex(A)\n push!(F,G/A[l])\n println(A[i])\n for j in eachindex(A)\n if j!=l\n F[l]*=((G - A[l])/(G + A[j]))*((A[l] - A[j])/(A[l] + A[j]))\n end\n end\n end\n #println(alpha)\n return F\nend\nA = collect(1.0:1.0:5.0)\nG = Vector{Float64}[[1.,2.],[3.,4.]]\nprintln(JuliacalcF(G,A))\n\n\nBut is there a way to do it in a smart way as in the numpy broadcasting vectorized version?" ]
[ "python", "algorithm", "numpy", "julia", "array-broadcasting" ]
[ "Enable screen to sleep while playing video in Android WebView", "I have a WebView in an activity for monitoring a webcam. The feed is a javascript player embedded in an html page. I have control over the html page but not the stream and js player itself. The feed is bandwidth heavy both for the user and the provider. I am trying to force, to allow the device to sleep while watching video -- after a minute or two. It seems staying awake while playing video is baked into android. My problem is users are setting down their device and the app is playing away -- burning gigabytes of date and hours of battery life. \n\nIf the user pauses the player the device will sleep. If not it just plays on. If I google \"put android to sleep while playing video\" etc. ect. I am drowned with pages and pages of how to keep the device awake. It seems I am the only one in the world who wants sleep. \n\nIt would be nice to discover a flag opposite this:\n\ngetWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);\nlike: FORCE_SCREEN_TIMEOUT, 50000\n\n\nThe pertinent code from my MainActivity:\n\npublic class MainActivity extends AppCompatActivity {\nprivate WebView webView;\n\n\n@Override\nprotected void onCreate(Bundle savedInstanceState) {\nsuper.onCreate(savedInstanceState);\nsetContentView(R.layout.activity_main);\n\n// webview webcam\n\nString webcam = \"https://xxx/webcam.html\";\nwebView = (WebView) findViewById(R.id.webCam);\nwebView.setWebChromeClient(new WebChromeClientCustomPoster());\nwebView.setKeepScreenOn(false); // trying to get the thing to sleep\nwebView.setInitialScale(1); // to fill the screen no work\nwebView.getSettings().setLoadWithOverviewMode(true);\nwebView.getSettings().setUseWideViewPort(true);\nwebView.getSettings().setJavaScriptEnabled(true);\nwebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);\nwebView.loadUrl(webcam);\nWebSettings webSettings = webView.getSettings();\n\n// trying to pause webview with the js player buttons -- works\n@Override\npublic void onWindowFocusChanged(boolean hasFocus) {\n webView = (WebView) findViewById(R.id.webCam);\n // TODO Auto-generated method stub\n if (hasFocus) {\n try {\n Class.forName(\"android.webkit.WebView\")\n .getMethod(\"onResume\", (Class[]) null)\n .invoke(webView, (Object[]) null);\n } catch (Exception e) {\n\n }\n webView.resumeTimers();\n webView.loadUrl(\"javascript:setflashfocus()\");\n } else {\n try {\n Class.forName(\"android.webkit.WebView\")\n .getMethod(\"onPause\", (Class[]) null)\n .invoke(webView, (Object[]) null);\n } catch (Exception e) {\n\n }\n webView.pauseTimers();\n }\n super.onWindowFocusChanged(hasFocus);\n}\n\n\nSome of the xml if necessary: \n\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<androidx.constraintlayout.widget.ConstraintLayout \nxmlns:android=\"http://schemas.android.com/apk/res/android\"\nxmlns:app=\"http://schemas.android.com/apk/res-auto\"\nxmlns:tools=\"http://schemas.android.com/tools\"\nandroid:layout_width=\"match_parent\"\nandroid:layout_height=\"match_parent\"\nandroid:padding=\"8dp\"\ntools:context=\".MainActivity\">\n\n <WebView\n android:id=\"@+id/webCam\"\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n app:layout_constraintBottom_toBottomOf=\"parent\"\n app:layout_constraintEnd_toEndOf=\"parent\"\n app:layout_constraintStart_toStartOf=\"parent\"\n app:layout_constraintTop_toTopOf=\"parent\"\n app:layout_constraintVertical_bias=\"0.022\" />" ]
[ "android", "webview", "video-streaming", "sleep" ]
[ "Inheriting a type declaration in the presence of templates", "Is there a way to declare types in a base class template and re-use those definitions in the child class template?\n\nFor example, consider the following attempt:\n\ntemplate <typename T_>\nstruct A {\n using T=T_;\n};\n\ntemplate <typename T_>\nstruct B: public A<T_> {\n T a;\n};\n\n\nThe compiler complains that using the type T in the definition of B is illegal. It doesn't wait for instantiation to see that this type is inherited from A. So, is there a way to declare types in a base class template and re-use those definitions in the child class template?" ]
[ "c++", "templates", "c++11", "inheritance" ]
[ "how to get array using $.ajax in jquery", "I have page getorgname.php which return array so how do i get the array in my jquery page using $.ajax method?\n\n$ds = my_ldap_connect(CHI_LDAP_LOCATION, CHI_LDAP_PORT, CHI_LDAP_USE_TLS);\n$groups = get_all_groups($ds, CHI_LDAP_BASE_DN, CHI_LDAP_BIND_DIRECTORY, CHI_LDAP_BIND_PASSWORD);\n$sr = @ldap_search($ds, \"ou=people,\".CHI_LDAP_BASE_DN, \"(uid=*)\");\n$nt = ldap_get_entries( $ds, $sr );\n//echo \"<pre>\";\n//print_r($nt);\n//echo \"</pre>\";\nforeach( $nt as $each )\n{\n if( is_array( $each ) )\n {\n\n $json[] = trim('\"'.$each['o'][0].'\"');\n\n }\n}\n\n\nreturn $json;" ]
[ "php", "jquery", "ajax" ]
[ "curl won't download empty file", "curl -o foo.txt http://test.barrycarter.info/emptyfile.txt\ncurl -O http://test.barrycarter.info/emptyfile.txt\n\nI just tried both the above, and neither foo.txt nor emptyfile.txt were created.\n\nHow can I make curl create them? Knowing that a file (URL) exists and is empty can be useful.\n\nIn particular, I'm trying to mirror geonames daily updates, and it so happens that today's \"http://download.geonames.org/export/dump/alternateNamesDeletes-2015-05-28.txt\" file is empty. It would be useful to know this instead of simply not downloading it.\n\n(Note: I created an emptyfile above for testing, since geonames' file will disappear within a day)" ]
[ "curl" ]
[ "Adding to Individual Array Elements - C++", "I need to add either +0.25 or -0.25 to all elements within an array. Here is what I have so far. Any help would be appreciated.\n\nint main() {\n\ndouble i;\n\n\n// Arrays\ndouble x[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};\ndouble x2[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};\n\n\n\nfor(i=1; i<=10; i++) {\n const double pM[2] = {-1, 1};\n int randoid = rand() % 2;\n for(i=1; i<=10; i++){\n x2[i] = x[i] + pM[randoid]*0.25; //Error Line\n }\n}\n\ncout << x;\ncout << x2;\n}\n\n\nI get this error at the marked line: \"invalid types 'double[10][double] for array subscript\"" ]
[ "c++" ]
[ "2-dimensional matrix", "whats the logic to find the sum of alternate elements of a two-dimensional matrix." ]
[ "c++" ]
[ "do ruby plugins make starting vim very slow?", "Lately vim takes a long time to start up when I'm running it to edit a ruby file or a rails project. But it starts up fast when invoked on a plain text file. Is there any way to find out which ruby vim plugins are most responsible for prolonging the startup?" ]
[ "ruby", "vim" ]
[ "plt.matshow: How to include a key describing color values in a correlation matrix", "I am using plt.matshow to create a correlation matrix for a set of dataframe series as a step to preprocessing data for use in a data science project. I would like to add a 'key' alongside the correlation matrix that describes the relationship between the colors and their numeric values. Any ideas as to how to improve the readability of my current correlation matrix?\n\nreviewed documentation for matplotlib.pyplot.matshow and matplotlib.pyplot without success in identifying attribute tools\n\n plt.matshow(xspace.corr())\n plt.xticks(range(len(xspace.columns)), xspace.columns, rotation = \n 'vertical')\n print(plt.show())\n\n\nthe resulting correlation matrix is as expected and does not include a key describing the relationship between the colors and the numeric correlation values between the series." ]
[ "python-3.x" ]
[ "Valgrind error and generic list with one allocation per element", "I'm experimenting with linked lists and tried to create a generic doubly linked list which allocates memory only once for each node. It means that the memory for the node and the element the node contains is allocated within same malloc invocation.\nThe list itself is a structure which contains size of a unit (initialized with sizeof(struct which_is_an_element):\n\nstruct doubly_linked_list\n{\n struct dll_node *head, *tail;\n size_t elem_size;\n};\n\n\nThe node:\n\nstruct dll_node\n{\n struct dll_node *next, *prev;\n void *elem;\n};\n\n\nNow, when I try to insert element and initialize it:\n\nstatic struct dll_node * new_node(\n struct doubly_linked_list *l, \n void *elem)\n{\n struct dll_node *n = malloc (\n sizeof(struct dll_node) + l->elem_size);\n\n // This line throws valgrind error\n memcpy(n + sizeof(struct dll_node), elem, l->elem_size); \n\n n->prev = n->next = NULL;\n n->elem = n + sizeof(struct dll_node);\n return n;\n}\n\n\nI get a valgrind error:\n\n\n Invalid write of size 8\n at 0x4C3217B: memcpy@@GLIBC_2.14 (vg_replace_strmem.c:1022)\n by 0x400705: new_node (doubly_linked_list.c:20)\n by 0x400768: dl_list_insert_at_tail (doubly_linked_list.c:30)\n by 0x40093F: main (main.c:24)\n Address 0x5204280 is 480 bytes inside an unallocated block of size 4,194,112 in arena \"client\" \n\n\n\nDoes really memcpy write inside unallocated block as the size of the allocated memory is equal to sizeof(struct which_is_an_element) + sizeof(dll_node)?\nAre those issues caused by valgrind thinking the allocated memory has size = sizeof(struct dll_node) because of the type of the pointer called n inside new_node function which points to the data?\nIs this approach good? Can I allocate the memory once for each element or should I allocate memory for the node and the element separately?\nIf this approach is good then how could I get rid of this valgrind error?" ]
[ "c", "memory-management", "valgrind", "generic-programming", "pointer-arithmetic" ]
[ "Not getting selected radio button value from one HTML form to another in Python Flask", "I have a home page with radio buttons. I select an item (database type) and want to get the checked-value in python code and then after some validation want to display another form to connect to the selected database type. But after trying so many things, I am unable to get the selected-radio-button value and then unable to process conndb.html below. I am quite new to Python web development. Not getting anything working to meet this requirement. Home page pyhton code is \n\[email protected]('/')\ndef index():\ndb = get_db()\nif request.method == 'GET':\n posts = db.execute(\n 'SELECT id, DB_Tp'\n ' FROM DB_Type'\n ' ORDER BY DB_Tp ASC'\n ).fetchall()\n\n error = None\n if len(posts) == 0:\n error = 'No Database Type To Choose For Meta Data. Create New Entry'\n flash(error)\n\n return render_template('meta/index.html', posts = posts)\nelse: **#=> from here the code is never executed. It always falls thru to next function**\n\n checked = request.form['dbtype']\n print(\"This is \", checked, flush = True)\n if checked == \"MySql\":\n return render_template('meta/conndb.html')\n else:\n error = \"Nothing checked \"\n flash(error)\n return redirect(url_for(\"meta.index\")) \n\n\nindex.html is -\n\n{% extends 'base.html' %}\n\n{% block header %}\n <h1>{% block title %}Select Database Type{% endblock %}</h1>\n\n{% endblock %}\n\n{% block content %}\n <form class=\"post\" action=\"/conndb\">\n{% for post in posts %}\n <label class=\"body\">\n <input type=\"radio\" name=\"dbtype\" required>{{post['DB_TP']}}</label><br>\n{% if not loop.last %}\n{% endif %}\n{% endfor %} \n <button type=\"submit\">Next</button>\n</form>\n<hr>\n{% endblock %}\n\n\nDepending on the selected radio button, I want to perform different operations with different kind of DB. After getting the value from the selected radio button, I render this template to connect to database...\nconndb.html\n\n{% extends 'base.html' %}\n\n{% block header %}\n <h1>{% block title %}Provide Details To Connect To Database{% endblock %}</h1>\n{% endblock %}\n\n{% block content %}\n <form method=\"post\">\n <label for=\"host\">Host Name</label>\n <input name=\"host\" id=\"host\" required>\n <label for=\"user\">User ID</label>\n <input name=\"user\" id=\"user\" required>\n <label for=\"passwd\">Password</label>\n <input type=\"password\" name=\"passwd\" id=\"passwd\" required>\n <label for=\"db\">Schema</label>\n <input name=\"db\" id=\"db\" required>\n <input type=\"submit\" value=\"Get MetaData\">\n </form>\n{% endblock %} \n\n\nAny help is greatly appreciated." ]
[ "python", "html", "flask", "jinja2" ]
[ "Add a conditional foreign key field in a DJANGO model", "Models.py is shown below. The Release table has a foreign key system_requirements_id that points to the SystemRequirement table but I want that the user should fill the system_requirements_id only when there is no text in the system_requirements field in the Release table. Otherwise, the system_requirements_id can be left blank. How do I implement that?\n\nclass SystemRequirement(TimeStampedModel):\n code_name = models.TextField(blank=True)\n content = models.TextField()\n creation_date = models.DateField(auto_now=False, auto_now_add=True)\n\n def __unicode__(self):\n return self.code_name\n\nclass Release(TimeStampedModel):\n system_requirements = models.TextField(blank=True)\n system_requirements_id = models.ForeignKey(SystemRequirement,\n blank=True, null=True)" ]
[ "python", "django" ]
[ "why odoo display date format error when save model data?", "odoo v13:\nI've been working very well before, but I suddenly got the following error when saving these two days.\nWhen I try to comment out the date field, the error disappears, and when I reuse it, it goes wrong again. It can be determined that the problem is the date field, and it is the same error to change the date field to a datetime field. Please help me analyze the reasons.\nTypeError: format() expects a string or boolean:false parameter function()\n{var args=(arguments.length===1&&$.isArray(arguments[0]))?arguments[0]:arguments;var formattedString=this;for(var i=0;i<args.length;i++)\n{var pattern=new RegExp("\\\\{"+i+"\\\\}","gm");formattedString=formattedString.replace(pattern,args[i]);}\nreturn formattedString;}\n\ni view the error code ,in web.assets_common.js file, the 3060 line ,the object _options.format=null and newOptions.format=null then display error.\nI test found that all modules( including the system's own) as long as there is a date field to save, there will be this error." ]
[ "odoo" ]
[ "Twilio SMS Using PHP (Not Sending or Loading PHP page)", "So this is what's on the top of the PHP file:\n\n<?php\n // Start the session\n session_start();\n?>\n\n<?php\n // Get the PHP helper library from twilio.com/docs/php/install\n require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library\n\n // Your Account Sid and Auth Token from twilio.com/user/account\n $sid = \"ACXXXXXXXXXXXXXX\"; \n $token = \"XXXXXXXXXXXXXXXXXX\"; \n $client = new Services_Twilio($sid, $token);\n\n $client->account->messages->sendMessage(\"+1234567890\", \"+0987654321\", \"Please?! I love you <3, Twilio Test\");\n?>\n\n<?php\n // Start the session\n session_destroy();\n?>\n\n\nThen I have the <html> beneath.\n\nThe Issue I'm having is that the page just loads a white blank page and when I check the Twilio Log to see if any SMS are logged. \n\nBut the page loads just fine without the middle PHP (the part that's supposed to send the SMS through Twilio)\n\nThe Log is completely empty and shows no record of any outgoing SMS.\n\nAny help would be appreciated!" ]
[ "php", "twilio", "twilio-php" ]
[ "Is there any down time when porting numbers to Twilio", "Is there any down time (out of service) when porting numbers to Twilio? These are production phone numbers being ported from Telnyx over to Twilio." ]
[ "numbers", "porting" ]
[ "Scrapy - get the value of Javascript variable", "Using Scrapy, how do I get value of a Javascript variable ....\n\nHere is the my code ...\n\n<script rel=\"bmc-data\">\n var match = 'yes';\n var country = 'uk';\n var tmData = {\n \"googleExperimentVariation\": \"1\",\n \"pageTitle\": \"Child Care\",\n \"page_type\": \"claimed\",\n \"company_state\": \"wyostate\",\n \"company_city\": \"mycity\"\n };\n</script>\n\n\nI want to check the value of page_type variable. If its \"claimed\" process the page, or else move on ....\n\nI have already seen this and this \n\nI have tried this ...\n\npattern = r'page_type = \"(\\w+)\",'\nresponse.xpath('//script[@rel=\"bmc-data\"]').re(pattern)\n\n\nbut ofcourse this is not working, becuase I think my regex is wrong." ]
[ "python", "python-2.7", "scrapy" ]
[ "Android RelativeLayout design issue", "I am facing android design issue , I can't understand why it happened it is weird.\n\nMy layout code : \n\n <RelativeLayout\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:layout_margin=\"10dp\">\n\n <RelativeLayout\n android:id=\"@+id/outgoing_layout_bubble\"\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:layout_marginLeft=\"60dp\"\n android:layout_marginRight=\"8dp\"\n android:background=\"@drawable/chatrectbg\"\n android:padding=\"10dp\"\n android:visibility=\"visible\">\n\n <TextView\n android:id=\"@+id/message\"\n style=\"@style/chat_text_message_style\"\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:layout_toStartOf=\"@+id/time\"\n android:autoLink=\"web\"\n android:paddingRight=\"10dp\"\n android:text=\"@{chat.messageText}\"\n android:textColor=\"@android:color/white\"\n android:textStyle=\"bold\" />\n\n <TextView\n android:id=\"@id/time\"\n style=\"@style/chat_timings\"\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:layout_alignParentBottom=\"true\"\n android:layout_alignParentRight=\"true\"\n android:layout_marginRight=\"4dp\"\n android:padding=\"5dp\"\n android:paddingRight=\"10dp\"\n android:text=\"@{chat.messageTime}\"\n android:textColor=\"@android:color/white\"\n android:textStyle=\"bold\" />\n\n </RelativeLayout> \n </RelativeLayout>\n\n\npreview of this code is as below : \n \n\nI want background color change wrapping text, but it doesn't. \nI can't understand what I am doing wrong?" ]
[ "android", "android-layout", "android-relativelayout", "android-xml" ]
[ "Razor if statement inside HTML", "Why I can do that:\n\n @Code\n Dim styleVisible As String = if(Model.IndicateurAchatPeriodique,\"block\",\"none\")\nEnd Code\n <div id=\"@sectionDCAId\" style=\"display:@styleVisible\">...\n\n\nbut not that:\n\n<div id=\"@sectionDCAId\" style=\"display:@If(Model.IndicateurAchatPeriodique,\"block\",\"none\")\">\n\n\nI just moved the if instruction inside the HTML but it throw an error. Why the compiler can't understand it?\nI don't need solutions, just an explanation. Thanks" ]
[ "asp.net-mvc", "vb.net", "razor" ]
[ "Function ReflectionParameter::export() is deprecated 7.4, alternative?", "I recently changed to Php 7.4 from 7.2 and I came across a deprecated function:\nFunction ReflectionParameter::export() is deprecated\n\nhttps://www.php.net/manual/en/reflectionparameter.export.php\nwhat to use instead?" ]
[ "php", "reflection", "deprecated" ]
[ "Regular expression to match error and associated few lines", "I am looking for a single line regular expression to match the word \"Error\" from the log file and i need to get the few lines above and below the lines that has the word \"Error\" for debugging purpose. \n\nFor example:\n I need to match for the word \"TypeError\" and get other few lines above and below this matched lines. atleast i need next 10 lines. Could anyone please help on this ?\n\nLog File content below =>\n\n**TypeError**: Parameter 'url' must be a string, not undefined\n at Url.parse (url.js:107:11)\n at urlParse (url.js:101:5)\n at Object.urlResolve [as resolve] (url.js:404:10)\n at parseMarkdown (/opt/controllers/api/userguide.js:53:19)\n at /opt/controllers/api/userguide.js:33:17\n at Object.<anonymous> (/opt/models/api.js:172:4)\n at /opt/lib/data/api.js:138:5\n at IncomingMessage.<anonymous> (/opt/node_modules/httpunch/lib/_wrap_request.js:100:9)\n at IncomingMessage.g (events.js:180:16)\n at IncomingMessage.emit (events.js:117:20)" ]
[ "javascript", "regex", "node.js", "error-handling", "monit" ]
[ "AES/CBC/PKCS#5 Encryption Algorithm In PHP", "Im attempting to integrate the SagePay payment gateway into a website using the 'Form Integration' method.\n\nBasically the form integration method works by inserting a FORM in a webpage and POSTing information to SagePay's servers whenever the Submit button for the FORM is selected. Before the information can be sent to SagePay's servers it must be encrypted using the AES/CBC/PKCS#5 algorithm, before being Base 64 encoded.\n\nI have a basic knowledge of encryption but I have no experience of using it in PHP. Can anyone please help me formulate the AES/CBC/PKCS#5 algorithm in PHP please?\n\nHere's my efforts so far:\n\n$CRYPT = \"Text Goes Here\";\n\n$blocksize = 16;//Does 16 Refer To 16 Bytes Or 16 Bits? 16 Bytes = 128 Bits.\n$cryptLength = strlen($CRYPT);\n$cryptLengthModuloBlocksize = $cryptLength % $blocksize;\n$pad = $blocksize - $cryptLengthModuloBlocksize;\n$padString = str_repeat(chr($pad), $pad);\n$CRYPT = $CRYPT . $padString;\n\n$encryptionPassword = 'password';\n$Encrypted_CRYPT = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $encryptionPassword, $CRYPT, MCRYPT_MODE_CBC);\n\n$Base64_Encrypted_CRYPT = base64_encode($Encrypted_CRYPT);\n\necho \"<form action = 'https://test.sagepay.com/gateway/service/vspform-register.vsp' method = 'POST'>\n\n <input type = 'hidden' name = 'VPSProtocol' value = '3.00' />//\n <input type = 'hidden' name = 'TxType' value = 'PAYMENT' />\n <input type = 'hidden' name = 'Vendor' value = 'vendorName' />\n <input type = 'hidden' name = 'Crypt' value = '\" . $Base64_Encrypted_CRYPT . \"' />\n <input type= 'submit' value = 'Submit'>\n\n </form>\";\n\n\nAny help is much appreciated." ]
[ "php", "encryption", "aes", "opayo" ]
[ "Array to associative array", "I have an array like this : \n\narray(3) {\n [0]=>\n array(2) {\n [0]=>\n string(6) \"action\"\n [1]=>\n string(5) \"depot\"\n }\n [1]=>\n array(2) {\n [0]=>\n string(9) \"Demandeur\"\n [1]=>\n string(11) \"Particulier\"\n }\n [2]=>\n array(2) {\n [0]=>\n string(3) \"Nom\"\n [1]=>\n string(6) \"Cheval\"\n }\n\n\nBut I want an associative array, to access it like this : $_REQUEST['Nom'] and have in return 'Cheval' etc...\n\nThe first array is actually an object, created with jQuery and here is his construction : \n\njQuery('input:submit').click(function() {\n var itemMetaArray = {};\n jQuery('.frm_pro_form :input:not(:hidden, :submit)').each(function() {\n if(jQuery('#field_demande').val() != undefined){\n itemMetaArray['action'] = jQuery('#field_demande').val();\n } \n else itemMetaArray['action'] = jQuery('#field_demande2').val();\n var label = jQuery(this).closest('.frm_form_field').find('.frm_primary_label').text().trim();\n if(jQuery(this).attr('name').indexOf(\"file\") == -1 ) {\n itemMetaArray[label] = jQuery(this).val();\n }else{\n var fileName = jQuery(this).attr('name');\n fileName = fileName.substring(0,fileName.length-2);\n itemMetaArray[label] = fileName;\n }\n});\n\n\nAfter this, I do some parsing in PHP : \n\n$dataInfo = explode(\",\",$_POST['dataInfo']);\nfor ($i = 0; $i < count($dataInfo); ++$i){\n $tmpWithoutBrackets[$i] = trim($dataInfo[$i],\"{..}\");\n $tmpWithoutColon[$i] = explode(\":\",$tmpWithoutBrackets[$i]);\n for($j = 0; $j < (count($tmpWithoutColon) + 1); ++$j){\n $arrayFinal[$i][$j] = trim($tmpWithoutColon[$i][$j],\"\\\"\");\n }\n $arrayFinal[$i] = array_diff($arrayFinal[$i],array(\"\"));\n}\n\n\n$arrayFinal is the same array as arrayInfo\n\nThanks in advance for your help" ]
[ "php", "arrays", "associative" ]
[ "Spring Data Neo4j Ridiculously Slow Over Rest", "public List<Errand> interestFeed(Person person, int skip, int limit)\n throws ControllerException {\n\n person = validatePerson(person);\n String query = String\n .format(\"START n=node:ErrandLocation('withinDistance:[%.2f, %.2f, %.2f]') RETURN n ORDER BY n.added DESC SKIP %s LIMIT %S\",\n person.getLongitude(), person.getLatitude(),\n person.getWidth(), skip, limit);\n String queryFast = String\n .format(\"START n=node:ErrandLocation('withinDistance:[%.2f, %.2f, %.2f]') RETURN n SKIP %s LIMIT %S\",\n person.getLongitude(), person.getLatitude(),\n person.getWidth(), skip, limit);\n Set<Errand> errands = new TreeSet<Errand>();\n System.out.println(queryFast);\n\n Result<Map<String, Object>> results = template.query(queryFast, null);\n\n\n Iterator<Errand> objects = results.to(Errand.class).iterator();\n return copyIterator (objects);\n}\n\npublic List<Errand> copyIterator(Iterator<Errand> iter) {\n Long start = System.currentTimeMillis();\n Double startD = start.doubleValue();\n List<Errand> copy = new ArrayList<Errand>();\n while (iter.hasNext()) {\n Errand e = iter.next();\n copy.add(e);\n System.out.println(e.getType());\n }\n Long end = System.currentTimeMillis();\n Double endD = end.doubleValue();\n p ((endD - startD)/1000);\n return copy;\n}\n\n\nWhen I profile the copyIterator function it takes about 6 seconds to fetch just 10 results. I use Spring Data Neo4j Rest to connect with a Neo4j server running on my local machine. I even put a print function to see how fast the iterator is converted to a list and it does appear slow. Does each iterator.next() make a new Http call?" ]
[ "spring", "neo4j", "cypher", "spring-data", "spring-data-neo4j" ]
[ "how to: r = requests.get(driver_current_url)", "r = requests.get(driver_current_url)\n\nHow to request and use the url from the driver in the request.\n(also the request request the url thru the driver)\nDriver = PATH = "C:\\Chromedriver\\chromedriver.exe"\ndriver = webdriver.Chrome(PATH)" ]
[ "python", "selenium", "python-requests" ]
[ "HtmlUnitDriver() not working", "I have a selenium project set up in Eclipse. I was able to get my selenium project to work with the firefox driver; however, i get the following error when I try to use the HtmlUnitDriver instead:\n\nException in thread \"main\" net.sourceforge.htmlunit.corejs.javascript.EvaluatorException: Exception: java.lang.RuntimeException: java.io.FileNotFoundException: \\Settlement\\static\\css\\WebDirect_1.css (The system cannot find the path specified)\nat net.sourceforge.htmlunit.corejs.javascript.Context.reportRuntimeError(Context.java:965)\nat net.sourceforge.htmlunit.corejs.javascript.Context.reportRuntimeError(Context.java:1017)\nat com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleSheet.loadStylesheet(CSSStyleSheet.java:279)\nat com.gargoylesoftware.htmlunit.javascript.host.html.HTMLLinkElement.getSheet(HTMLLinkElement.java:129)\nat com.gargoylesoftware.htmlunit.javascript.host.css.StyleSheetList.jsxFunction_item(StyleSheetList.java:126)\nat com.gargoylesoftware.htmlunit.javascript.host.Window.jsxFunction_getComputedStyle(Window.java:1454)\nat com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement.jsxGet_currentStyle(HTMLElement.java:208)\nat com.gargoylesoftware.htmlunit.html.DomNode.isDisplayed(DomNode.java:683)\nat org.openqa.selenium.htmlunit.HtmlUnitWebElement.getTextFromNode(HtmlUnitWebElement.java:572)\nat org.openqa.selenium.htmlunit.HtmlUnitWebElement.getText(HtmlUnitWebElement.java:524)\nat com.automation.selenium.HTMLToExcelExporter.extractParticipantID(HTMLToExcelExporter.java:753)\nat com.automation.selenium.HTMLToExcelExporter.generateFileOutputPath(HTMLToExcelExporter.java:760)\nat com.automation.selenium.HTMLToExcelExporter.initializeFileOutputStream(HTMLToExcelExporter.java:106)\nat com.automation.selenium.MainClass.main(MainClass.java:38)\n\n\nIn short, I'm trying to execute the following code:\n\nWebDriver webDriver = new HtmlUnitDriver();\nwebDriver.get(\"Some web page\");\nWebElement element = webDriver.findElement(By.xpath(\"some xpath\"));\n\n\nAny help would be greatly appreciated." ]
[ "java", "selenium", "htmlunit", "htmlunit-driver" ]
[ "Xcode 10.2 Update issue Build system error -1: Unable to load contents of file list: input/output xcfilelist", "After upgrading to Xcode 10.2 I am getting 2 errors \n\n\n :-1: Unable to load contents of file list: 'xxxxx/Pods/Target Support\n Files/Pods-xxxx/Pods-xxxxx-frameworks-Debug-input-files.xcfilelist'\n (in target 'xxxxx')\n \n :-1: Unable to load contents of file list: 'xxxxx/Pods/Target Support\n Files/Pods-xxxxx/Pods-xxxxx-frameworks-Debug-output-files.xcfilelist'\n (in target 'xxxxx')\n\n\nI updated all my pod and changed build system to \"Legacy Build System\" but still getting the same build error" ]
[ "ios", "xcode", "cocoapods", "xcode10.2" ]
[ "django reverse query", "Am trying to query from parent to child and with a single query being able to have the child results in parent. In my example, am trying to do a relation between i18n tables in which I want to include the row from the child table in a single hit. \n\nmodels.py\n\nclass main(models.Model):\n slug = models.SlugField()\n is_active = models.BooleanField(default=True)\n site = models.ForeignKey(Site)\n\n def __unicode__(self):\n return self.slug\n\nclass main_i18n(models.Model):\n main = models.ForeignKey(main)\n language = models.CharField(max_length=2, choices=LANGUAGES)\n title = models.CharField(max_length=50)\n class Meta:\n unique_together = ((\"language\", \"main\"))\n def __unicode__(self):\n return self.title\n\n\nI tried the following to query \n\na=main.objects.filter(is_active=True, main_i18n__language='en')\n\n\nand the relation its done perfectly, here is what I saw when tried to print the query\n\n>>> a.query.__str__()\n'SELECT `category_main`.`id`, `category_main`.`slug`, `category_main`.`is_active`, `category_main`.`site_id` FROM `category_main` INNER JOIN `category_main_i18n` ON (`category_main`.`id` = `category_main_i18n`.`main_id`) WHERE (`category_main_i18n`.`language` = en AND `category_main`.`is_active` = True )'\n\n\nAs you see from the query, it does the join correctly but the column names is not included in the select statement. I cannot access the main_i18n data when trying to do a for loop. \n\nsorry for my lousy english and hope i can find help,\n\nBest wishes,\n\n---- EDIT:\n\nbelow is the template am currently using, ultimately I would really like to create a single query and do regrouping based to list the data in my view.\n\n <table class=\"homepage-listing\">\n <tr>\n <td>\n{# {% regroup list by main as rg_main %}#}\n {% for obj in main %}\n{# {% if obj.grouper != None %}#}\n <div class=\"listing-block\">\n <a href=\"#\" ><h3>{{ obj }}</h3></a>\n <ul>\n {% for s in obj.list %}\n <li>{{ s.list_i18n_set.get }} </li>\n {% endfor %}\n </ul>\n </div>\n{# {% endif %}#}\n {% endfor %}\n </td>\n </tr>\n </table>\n\n\n--- EDIT:\n\nI had to use the extra functions to to build a single query for that purpose. I started with it but getting a bit complicated, am trying to make sure the columns not hardcoded in the queries and the joins are correct. Can anyone tell me if there is a better way to write the query?\n\n dict = Main.objects.extra(\n select=\n {\n 'main_title' : '%s.%s' % (MainI18n._meta.db_table, MainI18n._meta.get_field('title').verbose_name),\n 'list_title' : '%s.%s' % (ListI18n._meta.db_table, ListI18n._meta.get_field('title').verbose_name),\n },\n tables=[\n '%s' % (MainI18n._meta.db_table),\n '%s' % (List._meta.db_table),\n '%s' % (ListI18n._meta.db_table),\n ],\n where=[\n '%s.%s=%s.%s' % (MainI18n._meta.db_table, 'main_id', Main._meta.db_table, 'id'),\n '%s.main_id=%s.id' % (List._meta.db_table, Main._meta.db_table),\n '%s.list_id=%s.id' % (ListI18n._meta.db_table, List._meta.db_table),\n 'category_listi18n.language=\"%s\"' % (request.LANGUAGE_CODE)\n ]).select_related().filter(maini18n__language=request.LANGUAGE_CODE )" ]
[ "python", "django", "orm" ]
[ "When is the \"virtual\" attribute actually needed in a derived class?", "I'm trying to understand when/where exactly one should write the 'virtual' keyword in order for any descendant of a given class to enable polymorphic behavior, since I could not find specific informations about this question elsewhere.\n\nFor what I've tried, having virtual on a function in the base class automatically makes that function virtual for any descendants. However many snippets around the Internet often declare these functions again virtual in the descendants. \n\nstruct A {\n virtual void foo1() { std::cout << \"[A] foo1.\\n\"; }\n virtual void foo2() { std::cout << \"[A] foo2.\\n\"; }\n};\nstruct B : public A {\n virtual void foo1() { std::cout << \"[B] foo1.\\n\"; }\n void foo2() { std::cout << \"[B] foo2.\\n\"; }\n};\n\n\nCompiling this code with g++ I get that both foo1 and foo2 have polymorphic behavior. In addition, even if I derive again from B and create a C class, and I implement foo2 again without the virtual keyword, foo2 still uses the v-table. \n\nIs using the virtual keyword in derived classes only used for clarity and self-documentation, or is there some other effect that I'm not aware of?" ]
[ "c++", "virtual" ]
[ "C# Exiting a Console Application Without Exceptions", "I'm using a C# library that has a pretty bad shutdown procedure and whenever I exit the application using Environment.exit, it throws an exception and my whole console application freezes with a popup message (debug/close/etc). I am running my application as a scheduled task so I'd prefer not to have to manually hit the close button every time it runs and crashes on exit. I've tried putting some try catches around it, and handling all exceptions, but it doesnt seem to work.\n\nIs there a way to force an application exit and not allow any exceptions or anything that will cause it to crash?\n\nThanks\n-Jeff" ]
[ "c#" ]
[ "how can i publish HTML and plain-text template used by mail notifications in laravel?", "when I run this command :\n\nphp artisan vendor:publish --tag=laravel-notifications\n\n\nTo publishing the HTML and plain-text template used by mail notifications,this throws the following error :\n\n\n [UnexpectedValueException]\n Invalid route action: [App\\Http\\Controllers]\n\n\nWhy this is happening?" ]
[ "php", "laravel", "notifications", "laravel-artisan", "vendor" ]
[ "jquery.form.js image uploading isn't working in IE", "I'm using jquery.form.js to upload images and it's working in all browsers, except IE.\nversion: 3.32.0-2013.04.03\n\nI'm getting SCRIPT5: Access is denied.\njquery.form.js, line 531 character 21 \n\nI'm also using a custom upload button to submit the file which may be a part of the problem, but I'm not sure.\n\nI even tried changing to another plugin without success, but I'd really like to get this one to work as I'm using the plugin in other pages of the site.\n\nHTML: \n <input type=\"button\" id=\"uploadButton\" name=\"upload\" value=\"\" class=\"uploadButton\"/>\n <br><div id=\"uploadLimit\">Images cannot exceed 5mb.</div>\n <form id=\"uploadForm\" action=\"inc/ajax-ftlib.php\" method=\"post\" enctype=\"multipart/form-data\" style=\"position:absolute;left:-99999px;\">\n <input id=\"uploadFile\" type=\"file\" name=\"image\" />\n <input type=\"submit\" value=\"Submit\" id=\"submit-btn\" />\n <input type=\"hidden\" name=\"cmd\" value=\"uploadImage\">\n <input type=\"hidden\" name=\"postId\" value=\"0\">\n </form>\n\nJS:\n\n// hook up custom upload button\n $('#uploadButton').bind('click', function() {\n $('#uploadFile').trigger('click');\n });\n $('#uploadFile').bind('change', function() {\n $('#submit-btn').trigger('click');\n });\n\nvar options = {iframe: true, dataType: 'json', beforeSubmit: imageUploadRequest, success: imageUploadResponse, uploadProgress: imageUploadProgress, submit: imageUploadSubmit};\n $form = $('#uploadForm');\n $form.ajaxForm(options);\n\nfunction imageUploadResponse(response){\n var fileName = response;\n //alert(fileName);\n // add the image to the thumbnail ui here / remove any loader image\n var path = \"img/post/\" + postId + \"/\" + fileName;\n var $newdiv = $('<div class=\"item\" name=' + fileName + '><input type=\"button\" class=\"thumbClose\"/></div>');\n $newdiv.css('background-image', 'url(' + path + ')');\n $(\"#list\").append($newdiv);\n\n $('#uploadButton').show();\n $('#uploadLimit').show();\n}" ]
[ "jquery", "internet-explorer", "jquery-plugins", "file-upload" ]