text
stringlengths
74
309k
{"title":"Draw horizontal divider in winforms","tags":[".net","winforms"],"question_text":"In the standard windows installer there is a divider between the control buttons on the bottom and the main part of the form. Does anyone know how this would be done in winforms\/.net? I've tried fiddling around with the border s...
{"title":"How do I delete all untracked files from my working directory in Mercurial?","tags":["mercurial"],"question_text":"Is it possible to delete all untracked files from my working directory? Let's say I added a bunch of files to my working directory, didn't add them via\n`hg add`\n, and now want to get rid of tho...
{"title":"What are inline namespaces for?","tags":["c++","namespaces","c++11","inline-namespaces"],"question_text":"C++11 allows\n`inline namespace`\ns, all members of which are also automatically in the enclosing\n`namespace`\n. I cannot think of any useful application of this -- can somebody please give a brief, succ...
{"title":"What does this gdb output mean?","tags":["objective-c","ios","audio","playback"],"question_text":"I've got a button that plays a sound, and it seems to work perfectly fine on the simulator, but i'm getting this message:\nError loading \/System\/Library\/Extensions\/AudioIPCDriver.kext\/Contents\/Resources\/Au...
{"title":"how to implement login auth in node.js","tags":["authentication","node.js","login"],"question_text":"I have this node server running :\n`var server=http.createServer(function(request, responsehttp) {\n if (request.method == 'POST') {\n var body = '';\n request.on('data', function (data) {\n body += data;\n })...
{"title":"How do I convert a decimal to an int in C#?","tags":["c#",".net","int","decimal"],"question_text":"How do I convert a decimal to an int?","answer_text":"Use\n`Convert.ToInt32`\nfrom\n`mscorlib`\nas in\n`decimal value = 3.14m;\nint n = Convert.ToInt32(value);`\nSee\nMSDN\n. You can also use\n`Decimal.ToInt32`\...
{"title":"How do I override __getattr__ in Python without breaking the default behavior?","tags":["python"],"question_text":"I want to override the\n`__getattr__`\nmethod on a class to do something fancy but I don't want to break the default behavior.\nWhat's the correct way to do this?","answer_text":"Overriding\n`__g...
{"title":"How Python web frameworks, WSGI and CGI fit together","tags":["python","apache","cgi","wsgi"],"question_text":"I have a\nBluehost\naccount where I can run Python scripts as CGI. I guess it's the simplest CGI, because to run I have to define the following in\n`.htaccess`\n:\n`Options +ExecCGI\nAddType text\/ht...
{"title":"Which @NotNull Java annotation should I use?","tags":["java","nullpointerexception",null,"annotations","ide"],"question_text":"I'm looking to make my code more readable as well as use tooling like IDE code inspection and\/or static code analysis (FindBugs and Sonar) to avoid NullPointerExceptions. Many of the...
{"title":"PHP function to generate v4 UUID","tags":["php","function","uuid"],"question_text":"So I've been doing some digging around and I've been trying to piece together a function that generates a valid v4 UUID in PHP. This is the closest I've been able to come. My knowledge in hex, decimal, binary, PHP's bitwise op...
{"title":"Why does python use 'else' after for and while loops?","tags":["python","if-statement","for-loop","for-else"],"question_text":"I understand how this construct works:\n`for i in range(10):\n print(i)\n if i == 9:\n print(\"Too big - I'm giving up!\")\n break;\nelse:\n print(\"Completed successfully\")`\nBut I ...
{"title":"Eclipse JUNO doesn't start","tags":["android","eclipse","eclipse-plugin","crash-reports","eclipse-juno"],"question_text":"When I launch Eclipse, it does not start.\nAn error appears and tells me to see the log file.\n\"See the log file: \/Users\/max\/work\/projects\/.metadata\/.log\"\nOS: MacOS 10.7.4\nEclips...
{"title":"Serialize an object to XML","tags":["c#","xml-serialization"],"question_text":"I have a C# class that I have inherited. I have successfully \"built\" the object. But I need to serialize the object to XML. Is there an easy way to do it?\nIt looks like the class has been set up for serialization, but I'm not su...
{"title":"USB devices are not recognized in Virtualbox (Linux host)","tags":["usb","virtual-machine","virtualbox"],"question_text":"I tried to use USB devices without any success. It seems they are not detected by Virtualbox itself, since if I select the guest from the Virtualbox home (I'm using a Windows XP 3 guest), ...
{"title":"Match whitespace but not newlines","tags":["regex","perl"],"question_text":"I sometimes want to match whitespace but not newline.\nSo far I've been resorting to\n`[ \\t]`\n. Is there a less awkward way?","answer_text":"Use a double-negative:\n`\/[^\\S\\n]\/`\nTo avoid platform differences\nwarned about in per...
{"title":"ListView setOnItemClickListener not working by adding button","tags":["android","listview"],"question_text":"I have a list view with text and button in each row, list view setOnItemClickListener() is not working. is it possible to handle item click and button click events differently(item click should call Ac...
{"title":"Way to go from recursion to iteration","tags":["recursion","computer-science","theory","iteration"],"question_text":"I've used recursion quite a lot on my many years of programming to solve simple problems, but I'm fully aware that sometimes you need iteration due to memory\/speed problems.\nSo, sometime in t...
{"title":"sometimes my file just freezes in my vi |vim, what happened?","tags":["unix"],"question_text":"Sometimes when I edit my file using vi or vim, my file just freezes. Even if I type\nCtrl+C\nor\nCtrl+D\n, it still freezes there. I\n`kill -9 <pid>`\nfrom another terminal, the pid is killed, but the file still fre...
{"title":"How to get a DOM Element from a JQuery Selector","tags":["javascript","jquery","dom"],"question_text":"I'm having an impossibly hard time finding out to get the actual DOMElement from a jquery selector. Sample Code:\n`<input type=\"checkbox\" id=\"bob\" \/>\n var checkbox = $(\"#bob\").click(function() { \/\/...
{"title":"Objective-C pass block as parameter","tags":["objective-c","objective-c-blocks"],"question_text":"How can I pass a\n`Block`\nto a\n`Function`\n\/\n`Method`\n?\nI tried\n`- (void)someFunc:(__Block)someBlock`\nwith no avail.\nie. What is the type for a\n`Block`\n?","answer_text":"The type of a block varies depe...
{"title":"How do I simply create a patch from my latest git commit?","tags":["git","patch"],"question_text":"I'm looking for the magic command of creating a patch from the last commit made.\nMy workflow sometimes looks like this\n`vi some.txt\ngit add some.txt\ngit commit -m \"some change\"`\nand now I just want to wri...
{"title":"JavaScript Editor Plugin for Eclipse","tags":["javascript","eclipse","eclipse-plugin"],"question_text":"Is there an Eclipse plugin available for JavaScript that allows for syntax checking and autosuggestions for .js files in Eclipse?","answer_text":"Complete the following steps in Eclipse to get plugins for J...
{"title":"Why can't I make a vector of references?","tags":["c++","stl","vector"],"question_text":"When I do this:\n`std::vector<int> hello;`\nEverything works great. However, when I make it a vector of references instead:\n`std::vector<int &> hello;`\nI get horrible errors like \"error C2528: 'pointer' : pointer to re...
{"title":"Can I pass parameters by reference in Java?","tags":["c#","java","reference"],"question_text":"I'd like semantics similar to\n`C#`\n's\n`ref`\nkeyword.","answer_text":"Java is confusing because\neverything is passed by value\n. However for a parameter\nof reference type\n(i.e. not a parameter of primitive typ...
{"title":"C++ performance vs. Java\/C#","tags":["c#","java","c++","performance","bytecode"],"question_text":"My understanding is that C\/C++ produces native code to run on a particular machine architecture. Conversely, languages like Java and C# run on top of a virtual machine which abstracts away the native architectu...
{"title":"Find String index from last in Python","tags":["python","string"],"question_text":"I think it might be a silly question but as I'm totally new to Python, i don't know anything about it.\nI want to find the last position of a target string in given str as a input.\nFor ex.\n`str='hello'`\nand\n`target='l'`\nth...
{"title":"Is there a CSS selector by class prefix?","tags":["css","css-selectors"],"question_text":"I want to apply a CSS rule to any element whose one of the classes matches specified prefix.\nE.g. I want a rule that will apply to div that has class that starts with\n`status-`\n(A and C, but not B in following snippet...
{"title":"Fade in each element - one after another","tags":["jquery","ajax","load"],"question_text":"I am trying to find a way to load a JSON page to display my content, which I currently have. But I am trying to fade in each element one after another? Is anyone familiar with a way to do that?\nFade in each element wit...
{"title":"How to add a button to a PreferenceScreen (Android)","tags":["android","button","preferences"],"question_text":"I'm quite new to Android Development and just came across Preferences.\nI found PreferenceScreens and wanted to create a login functionality with it. The only problem I have it that I don't know hot...
{"title":"List vs Set vs Bag in NHibernate","tags":["nhibernate"],"question_text":"What's the difference between a list, set and bag in the NHibernate mapping file? How does each relate to .NET collections?","answer_text":"NHibernate semantics:\nList: Ordered collection of entities, duplicate allowed. Use a .NET\n`ILis...
{"title":"Lock screen orientation (Android)","tags":["android","orientation"],"question_text":"Possible Duplicate:\nHow to disable orientation change in Android?\nI'm writing an android application that uses tabs with different contents (activities).\nIn one of these activities, I would like to lock the screen orientat...
{"title":"HTML5 placeholder css padding","tags":["css","html5","google-chrome","webkit","css3"],"question_text":"I've seen this\npost\nalready and tried everything I could to change the padding for my placeholder but alas, it seems it just doesn't want to cooperate.\nAnyway, here is the code for the css. (\nEDIT\n: Thi...
{"title":"MySQL and GROUP_CONCAT() maximum length","tags":["mysql","group-concat"],"question_text":"I'm using\n`GROUP_CONCAT()`\nin a MySQL query to convert multiple rows into a single string.\nHowever, the maximum length of the result of this function is\n`1024`\ncharacters.\nI'm very well aware that I can change the ...
{"title":"How can I determine whether a Java class is abstract by reflection","tags":["java","class","abstract"],"question_text":"I am interating through classes in a Jar file and wish to find those which are not abstract. I can solve this by instantiating the classes and trapping InstantiationException but that has a ...
{"title":"UICollectionView spacing margins","tags":["ios","uicollectionview","uikit"],"question_text":"I have a\n`UICollectionView`\nwhich shows photos. I have created the collectionview using\n`UICollectionViewFlowLayout`\n. It works good but I would like to have spacing on margins. Is it possible to do that using\n`U...
{"title":"AngularJS For Loop with Numbers & Ranges","tags":["angularjs","angularjs-ng-repeat"],"question_text":"Angular does provide some support for a for loop using numbers within its HTML directives:\n`<div data-ng-repeat=\"i in [1,2,3,4,5]\">\n do something\n<\/div>`\nBut if your scope variable includes a range tha...
{"title":"Install an apk file from command prompt?","tags":["android","cmd","apk"],"question_text":"I want to install a file using the windows command line. First I want to build after compiling all the .jar files to create an .apk file for an android application without using Eclipse.\nDoes anyone know how this can be...
{"title":"How change List<T> data to IQueryable<T> data","tags":[".net","linq"],"question_text":"Possible Duplicate:\nIList<T> to IQueryable<T>\nI have a List data, but I want a IQueryable data , is it possible from List data to IQueryable data?\nShow me code","answer_text":"`var list = new List<string>();\nvar queryab...
{"title":"Autolayout: Add constraint to superview and not Top Layout Guide?","tags":["ios","storyboard","autolayout","nslayoutconstraint"],"question_text":"I have a UIView in my UIViewController in storyboard which I want to add a constraint on to space that view a distance from the top edge.\nNow, when I do the usual ...
{"title":"Import regular css file in scss file?","tags":["sass"],"question_text":"Is there anyway to import a regular css file with sass's\n`@import`\ncommand? While I'm not using all of the SCSS syntax from sass, I do still enjoy it's combining\/compressing features, and would like to be able to use it without renamin...
{"title":"Reading binary file in Python and looping over each byte","tags":["python","file-io","binary"],"question_text":"In Python, how do I read in a binary file and loop over each byte of that file?","answer_text":"`f = open(\"myfile\", \"rb\")\ntry:\n byte = f.read(1)\n while byte != \"\":\n # Do stuff with byte.\n...
{"title":"Type-juggling and (strict) greater\/lesser-than comparisons in PHP","tags":["php","if-statement","comparison","logic","ieee-754"],"question_text":"PHP is famous for its type-juggling. I must admit it puzzles me, and I'm having a hard time to find out basic logical\/fundamental things in comparisons.\nFor exam...
{"title":"Using custom fonts using CSS?","tags":["css","font-face"],"question_text":"I've seen some new websites that are using custom fonts on their sites (other than the regular Arial, Tahoma, etc.).\nAnd they support a nice amount of browsers.\nHow does one do that? While also preventing people from having free acce...
{"title":"Possible to access the index in a Hash each loop?","tags":["ruby","enumerable"],"question_text":"I'm probably missing something obvious, but is there a way to access the index\/count of the iteration inside a hash each loop?\n`hash = {'three' => 'one', 'four' => 'two', 'one' => 'three'}\nhash.each { |key, val...
{"title":"Produce a random number in a range using C#","tags":["c#",".net","random"],"question_text":"How do I go about producing random numbers within a range?","answer_text":"You can try\n`Random r = new Random();\nint rInt = r.Next(0, 100); \/\/for ints\nint range = 100;\ndouble rDouble = r.NextDouble()* range; \/\/...
{"title":"How can I play birthday music using R?","tags":["r","music"],"question_text":"I would like to play music using R. While R may not be the best tool for this purpose, it is the tool that I am familiar with and it would be nice to demonstrate to others its flexibility on such a joyous occasion.\nHow could I acco...
{"title":"How to search a string in multiple files and return the names of files in Powershell?","tags":["string","search","text","powershell","recursion"],"question_text":"I have started learning powershell a couple of days ago, and I couldn't find anything on google that does what I need so please bear with my questi...
{"title":"wget with authentication","tags":["linux","bash","shell","ubuntu","wget"],"question_text":"How can I download a webpage that require a username and password?\nFor example I want to download this page after I have entered username and password:\nhttp:\/\/forum.ubuntu-it.org\/index.php","answer_text":"Using the...
{"title":"How do I get the full url of the page I am on in C#","tags":["c#","asp.net","user-controls"],"question_text":"I need to be able to get at the full URL of the page I am on from a user control. Is it just a matter of concatenating a bunch of Request variables together? If so which ones? Or is there a more simpi...
{"title":"jQuery equivalent of getting the context of a Canvas","tags":["javascript","jquery","html","html5","canvas"],"question_text":"I have the following working code:\n`ctx = document.getElementById(\"canvas\").getContext('2d');`\nIs there any way to re-write it to use\n`$`\n? Doing this fails:\n`ctx = $(\"#canvas\...
{"title":"makefile:4: *** missing separator. Stop","tags":["c","makefile"],"question_text":"This is my makefile:\n`all:ll\nll:ll.c \n gcc -c -Wall -Werror -02 c.c ll.c -o ll $@ $<\nclean :\n \\rm -fr ll`\nWhen I try to\n`make clean`\nor\n`make make`\n, I get this error:\n`:makefile:4: *** missing separator. Stop.`\nHow...
{"title":"Android Webview - Webpage should fit the device screen","tags":["android","webview","scaling","android-webview"],"question_text":"I have tried the following to fit the webpage based on the device screen size.\n`mWebview.setInitialScale(30);`\nand then set the metadata viewport\n`<meta name=\"viewport\" conten...
{"title":"Java integer to byte array","tags":["java","arrays","integer","byte"],"question_text":"I got an integer:\n`1695609641`\nwhen I use method:\n`String hex = Integer.toHexString(1695609641);\nsystem.out.println(hex);`\ngives:\n`6510f329`\nbut I want a byte array:\n`byte[] bytearray = new byte[] { (byte) 0x65, (by...
{"title":"Maven: Command to update repository after adding dependency to POM","tags":["maven-2","maven-dependency"],"question_text":"I've added a new dependency to my POM.\nIs there a simple command I can run to download this dependency to my repository?","answer_text":"If you want to\nonly\ndownload dependencies witho...
{"title":"Detect the OS from a Bash script","tags":["bash","os-detection"],"question_text":"I would like to keep my\n`.bashrc`\nand\n`.bash_login`\nfiles in version control so that I can use them between all the computers I use. The problem is I have some OS specific aliases so I was looking for a way to determine if t...
{"title":"JavaScript Hashmap Equivalent","tags":["javascript","data-structures","language-features","hashmap"],"question_text":"As made clear in update 3 on\nthis answer\n, this notation:\n`var hash = {};\nhash[X]`\ndoes not actually hash the object\n`X`\n; it actually just converts\n`X`\nto a string (via\n`.toString()...
{"title":"What is the difference between Linq to XML Descendants and Elements","tags":["c#",".net","xml","linq-to-xml"],"question_text":"I have came across both these keywords in the VS IntelliSense. I tried to googling the difference between them and did not get a clear answer. Which one of these have the best perform...
{"title":"PHP multi dimensional array search","tags":["php"],"question_text":"I have an array where I want to search the\n`uid`\nand get the key of the multidimensional array.\nExamples\nAssume we have the following 2-dimensional array:\n`$userdb=Array\n(\n (0) => Array\n (\n (uid) => '100',\n (name) => 'Sandra Shush',...
{"title":"IntelliJ Organize Imports","tags":["java","intellij-idea"],"question_text":"Does IntelliJ have an Organize Imports feature similar to that in Eclipse?\nWhat I have is a Java file with multiple classes missing their imports. Example:\n`package com.test;\npublic class Foo {\n public Map map;\n public JTable tab...
{"title":"Undo a git stash","tags":["git"],"question_text":"I just did a stash in a project that I haven't commit. Is there a way to go back to the state before I stashed? How could I do this? I've closed the terminal and my laptop is shut down. I've done some researched and it seems there's no way to do this.","answer...
{"title":"IOS: verify if a point is inside a rect","tags":["ios","xcode","collision-detection","cgrect","cgpoint"],"question_text":"Is there a way to verify if a\n`CGPoint`\nis inside a specific\n`CGRect`\n.\nAt example: I'm dragging an\n`UIImageView`\nand I want to verify if its central point\n`CGPoint`\nis inside ano...
{"title":"Run Cron job every N minutes plus offset","tags":["cron"],"question_text":"`*\/20 * * * *`\nEnsures it runs every 20 minutes, I'd like to run a task every 20 minutes, starting at 5 past the hour, is this possible with Cron? Would it be:\n`5\/20 * * * *`\n?","answer_text":"To run a task every 20 minutes starti...
{"title":"INSERT ... ON DUPLICATE KEY (do nothing)","tags":["mysql","sql","unique-key"],"question_text":"I have a table with a unique key for two columns:\n`CREATE TABLE `xpo`.`user_permanent_gift` (\n`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,\n`fb_user_id` INT UNSIGNED NOT NULL ,\n`gift_id` INT UNSIGNED NOT NULL ,\n`...
{"title":"What are the reasons why Map.get(Object key) is not (fully) generic","tags":["java","generics","collections","map"],"question_text":"What are the reasons behind the decision to not have a fully generic get method \nin the interface of\n`java.util.Map<K, V>`\n.\nTo clarify the question, the signature of the me...
{"title":"Determine if ActiveRecord Object is New Or Created","tags":["ruby-on-rails","activerecord"],"question_text":"How can I introspect an\n`ActiveRecord`\nobject to determine whether it's new or already created?","answer_text":"An ActiveRecord object lifecycle:\n1.\nnew record\n`item = Item.new\nitem.new_record? #...
{"title":"mipmap drawables for icons","tags":["android","android-drawable","mipmaps"],"question_text":"Since Android 4.3 we can now make use of the\n`res\/mipmap`\nfolders to store \"mipmap\" images.\ne.g.\nChrome for Android\nstores its icons in these folders instead of the more normal\n`res\/drawable`\nfolders.\nHow ...
{"title":"php shell_exec() vs exec()","tags":["php","shell"],"question_text":"I'm struggling to understand the difference between\n`shell_exec()`\nand\n`exec()`\n...\nI've always used\n`exec()`\nto execute server side commands, when would I use\n`shell_exec()`\n?\nIs\n`shell_exec()`\njust a shorthand for\n`exec()`\n? I...
{"title":"Stop caching for PHP 5.5.3 in MAMP","tags":["php","caching","mamp","php-5.5"],"question_text":"Installed MAMP on a new Macbook with PHP 5.5.3.\nReload and refresh do nothing. Still nothing. Google around for a few minutes trying to find out what is wrong, come back and refresh. It works. What the heck?\nI wen...
{"title":"How to make Twitter bootstrap tooltips have multiple lines?","tags":["javascript","css","twitter-bootstrap"],"question_text":"I am currently using the below function to create text that will be displayed using bootstrap's tooltip plugin. How come multiline tooltips only works with\n`<br>`\nand not\n`\\n`\n? I...
{"title":"VS2013 permanent CPU usage even though in idle mode","tags":["visual-studio-2013","cpu-usage"],"question_text":"I've recently updated VS2013 to Update 1 and since then VS takes CPU usage to 25% (on a 4 cores intel i5 cpu) permanently even though it's supposed to be idle. I thought it has some unfinished backg...
{"title":"Can I install Python windows packages into virtualenvs?","tags":["python","windows","virtualenv"],"question_text":"Virtualenv is great: it lets me keep a number of distinct Python installations so that different projects' dependencies aren't all thrown together into a common pile.\nBut if I want to install a ...
{"title":"How to find out if a file exists in C# \/ .NET?","tags":["c#",".net","io"],"question_text":"I would like to test a string containing a path to a file for existence of that file (something like the\n`-e`\ntest in Perl or the\n`os.path.exists()`\nin Python) in C#.","answer_text":"Use:\n`File.Exists(path)`\nMSDN...
{"title":"How to revert Master branch to upstream","tags":["git","github"],"question_text":"I have forked a git repository and setup upstream. I've made some changes in Master branch and committed and pushed to github.\nNow what should I do to abandon all my changes in Master branch and make it identical to the upstrea...
{"title":"Ruby on Rails and Rake problems: uninitialized constant Rake::DSL","tags":["ruby-on-rails","rake"],"question_text":"I'm having a really frustrating issue:\nRake\nis being dumb.\nHere's how the problem comes about:\n`$ rails new test_app\n$ rails generate scaffold new_scaffold field1:string field2:text`\nBoth ...
{"title":"Different ways of loading a file as an InputStream","tags":["java","inputstream"],"question_text":"What's the difference between:\n`InputStream is = this.getClass().getClassLoader().getResourceAsStream(fileName)`\nand\n`InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileNa...
{"title":"WPF text Wrap vs WrapWithOverflow","tags":["wpf","textwrapping"],"question_text":"What's the \"conceptual\" difference between\n`TextWrapping=\"Wrap\"`\nand\n`TextWrapping=\"WrapWithOverflow\"`\n(e.g. for a TextBox)?\nIn the MSDN page about the class TextBox there is nothing ...\nThank you.","answer_text":"So...
{"title":"Paste text on Android Emulator","tags":["android","copy-paste"],"question_text":"Is there anyway to copy\/paste (desktop's) clipboard content to\n`EditView`\non Android Emulator?\n(just for the sake to ease development\/test)","answer_text":"In a terminal, type\n`adb shell input text 'my string here. With som...
{"title":"Referring to a table in LaTeX","tags":["table","latex","ref"],"question_text":"How can you refer to a table number such that you get\n`Table 7`\nfor instance?\nSample data\n`Table \\ref{table:questions} lorem lorem ipsun.\n\\begin{table}\n\\label{table:questions}\n\\begin{tabular}{| p{5cm} | p{5cm} | p{5cm} |...
{"title":"You have already activated rake 0.9.0, but your Gemfile requires rake 0.8.7","tags":["ruby-on-rails","rake"],"question_text":"I'm trying to run rails project,\nI get\n`Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.`\nIf I do: \"bundle install\"\nbut\nI'm getting\...
{"title":"Jump to editor shortcut in Intellij IDEA","tags":["intellij-idea","keyboard-shortcuts"],"question_text":"I can use\nF12\nto jump\nto project tree\n(if it was the last tool that I used), but is there a shortcut for jumping\nback to editor?","answer_text":"Esc\nalways brings the focus back to the editor.","ques...
{"title":"What exactly does big \u00d3\u00a8 notation represent?","tags":["algorithm","computer-science","big-o","notation","big-theta"],"question_text":"I'm really confused about the differences between big O, big Omega, and big Theta notation.\nI understand that big O is the upper bound and big Omega is the lower bou...
{"title":"Change Name of Import in Java, or import two classes with the same name","tags":["java","import"],"question_text":"In Python you can do a:\n`from a import b as c`\nHow would you do this in Java, as I have two imports that are clashing.","answer_text":"There is no import aliasing mechanism in Java. You cannot ...
{"title":"Are \"while(true)\" loops so bad?","tags":["java","while-loop","do-while"],"question_text":"I've been programming in Java for several years now, but I just recently returned to school to get a formal degree. I was quite surprised to learn that, on my last assignment, I lost points for using a loop like the on...
{"title":"Android - Round to 2 decimal places","tags":["android","double","decimal","rounding"],"question_text":"Possible Duplicate:\nRound a double to 2 significant figures after decimal point\nI know that there are plenty of examples on how to round this kind numbers.\nBut could someone show me how to round double, t...
{"title":"make arrayList.toArray() return more specific types","tags":["java","arrays","object","types","arraylist"],"question_text":"So, normally\n`ArrayList.toArray()`\nwould return a type of\n`Object[]`\n....but supposed it's an\n`Arraylist`\nof object\n`Custom`\n, how do I make\n`toArray()`\nto return a type of\n`C...
{"title":"How can I change the animation style of a modal UIViewController?","tags":["iphone","cocoa-touch"],"question_text":"I'm currently displaying a UIViewController like this:\n`[[self navigationController] presentModalViewController:modalViewController animated:YES];`\nand hiding it like this:\n`[self.navigationC...
{"title":"Can I call an overloaded constructor from another constructor of the same class in C#?","tags":["c#","constructor"],"question_text":"Can I call an overloaded constructor from another constructor of the same class in C#?","answer_text":"No, You can't do that, the only place you can call the constructor from an...
{"title":"Looking for a 'cmake clean' command to clear up cmake output","tags":["cmake"],"question_text":"Just as\n`make clean`\ndeletes all the files that a makefile has produced, I would like to do the same with CMake. All too often I find myself manually going through directories removing files like\n`cmake_install....
{"title":"Excel \"External table is not in the expected format.\"","tags":["c#","excel-2007","xlsx","import-from-excel"],"question_text":"I'm trying to read an Excel (xlsx) file using the code shown below. I get an \"External table is not in the expected format.\" error unless I have the file already open in Excel. In ...
{"title":"Is it possible to simplify (x == 0 || x == 1) into a single operation?","tags":["c#","algorithm","optimization","arithmetic-expressions"],"question_text":"So I was trying to write the\nn\nth number in the Fibonacci sequence in as compact a function as possible:\n`public uint fibn ( uint N ) \n{\n return (N ==...
{"title":"Resolving javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed Error?","tags":["java","ssl","https"],"question_text":"I am getting this error\ndetailed message sun.security.validator.ValidatorException: PKIX path\n building failed:\nsun.security.provider.ce...
{"title":"What is the difference between :focus and :active?","tags":["css","css-selectors","pseudo-class"],"question_text":"What is the difference between the\n`:focus`\nand\n`:active`\npseudo-classes?","answer_text":"`:focus`\nand\n`:active`\nare two different states.\n`:focus`\nrepresents the state when the element ...
{"title":"Removing duplicate objects with Underscore for Javascript","tags":["javascript","json","underscore.js"],"question_text":"I have this kind of array:\n`var foo = [ { \"a\" : \"1\" }, { \"b\" : \"2\" }, { \"a\" : \"1\" } ];`\nI'd like to filter it to have:\n`var bar = [ { \"a\" : \"1\" }, { \"b\" : \"2\" }];`\nI...
{"title":"Is it possible to clone html element objects in JavaScript \/ JQuery?","tags":["javascript","jquery","clone","elements"],"question_text":"I am looking for some tips on how to solve my problem.\nI have a html element (like select box input field) in a table. Now I want to copy the object and generate a new one...
{"title":"Convert base-2 binary number string to int","tags":["python"],"question_text":"I'd simply like to convert a base-2 binary number string into an int, something like this:\n`>>> '11111111'.fromBinaryToInt()\n255`\nIs there a way to do this in Python?","answer_text":"You use the built-in\n`[int()`\nfunction][1],...
{"title":"how to write setTimeout with params by Coffeescript","tags":["javascript","settimeout","coffeescript"],"question_text":"Please tell me how to write javascript below in coffeescript.\n`setTimeout(function(){\n something(param);\n}, 1000);`","answer_text":"I think it's a useful convention for callbacks to come ...
{"title":"Mysql - Alter a column to be AUTO_INCREMENT","tags":["sql","mysql","alter-table"],"question_text":"I'm trying to modify a table to make it's primary key column\n`AUTO_INCREMENT`\nafter the fact. I have tried the following sql, but got a syntax error:\n`ALTER TABLE document\nALTER COLUMN document_id AUTO_INCRE...
{"title":"Rails 3: Get Random Record","tags":["ruby-on-rails","ruby","ruby-on-rails-3","activerecord","random"],"question_text":"So, I've found several examples for finding a random record in Rails 2 -- the preferred method seems to be:\n`Thing.find :first, :offset => rand(Thing.count)`\nBeing something of a newbie I'm...
{"title":"command-line - what is the purpose of \"&&\"?","tags":["bash","command-line","posix"],"question_text":"As far as I know, using\n`&`\nafter the command is for running it in the background.\nExample of\n`&`\nusage:\n`tar -czf file.tar.gz dirname &`\nBut how about\n`&&`\n? (look at this example:\nhttp:\/\/server...
{"title":"How to install Python MySQLdb module using pip?","tags":["python","mysql","pip"],"question_text":"How can I install the\nMySQLdb\nmodule for Python using pip?","answer_text":"It's easy to do, but hard to remember the correct spelling:\n`pip install MySQL-python`\nNote: Some dependencies might have to be in pl...