text
stringlengths
74
309k
{"title":"Why are compilers so stupid?","tags":["performance","language-agnostic","compiler-construction"],"question_text":"I always wonder why compilers can't figure out simple things that are obvious to the human eye. They do lots of simple optimizations, but never something even a little bit complex. For example, th...
{"title":"How to check if an user is logged in Symfony2 inside a controller?","tags":["symfony2","login","symfony-security"],"question_text":"I read\nhere\nhow to check the login status of an user by inside a twig template for a Symfony2-based website.\nHowever, I need to know how to check if the user is logged in from...
{"title":"How to remove deprecated fields in Mongo?","tags":["mongodb"],"question_text":"I have removed some fields from document definition. I want to remove this field across all documents of collection. How can I do it?","answer_text":"Try:\n`db.collection.update(\n { '<field>': { '$exists': true } }, \/\/ Query\n {...
{"title":"Long Press in JavaScript?","tags":["javascript","javascript-events"],"question_text":"Is it possible to implement \"long press\" in JavaScript (or jQuery)? How?\nHTML\n`<a href=\"\" title=\"\">Long press<\/a>`\nJavaScript\n`$(\"a\").mouseup(function(){\n \/\/ Clear timeout\n return false;\n}).mousedown(functi...
{"title":"Illegal string offset Warning PHP","tags":["php","warnings"],"question_text":"I get a strange PHP error after updating my php version to 5.4.0-3.\nI have this array:\n`Array\n(\n [host] => 127.0.0.1\n [port] => 11211\n)`\nWhen I try to access it like this I get strange warnings\n`print $memcachedConfig['host'...
{"title":"Git blame showing no history","tags":["git","msysgit","blame"],"question_text":"When I run git blame on a file (using msysgit) I always get the following sort of printout:\n`00000000 (Not Committed Yet 2011-01-09 11:21:30 +0200 1) package co\n00000000 (Not Committed Yet 2011-01-09 11:21:30 +0200 2) {\n0000000...
{"title":"Make Font Awesome icons in a circle?","tags":["css","font-awesome"],"question_text":"I am using font awsome on some project but i have some things that i want to do with font awesome icons, i can easy call icon like this\n`<i class=\"fa fa-lock\"><\/i>`\nIs it possible to all icon always be in round circle wi...
{"title":"input type=\"text\" vs input type=\"search\" in HTML5","tags":["forms","html5","input"],"question_text":"I'm new to HTML5 as begun to work with HTML5's new form input fields. When I'm working with form input fields, especially\n`<input type=\"text\" \/>`\nand\n`<input type=\"search\" \/>`\nIMO there wasn't an...
{"title":"Strange String pool behavior","tags":["java","string"],"question_text":"I've got a question of some strange String pool behavior.\nI'm using\n`==`\nto compare equal Strings to find out whether they're in the pool or not.\n`public class StringPoolTest {\n public static void main(String[] args) {\n new StringPo...
{"title":"python exception message capturing","tags":["python","exception","logging","except"],"question_text":"`import ftplib\nimport urllib2\nimport os\nimport logging\nlogger = logging.getLogger('ftpuploader')\nhdlr = logging.FileHandler('ftplog.log')\nformatter = logging.Formatter('%(asctime)s %(levelname)s %(messa...
{"title":"Bat file to run a .exe at the command prompt","tags":["windows","batch-file","exe"],"question_text":"I want to create a .bat file so I can just click on it so it can run:\n`svcutil.exe \/language:cs \/out:generatedProxy.cs \/config:app.config http:\/\/localhost:8000\/ServiceModelSamples\/service`\nCan someone...
{"title":"Java read line from file","tags":["java","file","file-io"],"question_text":"My program must read text files - line by line.\nFiles in UTF-8.\nI am not sure that files are correct - can contain unprintable characters.\nIs possible check for it without going to byte level?\nThanks.","answer_text":"Open the file...
{"title":"How can I detect whether an iframe is loaded?","tags":["javascript","jquery","html","iframe"],"question_text":"I am trying to check whether an iframe has loaded after the user clicks a button.\nI have\n`$('#MainPopupIframe').load(function(){\n console.log('load the iframe')\n \/\/the console won't show anythi...
{"title":"How to make clang compile to llvm IR","tags":["c","llvm","clang"],"question_text":"I want clang to compile my\n`C\/C++`\ncode to\n`LLVM`\nbytecode rather than binary executable. How can I achieve that? And if I get the\n`LLVM`\nbytecode, how can I take it to further compile it to binary executable.\nBasically...
{"title":"What are the differences between various threading synchronization options in C#?","tags":["c#","multithreading","synchronization","locking","mutex"],"question_text":"Can someone explain the difference between:\nlock (someobject) {}\nUsing Mutex\nUsing Semaphore\nUsing Monitor\nUsing Other .Net synchronizatio...
{"title":"When should I use ugettext_lazy?","tags":["django","translation"],"question_text":"I have a question about using ugettext and ugettext_lazy for translations.\nI learned that in models I should use ugettext_lazy, while in views ugettext.\nBut are there any other places, where I should use ugettext_lazy too? Wh...
{"title":"Show div on scrollDown after 800px","tags":["jquery","html","css"],"question_text":"I want to show a hidden div when scrolling down after 800px from the top of the page. By now I have this example, but I guess it needs modification in order to achive what I am looking for.\nEDIT:\n[And when scrollUp and the h...
{"title":"Android Eclipse Plugin: Instrumentation Test Runner not specified","tags":["android","eclipse","unit-testing","junit"],"question_text":"I'm getting this error when trying to run unit tests from Eclipse with an Android Project. The list of Instrumentation Test Runners is empty in the Android preferences.\n[200...
{"title":"Jump into interface implementation in Eclipse IDE","tags":["eclipse","interface","polymorphism"],"question_text":"You know how in Eclipse, pressing\nF3\nover a method will take you to its declaration? Well I have a method that is part of an interface; clicking\nF3\nover this naturally takes me to the declarin...
{"title":"Can a dictionary be passed to django models on create?","tags":["python","django","django-models","dictionary"],"question_text":"Is is possible to do something similar to this with a list, dictionary or something else even?\n`data_dict = {\n 'title' : 'awesome title',\n 'body' : 'great body of text',\n}\nMode...
{"title":"How can I use PHP to dynamically publish an ical file to be read by Google Calendar?","tags":["php","calendar","icalendar"],"question_text":"Any Google search on PHP ical just brings up phpicalendar and how to parse or read IN ical files. I just want to write a PHP file that pulls events from my database and ...
{"title":"Reverse the ordering of words in a string","tags":["algorithm","data-structures","string"],"question_text":"I have this\n`string s1 = \"My name is X Y Z\"`\nand I want to reverse the order of the words so that\n`s1 = \"Z Y X is name My\"`\n.\nI can do it using an additional array. I thought hard but is it pos...
{"title":"Android: Cloning a drawable in order to make a StateListDrawable with filters","tags":["android","android-widget","drawable"],"question_text":"I'm trying to make a general framework function that makes any Drawable become highlighted when\npressed\/focused\/selected\/etc\n.\nMy function takes a Drawable and r...
{"title":"Android studio - Failed to find target android-18","tags":["java","android","gradle","android-studio"],"question_text":"I have a problem with Android Studio 0.2.3.\nWhen I run my project the build stops and appears message that says:\nGradle: Execution failed for task ':\nAppName\n:compileDebugAidl'.\n> faile...
{"title":"Using Joda Date & Time API to parse multiple formats","tags":["java","parsing","exception","jodatime"],"question_text":"I'm parsing third party log files containing date\/time using Joda. The date\/time is in one of two different formats, depending on the age of the log files I'm parsing.\nCurrently I have co...
{"title":"Find out time it took for a python script to complete execution","tags":["python"],"question_text":"I have the following code in a python script:\n`def fun()\n #Code here\nfun()`\nI want to execute this script and also find out how much time it took to execute in minutes. How to find out how much time it took...
{"title":"convert php date to mysql format","tags":["php","mysql"],"question_text":"I have a date field in php which is using this code:\n`$date = mysql_real_escape_string($_POST['intake_date']);`\nHow do I convert this to MySql format 0000-00-00 for inclusion in db. Is it along the lines of: date('Y-m-d' strtotime($da...
{"title":"What different breakpoint icons mean in Eclipse?","tags":["eclipse","debugging","breakpoints"],"question_text":"When working with breakpoints in Eclipse I sometimes notice that they have different icons \/ annotations (markers on left sidebar). Sometimes it's just a blue ball, sometimes it has a checkmark on ...
{"title":"Difference between shared objects (.so), static libraries (.a), and DLL's (.so)?","tags":["c++","c","linux","dll","linker"],"question_text":"I have been involved in some debate with respect to libraries in Linux, and would like to confirm some things.\nIt is to my understanding (please correct me if I am wron...
{"title":"Could not load file or assembly 'System.Net.Http.Formatting' or one of its dependencies. The system cannot find the path specified","tags":["c#","asp.net",".net","asp.net-mvc-4"],"question_text":"Please help anyone...\nI have a small MVC app that I use for practice reasons... But now I've encountered an error...
{"title":"Static constructor equivalent in Objective-C?","tags":["objective-c","static","initialization","initializer"],"question_text":"I'm new to Objective C and I haven't been able to find out if there is the equivalent of a static constructor in the language, that is a static method in a class that will automatical...
{"title":"Rails Migrations: Check Existence and Keep Going?","tags":["ruby-on-rails","migration"],"question_text":"I was doing this kind of thing in my migrations:\n`add_column :statuses, :hold_reason, :string rescue puts \"column already added\"`\nbut it turns out that,\nwhile this works for SQLite, it does not work f...
{"title":"Remove outline from select box in FF","tags":["html","css","firefox","xhtml"],"question_text":"Is it possible to remove the dotted line surrounding a selected item in a select element?\nI have tried to add the\n`outline`\nproperty in CSS but it did not work, at least not in FF.\n`<style>\n select { outline:no...
{"title":"Ignore empty result for xargs","tags":["bash","centos","xargs"],"question_text":"Consider this command:\n`ls \/mydir\/*.txt | xargs chown root`\nThe intention is to change owners of all text files in\n`mydir`\nto root\nThe issue is that if there are no\n`.txt`\nfiles in\n`mydir`\nthen xargs thows an error say...
{"title":"TextView onClick() not working","tags":["android","android-layout","onclick","android-textview"],"question_text":"here's my code for main.xml\n`<merge xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\">\n <RelativeLayout \n android:id=\"@id\/container\" \n android:layout_width=\"fill_parent\" \...
{"title":"How to spawn a process and capture its STDOUT in .NET?","tags":["c#",".net","process","spawning"],"question_text":"I need to spawn a child process that is a console application, and capture its output.\nI wrote up the following code for a method:\n`string retMessage = String.Empty;\nProcessStartInfo startInfo...
{"title":"jQuery if statement to check visibility","tags":["jquery","if-statement","hide","show","visible"],"question_text":"I'm trying to write a script that will hidden\/show div depending on other elements visibility. The action should take place when i click on other element. Here's what I've wrote so far:\n`$('#co...
{"title":"Why should I implement ICloneable in c#?","tags":["c#",".net","cloneable","icloneable"],"question_text":"Can you explain to me why I should inherit from\n`ICloneable`\nand implement the\n`Clone()`\nmethod?\nIf I want to do a deep copy, can't I just implement my method? Let's say\n`MyClone()`\n?\nWhy should I ...
{"title":"How do you run JavaScript script through the Terminal?","tags":["javascript","terminal"],"question_text":"For instance, if you were to run a Python script you would type\npython filename.py\nor if you wanted to run a C program\nmake filename\nthen\n.\/ filename\n. How do you do this with\n.js\nfiles?","answer...
{"title":"zsh compinit: insecure directories","tags":["zsh","zsh-completion"],"question_text":"What does it mean and how can I fix it ?\n`zsh compinit: insecure directories, run compaudit for list.\nIgnore insecure directories and continue [y] or abort compinit [n]?`\nRunning the\n`compaudit`\nreturns the follows:\n`Th...
{"title":"Advantages of using display:inline-block vs float:left in CSS","tags":["css","css3","css-float","html"],"question_text":"Normally, when we want to have multiple\n`DIVs`\nin a row we would use\n`float: left`\n, but now I discovered the trick of\n`display:inline-block`\nExample link\nhere\n.\nIt seems to me tha...
{"title":"Laravel Request::all() should not be called statically","tags":["php","laravel","laravel-5"],"question_text":"In Laravel, I'm trying to call\n`$input = Request::all();`\non a\n`store()`\nmethod in my controller, but I'm getting the following error:\nNon-static method\n`Illuminate\\Http\\Request::all()`\nshoul...
{"title":"Animate text change in UILabel","tags":["ipad","uilabel","caanimation"],"question_text":"I'm setting a new text value to a\n`uilabel`\n. Currently, the new text appears just fine. However, I'd like to add some animation when the new text appears. I'm wondering what I can do to animate the appearance of the ne...
{"title":"Sorting an array of objects in Ruby by object attribute?","tags":["ruby","sorting","object"],"question_text":"I have an array of objects in Ruby on Rails. I want to sort the array by an attribute of the object. Is it possible?","answer_text":"I recommend using sort_by instead:\n`objects.sort_by {|obj| obj.att...
{"title":"CSS: create white glow around image","tags":["css","image","css3","border","glow"],"question_text":"How can I create a white glow as the border of an unknown size image?","answer_text":"Use simple CSS3 (not supported in IE<9)\n`img\n{\n box-shadow: 0px 0px 5px #fff;\n}`\nThis will put a white glow around ever...
{"title":"what is the difference between json and xml","tags":["xml","json","comparison"],"question_text":"what is the difference between json and xml","answer_text":"The fundamental difference, which no other answer seems to have mentioned, is that XML is a markup language (as it actually says in its name), whereas JS...
{"title":"What is a C++ delegate?","tags":["c++","delegates","delegation"],"question_text":"What is the general idea of a delegate in C++? What are they, how are they used and what are they used for?\nI'd like to first learn about them in a 'black box' way, but a bit of information on the guts of these things would be ...
{"title":"Symfony2 and Doctrine - Error: Invalid PathExpression. Must be a StateFieldPathExpression","tags":["symfony2","doctrine2","dql"],"question_text":"I have an entity that looks like this:\n`\/**\n * @Gedmo\\Tree(type=\"nested\")\n * @ORM\\Table(name=\"categories\")\n * @ORM\\Entity()\n *\/\nclass Category extend...
{"title":"C++ array initialization","tags":["c++","syntax"],"question_text":"is this form of intializing an array to all 0s\n`char myarray[ARRAY_SIZE] = {0}`\nsupported by all compilers? ,\nif so, is there similar syntax to other types? for example\n`bool myBoolArray[ARRAY_SIZE] = {false}`","answer_text":"Yes, this for...
{"title":"Immutable vs Unmodifiable collection","tags":["java","collections","documentation"],"question_text":"From the\nCollections Framework Overview\n:\nCollections that do not support modification operations (such as\n`add`\n,\n`remove`\nand\n`clear`\n) are referred to as\nunmodifiable\n. Collections that are not u...
{"title":"MySQL errorno 121","tags":["mysql","foreign-keys","mysql-error-1005"],"question_text":"I'm getting this error in MySQL create. I'm doing:\n`CREATE TABLE `blogReply` (\n `Id` INT(24) NOT NULL AUTO_INCREMENT COMMENT 'Primary Key of This Table',\n `blogId` INT(24) NOT NULL COMMENT 'Blog where this reply was post...
{"title":"Remove ':hover' CSS behavior from element","tags":["html","css"],"question_text":"I have CSS that changes formatting when you hover over an element.\nHTML:\n`<div class=\"test\"> blah <\/div>`\nCSS:\n`.test:hover { border: 1px solid red; }`\nIn some cases I don't want to apply CSS on hover. One way would be t...
{"title":"How to provide animation when calling another activity in Android?","tags":["android","animation","android-activity"],"question_text":"I have two Activities A and B. I want to have the shrink Animation when \nActivity A calls B and maximize animation when Activity B calls A. I don't need the animation xml fil...
{"title":"What is the difference between partitioning and bucketing a table in Hive ?","tags":["hadoop","hive"],"question_text":"I know both is performed on a column in the table but how is each operation different.","answer_text":"Partitioning\ndata is often used for distributing load horizontally, this has performanc...
{"title":"Beautify NSLog of NSArray & NSDictionary","tags":["ios","nsarray","nsdictionary"],"question_text":"I'm dealing with deeply nested NSArray's and NSDictionary's and it's very time consuming to say the least. [data objectatindex:0] valueForKey:@\"blah\"] etc etc\nDoes anyone know of a nice iOS category to recurs...
{"title":"How to increase storage for Android Emulator? (INSTALL_FAILED_INSUFFICIENT_STORAGE)","tags":["android","android-emulator","emulator","avd"],"question_text":"I get this sometimes(not often) for one of my projects, couple of classes only\n`Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE`\nHow do I incre...
{"title":"Remove empty lines in text using Visual Studio","tags":["regex","visual-studio-2010","visual-studio","lines"],"question_text":"How to Remove empty lines in Visual Studio?","answer_text":"Since Visual Studio 2012 changed its regex syntax, the original answers by Ala translate into the following in VS 2012:\nRe...
{"title":"Strange Java behaviour with static and final qualifiers","tags":["java","order","final"],"question_text":"In our team we found some strange behaviour where we used both\n`static`\nand\n`final`\nqualifiers. This is our test class:\n`public class Test {\n public static final Test me = new Test();\n public stati...
{"title":"How to remove elements\/nodes from angular.js array","tags":["angularjs","scope","angularjs-ng-repeat"],"question_text":"I am trying to remove elements from the array\n`$scope.items`\nso that items are removed in the view\n`ng-repeat=\"item in items\"`\nJust for demonstrative purposes here is some code:\n`for...
{"title":"Conditional XOR?","tags":["c#","operators","xor","boolean-operations"],"question_text":"How come C# doesn't have a conditional\n`XOR`\noperator?\nExample:\n`true xor false = true\ntrue xor true = false\nfalse xor false = false`","answer_text":"Question is a bit outdated but...\nIt's how this operator should w...
{"title":"PHP - How to remove all specific characters at the end of a string?","tags":["php","regex","string"],"question_text":"How to remove the last character only if it's a period?\n`$string = \"something here.\";\n$output = 'something here';`","answer_text":"`$output = rtrim($string, '.');`\n(Reference:\nrtrim on P...
{"title":"Using Directives Sorted in Wrong Order","tags":["c#","visual-studio-2012","powercommands"],"question_text":"I'm using the Power Commands extension with Visual Studio 2012. I have the option checked to remove and sort usings on save. The problem is that the System.Xxx directives are being sorted last, and that...
{"title":"add image to uitableview cell","tags":["ios","uitableview","uikit","uiimage"],"question_text":"I have a\n`tableview`\n, how can I add image to the left of this cells?","answer_text":"`cell.imageView.image = [UIImage imageNamed:@\"image.png\"];`\nUPDATE:\nLike Steven Fisher said, this should only work for cell...
{"title":"How to make JRuby 1.6 default to Ruby 1.9?","tags":["jruby"],"question_text":"what is the best way to make JRuby to run in 1.9 mode by default?\ni.e, I want to run\n`rake test`\ninstead of\n`jruby --1.9 -S rake test`\nThank you","answer_text":"Use the\n`JRUBY_OPTS`\nenvironment variable.\n`JRUBY_OPTS`\nholds ...
{"title":"A more useful statusline in vim?","tags":["vim"],"question_text":"I\u00e2\u0080\u0099d like to make my statusline in vim more informative and interesting, and for that I need some ideas. How did you customize your statusline?","answer_text":"Edit:-\nNote\nvim-airline\nis gaining\n some traction as the new vim...
{"title":"Changing the current working directory in Java?","tags":["java","working-directory"],"question_text":"How can I change the current working directory from within a Java program? Everything I've been able to find about the issue claims that you simply can't do it, but I can't believe that that's really the case...
{"title":"CGRectMake , CGPointMake, CGSizeMake, CGRectZero, CGPointZero is unavailable in Swift","tags":["uikit","swift3","xcode8","ios10"],"question_text":"After converting code to latest swift 3.0 i am shown this error kindly help me with this.\nThanks\nAlso tell me solution for\n`CGSize = CGSizeMake(0,0)`\n`static v...
{"title":"Mythical man month 10 lines per developer day - how close on large projects?","tags":["productivity","metrics"],"question_text":"Everybody always says that they can beat the \"10 lines per developer per day\" from the \"Mythical Man Month\", and starting a project, I can usually get a couple hundred lines in ...
{"title":"How to cancel a Task in await?","tags":["c#","task-parallel-library",".net-4.5"],"question_text":"I'm playing with these Windows 8 WinRT tasks, and I'm trying to cancel a task using the method below, and it works to some point. The CancelNotification method DOES get called, which makes you think the task was ...
{"title":"How do I get the last inserted ID of a MySQL table in PHP?","tags":["php","mysql"],"question_text":"I have a table into which new data is frequently inserted. I need to get the very last ID of the table. How can I do this?\nIs it similar to\n`SELECT MAX(id) FROM table`\n?","answer_text":"If you're using PDO, ...
{"title":"Linq select objects in list where exists IN (A,B,C)","tags":["c#","linq","list","linq-to-objects","exists"],"question_text":"I have a list of\n`orders`\n.\nI want to select\n`orders`\nbased on a set of order statuses.\nSo essentially\n`select orders where order.StatusCode in (\"A\", \"B\", \"C\")`\n`\/\/ Filt...
{"title":"BigDecimal setScale and round","tags":["java","bigdecimal"],"question_text":"What is the difference between this two call? (Is there any?)\n`\/\/ 1.\nnew BigDecimal(\"3.53456\").round(new MathContext(4, RoundingMode.HALF_UP));\n\/\/ 2.\nnew BigDecimal(\"3.53456\").setScale(4, RoundingMode.HALF_UP);`","answer_...
{"title":"Inheritance and Overriding __init__ in python","tags":["python","override","superclass"],"question_text":"I was reading 'Dive Into Python' and in the chapter on classes it gives this example:\n`class FileInfo(UserDict):\n \"store file metadata\"\n def __init__(self, filename=None):\n UserDict.__init__(self)\n...
{"title":"How does Hadoop process records split across block boundaries?","tags":["hadoop","split","mapreduce","block","hdfs"],"question_text":"According to the\n`Hadoop - The Definitive Guide`\nThe logical records that FileInputFormats define do not usually fit neatly into HDFS blocks. For example, a TextInputFormat\u...
{"title":"HTTP header line break style","tags":["http","line-breaks"],"question_text":"Which line break style is more preferable for use in HTTP headers: '\\r\\n' or '\\n', and why?","answer_text":"`\\r\\n`\n, because it's defined as the line break in the protocol specification.\nRFC2616 states at the beginning of Sect...
{"title":"HTML Code for text checkbox '\u00ef\u0083\u00be'","tags":["html"],"question_text":"Is there an HTML code for the text checkbox '\u00ef\u0083\u00be'?\nEDIT: So to be clear, I need the HTML Number for the symbol \u00ef\u0083\u00be, not the form element checkbox.","answer_text":"U+F0FE\n`\u00ef\u0083\u00be`\nis ...
{"title":"Why is the use of tuples in C++ not more common?","tags":["c++","tuples"],"question_text":"Why does nobody seem to use tuples in C++, either the\nBoost Tuple Library\nor the standard library for TR1? I have read a lot of C++ code, and very rarely do I see the use of tuples, but I often see lots of places wher...
{"title":"How to dynamically add a style for text-align using jQuery","tags":["jquery","css","text-align"],"question_text":"I'm trying to correct the usual IE bugs around CSS 2.1 and need a way to alter an elements style properties to add a custom text-align style.\nCurrently in jQuery you can do something like\n`$(thi...
{"title":"Change page on UIScrollView","tags":["iphone","uiscrollview"],"question_text":"I have a UIScrollView with 10 pages. I am able to flick between them. I also want to have 2 buttons (a back button and a next button) which when touched will go to the previous or next page. I can't seem to figure out a way to do t...
{"title":"HtmlString vs. MvcHtmlString","tags":[".net-4.0","asp.net-mvc-3"],"question_text":"`HtmlString`\nvs.\n`MvcHtmlString`\nWhat are the differences bettween those two, or when to prefer one over the other?\nEdit:\nOne thing to prefer\n`MvcHtmlString`\nover\n`HtmlString`\nis the extension method\n`IsNullOrEmpty`\n...
{"title":"How can I programmatically get the MAC address of an iphone","tags":["iphone","objective-c","mac-address"],"question_text":"Does anyone know how to programmatically get an iPhone's MAC address and IP address?","answer_text":"NOTE\nAs of iOS7, you can no longer retrieve device MAC addresses. A fixed value will...
{"title":"Fastest way to swap elements in Python list","tags":["python","performance"],"question_text":"Is there any any faster way to swap two list elements in Python than\n`L[a], L[b] = L[b], L[a]`\nor would I have to resort to\nCython\nor\nWeave\nor the like?","answer_text":"Looks like the Python compiler optimizes ...
{"title":"How can I read the RGB value of a given pixel in Python?","tags":["python","graphics","rgb"],"question_text":"If I open an image with\n`open(\"image.jpg\")`\n, how can I get the RGB values of a pixel, if I have the coordinates of the pixel?\nThen how can I do the reverse of this? Starting with a blank graphic...
{"title":"The ultimate clean\/secure function","tags":["php","security","xss","sql-injection"],"question_text":"I have a lot of user inputs from\n`$_GET`\nand\n`$_POST`\n... At the moment I always write\n`mysql_real_escape_string($_GET['var'])`\n..\nI would like to know whether you could make a function that secures, e...
{"title":"Assert an object is a specific type","tags":["java","unit-testing","junit"],"question_text":"Is it possible in JUnit to assert an object is an instance of a class? For various reasons I have an object in my test that I want to check the type of. Is it a type of Object1 or a type of Object2?\nCurrently I have:...
{"title":"How to set up a cron job to run an executable every hour?","tags":["c","linux","gcc","cron","crontab"],"question_text":"I need to set up a cron job that runs an executable compiled using gcc once every hour.\nI logged in as root and typed\n`crontab -e`\nThen I entered the following and saved the file.\n`0 * *...
{"title":"Use Font Awesome Icon As Favicon","tags":["favicon","font-awesome"],"question_text":"Is it possible to use a\nFont Awesome\nicon as a favicon icon? You know, the little icon that appears along-side a website title in the browser tab?","answer_text":"I've created an online Font Awesome Favicon Generator to do ...
{"title":"bool to int conversion","tags":["c++","c","c99"],"question_text":"How portable is this conversion. Can I be sure that both assertions pass?\n`int x = 4<5;\nassert(x==1);\nx = 4>5;\nassert(x==0);`\nDon't ask why. I know that it is ugly. Thank you.","answer_text":"`int x = 4<5;`\nCompletely portable. Standard c...
{"title":"Chrome blocking javascript on localhost","tags":["javascript","google-chrome","blocking"],"question_text":"I'm working on developing a site on my local machine (Windows 7 Ultimate x64) using WAMP, running APACHE v2.2.22, PHP 5.3.13, and MySQL v5.5.24. I'm developing using Chrome v 22.0.1229.94. I've got quite...
{"title":"knockout.js and listen to check event on checkbox","tags":["checkbox","knockout.js"],"question_text":"I'm trying to get a function to execute when a checkbox is checked or unchecked to verify all checkboxes are unchecked but it never gets executed. I assume I'm not doing it correctly.\n`@Html.CheckBox(\"Subsc...
{"title":"Reset CSS display property to default value","tags":["css","default"],"question_text":"Is it possible to override the display property with its default value? For example if I have set it to none in one style, and I want to override it in a different with its default.\nOr is the only way to find out what the ...
{"title":"How to copy text from Emacs to another application on Linux","tags":["emacs","copy-paste"],"question_text":"When I yank text in Emacs 22.1.1 (in its own window on X, in KDE, on Kubuntu), I can't paste it anywhere else.","answer_text":"Let's be careful with our definitions here\nAn\nEmacs copy\nis the command\...
{"title":"How can I make PHP display the error instead of giving me 500 Internal Server Error","tags":["apache","php"],"question_text":"This has never happened before. Usually it displays the error, but now it just gives me a 500 internal server error. Of course before, when it displayed the error, it was different ser...
{"title":"How to get a single NSString character from an NSString","tags":["objective-c","cocoa-touch","nsstring"],"question_text":"I want to get a character from somewhere inside an NSString. I want the result to be an NSString.\nThis is the code I use to get a single character at index it:\n`[[s substringToIndex:i] s...
{"title":"Use find command but exclude files in two directories","tags":["linux","shell","unix","find"],"question_text":"I want to find files that end with\n`_peaks.bed`\n, but exclude files in the\n`tmp`\nand\n`scripts`\nfolders.\nMy command is like this:\n`find . -type f \\( -name \"*_peaks.bed\" ! -name \"*tmp*\" ! ...
{"title":"Asp.Net Absolute Path of a URL","tags":["c#","asp.net","absolute-path"],"question_text":"To make it simpler for a webapp to share files with another app on a different server, I'm using a base href tag in my master page. As many people have discovered, this breaks webform paths. I have a working Form Adaptor ...
{"title":"What is the difference between ports 465 and 587?","tags":["email","smtp","port","postfix-mta","email-client"],"question_text":"These ports\n465\nand\n587\nare both used for sending mail (submitting mail) but what is the real difference between them?","answer_text":"SMTP protocol: smtps (port 465) v. msa (por...
{"title":"Why are C# interface methods not declared abstract or virtual?","tags":["c#","methods","interface","abstract","virtual-functions"],"question_text":"C# methods in interfaces are declared without using the\n`virtual`\nkeyword, and overridden in the derived class without using the\n`override`\nkeyword.\nIs there...
{"title":"Adding Only Untracked Files","tags":["git","git-add"],"question_text":"One of the commands I find incredibly useful in Git is\n`git add -u`\nto throw everything but untracked files into the index. Is there an inverse of that? In the last few months, I've often found myself in a position where I've interactive...
{"title":"Parsing JSON from XmlHttpRequest.responseJSON","tags":["javascript","json","firefox-addon","bit.ly"],"question_text":"I'm trying to parse a bit.ly JSON response in javscript.\nI get the JSON via XmlHttpRequest.\n`var req = new XMLHttpRequest; \nreq.overrideMimeType(\"application\/json\"); \nreq.open('GET', BI...