text
stringlengths
74
309k
{"title":"Ruby on rails - Reference the same model twice?","tags":["ruby-on-rails","rails-activerecord","relationships"],"question_text":"Is it possible to set up a double relationship in\n`activerecord`\nmodels via the\n`generate scaffold`\ncommand?\nFor example, if I had a\n`User`\nmodel and a\n`PrivateMessage`\nmode...
{"title":"How can I find the location of a regex match in Perl?","tags":["regex","perl"],"question_text":"I need to write a function that receives a string and a regex. I need to check if there is a match and return the start and end location of a match. (The regex was already compiled by\n`qr\/\/`\n.)\nThe function mi...
{"title":"2.9999999999999999 >> .5?","tags":["javascript","bit-manipulation","precision"],"question_text":"I heard that you could right-shift a number by .5 instead of using Math.floor(). I decided to check its limits to make sure that it was a suitable replacement, so I checked the following values and got the followi...
{"title":"php.ini reload in php-cli","tags":["php","php-ini"],"question_text":"I have php script that must be runned from console (php-cli). But configuration of php.ini for php-cli was incorrect. I fix it, but when I run script a had error with php config, because php.ini uses an old.\nHow I can reload php.ini for con...
{"title":"Check whether an input string contains number","tags":["javascript","string","numbers","validation"],"question_text":"I want to check whether an input string contains number.\nI am trying to validate an input field. I want it to contain only alphabet, not numbers.","answer_text":"You can do this using javascr...
{"title":"How do you log the machine name via log4net?","tags":["c#",".net","logging","log4net"],"question_text":"I am using Log4Net with the AdoNetAppender to log messages from a simple systray application into a SQL Server 2005 database.\nI want to log the machine name along with the log message because this applicat...
{"title":"Java: for(;;) vs. while(true)","tags":["java","for-loop","while-loop"],"question_text":"What is the difference between a standard\n`while(true)`\nloop and\n`for(;;)`\n?\nIs there any, or will both be mapped to the same bytecode after compiling?","answer_text":"Semantically, they're completely equivalent. It's...
{"title":"Difference between class and type","tags":["java","class","types"],"question_text":"Being new to Java, I'm confused between the concepts of\nclass\nand\ntype\n.\nFor example, should the object\n`\"Hello World!\"`\nbelong to the\ntype\n`String`\nor\nclass\n`String`\n? Or maybe both?","answer_text":"A class is ...
{"title":"error in csproj - duplicate item","tags":["visual-studio-2010","msbuild","projects-and-solutions"],"question_text":"I have error from visual studio 2010:\nError 1 The item \"CrossDomainService.svc.cs\" was specified more than once in the \"Sources\" parameter. Duplicate items are not supported by the \"Source...
{"title":"How can I automatically render partials using markdown in Rails 3?","tags":["ruby-on-rails-3","markdown","partials"],"question_text":"I want to have some of my partials as markdown snippets. What is the easiest way to render them using the standard rails erb templating?\nIdeally, I'd like to do something like...
{"title":"How to convert .ICO to .PNG?","tags":["graphics"],"question_text":"What tool can I use to convert a .ICO file to a .PNG file?","answer_text":"Google has an ico to png converter, I saw it on\nreddit\nthe other day.\nhttp:\/\/www.google.com\/s2\/favicons?domain=stackoverflow.com","question_code":[],"answer_code...
{"title":"Generating a random hex color code with PHP","tags":["php","hex"],"question_text":"I'm working on a project where I need to generate an undefined number of random, hexadecimal color codes\u00e2\u0080\u00a6how would I go about building such a function in PHP?","answer_text":"Get a random number from 0 to 255, ...
{"title":"Android overlay a view ontop of everything?","tags":["android","layout","view"],"question_text":"Can you overlay a view on top of everything in android?\nIn iPhone I would get the new view set its\n`frame.origin`\nto (0,0) and its width and height to the width and height of\n`self.view`\n. Adding it to\n`self...
{"title":"Is there a way to only install the mysql client (Linux)?","tags":["mysql","linux","client"],"question_text":"Are there are any Linux mysql command line tools that don't require the entire mysql db installation package to be installed?\nWhat I'm trying to do is from server #1 (app server), execute mysql comman...
{"title":"How to implement the deprecated methods of Notification","tags":["android","android-notifications"],"question_text":"I have a small problem but dont understand how to get out of this.\nI created a class for providing Notifications, but these lines are marked deprecated:\n`...\nNotification notification = new ...
{"title":"Why is my hidden input writing: value=\"value\" instead of true\/false?","tags":["asp.net","asp.net-mvc-4"],"question_text":"I have an MVC4 site, with (as part of a hidden form):\n`<input name=\"somefield\" type=\"hidden\" value=\"@ViewBag.Test\"\/>`\nThe value of\n`ViewBag.Test`\nis\n`true`\n. The form field...
{"title":"\"'cc' failed with exit status 1\" error when install python library","tags":["python","clang","osx-mavericks","xcode5.1"],"question_text":"Like many others, I'm having issues installing a python library (downloaded as a tar, then extracted).\n`rodolphe-mbp:python-Levenshtein-0.11.2 Rodolphe$ sudo python setu...
{"title":"How do write IF ELSE statement in a MySQL query","tags":["mysql","if-statement"],"question_text":"How do I write an IF ELSE statement in a MySQL query?\nSomething like this:\n`mysql_query(\"...(irrelevant code).. IF(action==2&&state==0){state=1}\");`\nThen down in my array I should be able to do this:\n`$row[...
{"title":"How can I make deleteRowsAtIndexPaths: work with GenericTableViewController?","tags":["iphone","objective-c","cocoa-touch"],"question_text":"I'm using Matt Gallagher's\n`GenericTableViewController`\nidea for controlling my\n`UITableViews`\n. My datasource is a\n`NSFetchedResultsController`\n.\nhttp:\/\/cocoaw...
{"title":"How can I see all the projects I'm watching on github?","tags":["github"],"question_text":"Is there a way to see a list of all projects I'm watching and maybe unwatch some in bulk?","answer_text":"Make sure you're logged in and go to\nhttps:\/\/github.com\/watching\nProfit! ;-)\nMore information about this an...
{"title":"How do I delete till non-whitespace in vim?","tags":["vim","whitespace"],"question_text":"I'm looking for a command to delete from the cursor to the first non-whitespace character on the same line. I've Googled for a while and tried several possibilities. No joy. Does someone out there know how to do this?","...
{"title":"How come you cannot catch Code Contract exceptions?","tags":["c#","visual-studio-2010",".net-4.0","code-contracts"],"question_text":"System.Diagnostics.Contracts.ContractException is not accessible in my test project. Note this code is purely myself messing around with my shiney new copy of Visual Studio, but...
{"title":"Create comma separated strings C#?","tags":["c#","string-concatenation"],"question_text":"I have an object which holds many values, some of them (not all values from the object) need to be put in a csv string. My approach was this:\n`string csvString = o.number + \",\" + o.id + \",\" + o.whatever ....`\nSomeh...
{"title":"1052: Column 'id' in field list is ambiguous","tags":["mysql","sql","join","mysql-error-1052"],"question_text":"I have 2 tables. tbl_names and tbl_section which has both the id field in them. How do I go about selecting the id field, because I always get this error:\n`1052: Column 'id' in field list is ambigu...
{"title":"any idea how to update python PIP on a windows box?","tags":["python","windows","virtualenv","pip"],"question_text":"`pip install --upgrade pip`\ndoesn't work because the windows FS is brain damaged and won't let you delete an open file.\nI've tried setting my environment to the virtualenv that I want to upda...
{"title":"Is a^a or a-a undefined behaviour if a is not initialized?","tags":["c"],"question_text":"Consider this program:\n`#include <stdio.h>\nint main(void)\n{\n unsigned int a;\n printf(\"%u %u\\n\", a^a, a-a);\n return 0;\n}`\nIs it undefined behaviour?\nOn the face of it,\n`a`\nis an uninitialized variable. So th...
{"title":"RequireJS: Difference between \"requirejs\" and \"require\" functions","tags":["javascript","requirejs","require"],"question_text":"I am using requireJS 2.x. I found out that some tutorials (and the official docs) sometimes use\n`requirejs.config({ [...] });\nrequirejs([\"module\"]) ...`\nand sometimes\n`requ...
{"title":"Call to undefined function curl_init() error in wamp 2.2","tags":["php","curl","wamp","wampserver"],"question_text":"I am having below error when I try to implement google and facebook authentication\nin windows 7 using wamp server\n.\nFatal error: Call to undefined function curl_init() in\n E:\\wamp\\www\\my...
{"title":"When and why to 'return false' in JavaScript?","tags":["javascript","jquery"],"question_text":"When and why to\n`return false`\nin JavaScript?","answer_text":"Often, in event handlers, such as\n`onsubmit`\n, returning false is a way to tell the event to not actually fire. So, say, in the\n`onsubmit`\ncase, th...
{"title":"npm install gives unauthorized name or password is incorrect error","tags":["node.js","install","npm","tap"],"question_text":"When I try to install tap using\n`npm install tap`\nI get the following error:\n`npm ERR! Error: unauthorized Name or password is incorrect.: tap`\nHere's the entire response:\n`npm ht...
{"title":"jquery getting post action url","tags":["jquery"],"question_text":"I'm trying to access the post target action in a jquery function.\nexample:\n`<form action=\"\/page\/users\" id=\"signup\" method=\"post\">`\nI'd like to access the \"action\" part - \"\/page\/users\" in this case.\n`$('#signup').live(\"submit...
{"title":"therubyracer gem on windows","tags":["ruby-on-rails","gem","bundler","devkit"],"question_text":"I've been peacefully developing on Windows without adding any gems for a few weeks now and today I decided to to a bundle update, but I cannot get through this gem called therubyracer. I have the devkit installed a...
{"title":"Razor RenderSection within script tags - How to insert script from view into template function","tags":["javascript","asp.net-mvc-3","razor"],"question_text":"I'm using MVC 3 with the Razor view engine and I would like to inject script from my views into one $(document).ready(function(){}); function in the ma...
{"title":"Yahoo Weather API WOEID retrieval","tags":["php","api","yahoo","weather"],"question_text":"I'm creating an app (PHP) that takes yahoo weather data from the free RSS feed and correlates it with a colour hex based on data retrieved from the RSS feed. The issue I'm having is finding a way to grab the location co...
{"title":"Using the Swift if let with logical AND operator &&","tags":["swift","expression"],"question_text":"We know that we can use an\n`if let`\nstatement as a shorthand to check for an optional nil then unwrap.\nHowever, I want to combine that with another expression using the logical AND operator\n`&&`\n.\nSo, for...
{"title":"Visual Studio inserts invalid characters in batch files","tags":["visual-studio-2008","batch-file"],"question_text":"I've got some batch files that I use to help automate the process of creating and reloading development databases. It makes sense to create and maintain these batch files in Visual Studio (i.e....
{"title":"Knockout: computed observable vs function","tags":["knockout.js","knockout-2.0","computed-observable"],"question_text":"When using knockout, what is the advantage of using read-only computed observables rather than simple functions?\nTake the following viewmodel constructor and html snippet, for example: \u00...
{"title":"Position geom_text on dodged barplot","tags":["r","plot","ggplot2","bar-chart"],"question_text":"I tried to make the title self-explanatory, but here goes - data first:\n`dtf <- structure(list(variable = structure(c(1L, 1L, 2L, 2L, 3L, 3L, \n4L, 4L, 5L, 5L), .Label = c(\"vma\", \"vla\", \"ia\", \"fma\", \"fla...
{"title":"Why does Sleep(500) cost more than 500ms?","tags":["c++","winapi","sleep"],"question_text":"I used\n`Sleep(500)`\nin my code and I used\n`getTickCount()`\nto test the timing. I found that it has a cost of about 515ms, more than 500. Does somebody know why that is?","answer_text":"Because Win32 API's\n`Sleep`\...
{"title":"Postgis installation: type \"geometry\" does not exist","tags":["postgresql","geometry","postgis"],"question_text":"I am trying to create table with Postgis. I do it by this\npage\n. But when I import postgis.sql file, I get a lot of errors:\n`ERROR: type \"geometry\" does not exist`\nDoes anybody know how ca...
{"title":"Get first 100 characters from string, respecting full words","tags":["php","string"],"question_text":"I have asked a similar question here before, but I need to know if this little tweak is possible. I want to shorten a string to 100 characters and use\n`$small = substr($big, 0, 100);`\nto do so. However, thi...
{"title":"Laravel - Session store not set on request","tags":["php","laravel"],"question_text":"I recently created a new Laravel project and was following along the guide on Authentication. When I visit either my login or register route, I get the following error:\n`ErrorException in Request.php line 775:\nSession stor...
{"title":"Getting Cannot read property 'offsetWidth' of undefined with bootstrap carousel script","tags":["javascript","jquery","twitter-bootstrap"],"question_text":"I created a\n`carousel`\nwith\n`Bootstrap 3.3`\nand it works on my local machine, but when I upload the whole thing on server where the bootstrap js file ...
{"title":"What's a simple way to undelete a file in subversion?","tags":["svn","version-control"],"question_text":"These instructions are a little intimidating and confusing:\nhttp:\/\/svnbook.red-bean.com\/en\/1.0\/ch04s04.html#svn-ch-4-sect-4.3\n.\nAnd also they don't seem to mention that it's much simpler if you hav...
{"title":"selectionStart-End with textareas","tags":["javascript","jquery","editor"],"question_text":"I'm having this annoying problem, I can't seem to get the starting and ending index of the selected text in a textarea, all I get is undefined like this:\n`$('#myarea').selectionStart; \/\/ return undefined`\nDid I do ...
{"title":"exception in initializer error","tags":["java","binding","pack"],"question_text":"I am using Netbeans. I did some things with bindings and now whenever I start my program, before it even intializes the form, it gives me an error\nThe exception in thread main is ocuring before the form is even an intialized ob...
{"title":"should use size_t or ssize_t","tags":["c++","unsigned","signed","size-t"],"question_text":"At my code, I do not use int or unsigned int. I only use size_t or ssize_t for portable. For example:\n`typedef size_t intc; \/\/ (instead of unsigned int)\ntypedef ssize_t uintc; \/\/ (instead of int)`\nBecause\n`strle...
{"title":"Rails model without database","tags":["ruby-on-rails","ruby","activerecord"],"question_text":"I want to create a Rails (2.1 and 2.2) model with ActiveRecord validations, but without a database table. What is the most widely used approach? I've found some plugins that claim to offer this functionality, but man...
{"title":"Best pattern for simulating \"continue\" in Groovy closure","tags":["groovy","closures"],"question_text":"It seems that Groovy does not support break and continue from within a closure. What is the best way to simulate this?\n`revs.eachLine { line -> \n if (line ==~ \/-{28}\/) {\n \/\/ continue to next line.....
{"title":"Difference between a LinkedList and a Binary Search Tree","tags":["data-structures","linked-list","language-agnostic","binary-search-tree"],"question_text":"What are the main differences between a Linked List and a BinarySearchTree? Is BST just a way of maintaining a LinkedList? My instructor talked about Lin...
{"title":"What does \"inherently thread-safe\" mean?","tags":["java","c","multithreading","thread-safety"],"question_text":"I came across this line\n\"some functions are inherently thread-safe, for example\n`memcpy()`\n\"\nWikipedia\ndefines \"thread-safe\" as:\nA piece of code is thread-safe if it only manipulates sha...
{"title":"How do you like your primary keys?","tags":["sql-server","algorithm","database-design","primary-key"],"question_text":"In a fairly animated discussion in my team I was made to think what most people like as primary keys. We had the following groups-\nInt\/ BigInt which autoincrement are good enough primary ke...
{"title":"jquery unobtrusive validation attributes reference?","tags":["javascript","jquery"],"question_text":"Where i can find the reference for\nUnobtrusive jquery validation attributes\nlike\n`data-val-length`\n,\n`data-val-required`\netc..I want the full list of these attributes. Is\nthere any single place where i ...
{"title":"How to use git mergetool's filemerge","tags":["osx","git","mergetool","filemerge"],"question_text":"The documentation is here:\nhttp:\/\/www.kernel.org\/pub\/software\/scm\/git\/docs\/git-mergetool.html\nA handy guide is here:\nhttp:\/\/ryanflorence.com\/git-for-beginners\/\nHowever, neither of them explain h...
{"title":"Java get month string from integer","tags":["java","date"],"question_text":"Is there a better way to compact this method i.e. reduce the cyclomatic complexity by avoid the switch cases?\n`String monthString;\n switch (month) {\n case 1: monthString = \"January\"; break;\n case 2: monthString = \"February\"; b...
{"title":"What are naming conventions for MongoDB?","tags":["mongodb","naming-conventions"],"question_text":"Is there a set of preferred naming conventions for MongoDB entitites such as databases, collections, field names?\nI was thinking along these lines:\nDatabases: consist of the purpose (word in singular) and end ...
{"title":"How to make an progress bar for an NSURLConnection when downloading a file?","tags":["iphone","progress-bar","nsurlconnection"],"question_text":"I want to show up an progress bar while a download with NSURLConnection is happening. As I am getting data from the server, I could update the UI for every received ...
{"title":"JSONObject - How to get a value ?","tags":["java","json"],"question_text":"i'm using a java class on\nhttp:\/\/json.org\/javadoc\/org\/json\/JSONObject.html\n.\nThe following is my code snippet.\n`String jsonResult = UtilMethods.getJSON(this.jsonURL, null);\njson = new JSONObject(jsonResult);`\ngetJSON return...
{"title":"How to trim leading and trailing white spaces of a string in golang?","tags":["go"],"question_text":"Which is the effective way to trim the leading and trailing white spaces of string variable in golang","answer_text":"For example,\n`package main\nimport (\n \"fmt\"\n \"strings\"\n)\nfunc main() {\n s := \"\\...
{"title":"Flask-SQLalchemy update a row's information","tags":["python","flask","flask-sqlalchemy"],"question_text":"How can I update a row's information?\nFor example I'd like to alter the name column of the row that has the id 5.","answer_text":"Retrieve an object using the\ntutorial shown in the Flask-SQLAlchemy doc...
{"title":"Why is my jQuery :not() selector not working in CSS?","tags":["jquery","css","css3","jquery-selectors","css-selectors"],"question_text":"I have this layout:\n`<div id=\"sectors\">\n <h1>Sectors<\/h1>\n <div id=\"s7-1103\" class=\"alpha\"><\/div>\n <div id=\"s8-1104\" class=\"alpha\"><\/div>\n <div id=\"s1-760...
{"title":"Changing background colour of tr element on mouseover","tags":["html","css"],"question_text":"I want to have my table rows highlighted on mouse over, but I have yet to find a way to do it that isn't using Javascript. Is this not possible in CSS?\nI've tried this:\n`tr:hover {\n background: #000;\n}`\nBut that...
{"title":"cp command should ignore some files","tags":["shell","command-line"],"question_text":"Sometimes I need to perform following command\n`cp -rv demo demo_bkp`\nHowever I want to ignore all the files in directory .git . How do I achieve that? It takes a long time to copy .git files and I do not need those files."...
{"title":"How can I find the missing value more concisely?","tags":["python","benchmarking","microbenchmark"],"question_text":"The following code checks if\n`x`\nand\n`y`\nare distinct values (the variables\n`x`\n,\n`y`\n,\n`z`\ncan only have values\n`a`\n,\n`b`\n, or\n`c`\n) and if so, sets\n`z`\nto the third characte...
{"title":"Why does StyleCop recommend prefixing method or property calls with \"this\"?","tags":["c#",".net","coding-style","stylecop"],"question_text":"I have been trying to follow StyleCop's guidelines on a project, to see if the resulting code was better in the end. Most rules are reasonable or a matter of opinion o...
{"title":"MySQL Cluster (NDB) vs MySQL Replication (InnoDB) for Rails 3 apps: pros\/cons?","tags":["mysql","ruby-on-rails"],"question_text":"We are doing an overview of our current systems, trying to figure out if we can improve performance & reliability.\nCurrently we run a bunch of internal Rails apps and our Rails b...
{"title":"Laravel save \/ update many to many relationship","tags":["laravel","laravel-4","eloquent","relationship"],"question_text":"Can anyone help me on how to save many to many relationship? I have tasks, user can have many tasks and task can have many users (many to many), What I want to achieve is that in\nupdate...
{"title":"format xml string","tags":["php","xml","string"],"question_text":"What is the best way to format XML within a PHP class.\n`$xml = \"<element attribute=\\\"something\\\">...<\/element>\";\n$xml = '<element attribute=\"something\">...<\/element>';\n$xml = '<element attribute=\\'something\\'>...<\/element>';\n$x...
{"title":"Developing in Ruby on Windows","tags":["ruby-on-rails","windows","ruby"],"question_text":"I'm starting a new job soon where I'm going to be developing in Ruby and Rails on a Windows machine. I haven't used Windows for years, and the likes of Textmate, Git and Bash, are an integral part of the workflow using a...
{"title":"cmd 2>&1 > log vs cmd > log 2>&1","tags":["linux","bash","unix","command-line","redirect"],"question_text":"What is the difference between:\n`cmd > log 2>&1`\nand\n`cmd 2>&1 > log`\nwhere cmd is a command?\nWhich should I prefer and why?","answer_text":"Order matters. The way to reason about redirections is t...
{"title":"The maximum value for an int type in Go","tags":["numbers","go"],"question_text":"How does one specify the maximum value representable for an\n`unsigned`\ninteger type?\nI would like to know how to initialize\n`min`\nin the loop below that transitively computes min and max lengths from some structs.\n`var min...
{"title":"AngularJS: What's the best practice to add ngIf to a directive programmatically?","tags":["javascript","angularjs","angularjs-directive"],"question_text":"I want to create a directive that checks if an element should be present in the dom based on a value coming from a service (e.g. check for a user role).\nT...
{"title":"How can i get the application's icon from the package name?","tags":["android"],"question_text":"I have tried various solution from stack overflow with no luck. What I want.\nI know package name of different applications.\nI want to get application Icon from those package name.\nShow those icons in Image View...
{"title":"Calculate Bounding box coordinates from a rotated rectangle, Picture inside","tags":["actionscript-3","math","geometry","rotation","bounding-box"],"question_text":"I have the coordinates of the top left Point of a rectangle as well as its width, height and rotation from 0 to 180 and -0 to -180.\nI am trying t...
{"title":"Makefile variable as prerequisite","tags":["makefile"],"question_text":"In a Makefile, a\n`deploy`\nrecipe needs a environment variable\n`ENV`\nto be set to properly execute itself, whereas others don't care, eg:\n`ENV = \n.PHONY: deploy hello\ndeploy:\n rsync . $(ENV).example.com:\/var\/www\/myapp\/\nhello:\...
{"title":"Validate select box","tags":["javascript","jquery","html","validation","forms"],"question_text":"I'm using the jQuery plugin\nValidation\nto validate a form. I have a select list looking like this:\n`<select id=\"select\">\n<option value=\"\">Choose an option<\/option>\n<option value=\"option1\">Option1<\/opt...
{"title":"Loop doesn't see changed value without a print statement","tags":["java","multithreading","synchronization","busy-waiting"],"question_text":"In my code I have a loop that waits for some state to be changed from a different thread. The other thread works, but my loop never sees the changed value.\nIt waits for...
{"title":"Fix Vim + Tmux yank\/paste on unnamed register","tags":["vim","tmux"],"question_text":"While using vim inside a tmux session I cannot yank or paste to the unnamed register. Going to a named register works fine, but unnamed never works.\nError is:\n`E353: Nothing in register *`\nWithout tmux, vim works fine us...
{"title":"Convert dictionary to List<KeyValuePair>","tags":["c#","generics","collections"],"question_text":"I know that its possible to convert a List of KeyValuePair into a Dictionary, but is there a quick way (besides looping through manually) to perform the vice versa operation?\nThis would be the manual way,\n`fore...
{"title":"Strange behavior using braces in Java","tags":["java","braces"],"question_text":"When I run the following code:\n`public class Test {\n Test(){\n System.out.println(\"1\");\n }\n {\n System.out.println(\"2\");\n }\n static {\n System.out.println(\"3\");\n }\n public static void main(String args[]) {\n new Tes...
{"title":"How can I find out when a picture was actually taken in C# running on Vista?","tags":["c#"],"question_text":"In windows XP \"FileInfo.LastWriteTime\" will return the date a picture is taken - regardless of how many times the file is moved around in the filesystem.\nIn Vista it instead returns the date that th...
{"title":"How to change the default icon on the SearchView, to be use in the action bar on Android?","tags":["android","android-actionbar"],"question_text":"I'm having a bit of trouble customizing the search icon in the SearchView. On my point of view, the icon can be changed in the Item attributes, right? Just check t...
{"title":"Can someone explain \"ClassCastException\" in Java?","tags":["java","casting","classcastexception"],"question_text":"I read some articles written on \"ClassCastException\" but I couldn't get a good idea on that. Can someone direct me to a good article or explain it briefly.","answer_text":"Straight from the A...
{"title":"How can I throttle user login attempts in PHP","tags":["security","throttling","honeypot"],"question_text":"I was just reading this post\nThe definitive guide to form based website authentication\non Preventing Rapid-Fire Login Attempts.\nBest practice #1: A short time delay that increases with the number of ...
{"title":"Assert List in Junit","tags":["java","junit","java-collections-api"],"question_text":"How to assert list in\nJUnit\ntest case? I mean not only the size of the list but also the contents of the list.","answer_text":"I realise this was asked a couple years ago, probably this feature wasn't around then. But now,...
{"title":"WHERE clause on SQL Server \"Text\" data type","tags":["sql-server","sql-server-2005","tsql"],"question_text":"Where [CastleType] is set as data type \"text\" in SQL Server and the query is:\n`SELECT *\nFROM [Village]\nWHERE [CastleType] = 'foo'`\nI get the error:\nThe data types\nTEXT\nand\nVARCHAR\nare inco...
{"title":"Using AngularJS date filter with UTC date","tags":["angularjs","datetime","angularjs-filter"],"question_text":"I have an UTC date in milliseconds which I am passing to Angular's date filter for human formatting.\n`{{someDate | date:'d MMMM yyyy'}}`\nAwesome, except\n`someDate`\nis in UTC and the date filter c...
{"title":"How do I use a complex criteria inside a doctrine 2 entity's repository?","tags":["php","sql","doctrine","criteria","doctrine2"],"question_text":"Lets say I have a table that holds information about festivals.\nEach festival has a start and end date.\nI want to select all the festivals that are live (that hap...
{"title":"Change background color for selected ListBox item","tags":["wpf","styles"],"question_text":"This is my XAML so far.\n`<ScrollViewer Grid.Column=\"1\" Grid.RowSpan=\"2\">\n <ListBox Background=\"Black\" ItemsSource=\"{Binding Path=ActiveLog}\" >\n <ListBox.ItemTemplate>\n <DataTemplate>\n <Grid Background=\"Bl...
{"title":"What does a colon following a C++ constructor name do?","tags":["c++","constructor","initialization-list","ctor-initializer"],"question_text":"What does the colon operator (\":\") do in this constructor? Is it equivalent to\n`MyClass(m_classID = -1, m_userdata = 0);`\n?\n`class MyClass {\npublic:\n MyClass() ...
{"title":"Extracting date from a string in Python","tags":["python","string","date"],"question_text":"How can I extract the date from a string like \"monkey 2010-07-10 love banana\"? Thanks!","answer_text":"Using\npython-dateutil\n:\n`In [1]: import dateutil.parser as dparser\nIn [18]: dparser.parse(\"monkey 2010-07-10...
{"title":"How to check device natural (default) orientation on Android (i.e. get landscape for e.g., Motorola Charm or Flipout)","tags":["android"],"question_text":"I have an activity showing preview from camera, so it need to be set as landscape only. At the bottom (regardless of device rotation) I want to show a text...
{"title":"Write to multiple outputs by key Spark - one Spark job","tags":["scala","hadoop","output","hdfs","apache-spark"],"question_text":"How can you write to multiple outputs dependent on the key using Spark in a single Job. I could of course use\n`.filter`\nfor all the possible keys, but that is a horrible hack, wh...
{"title":"MSBuild passing parameters to CallTarget","tags":["msbuild","parameter-passing","msbuild-target"],"question_text":"I'm trying to make a reusable target in my MSBuild file so I can call it multiple times with different parameters.\nI've got a skeleton like this:\n`<Target Name=\"Deploy\">\n <!-- Deploy to a di...
{"title":"How can I override the @Html.LabelFor template?","tags":["asp.net-mvc","templates","asp.net-mvc-3"],"question_text":"I have a simple field form\n`<div class=\"field fade-label\">\n @Html.LabelFor(model => model.Register.UserName)\n @Html.TextBoxFor(model => model.Register.UserName)\n<\/div>`\nand this results...
{"title":"Git command could not be found. Please create an alias or add it to your PATH","tags":["git","github","github-for-windows"],"question_text":"After updating github, I am getting these\n`WARNING`\n.\ngit command could not be found. Please create an alias or add it to your PATH.\nWarning: Could not find ssh-agen...
{"title":"angular mock `module` resulting in '[Object object] is not a function'","tags":["angularjs","angular-mock","teaspoon"],"question_text":"I'm trying to create some unit tests in Angular using Jasmine being run through Teaspoon. The tests are running, however I have a simple test just to test the existence of a ...
{"title":"Omniauth Facebook Error - Faraday::Error::ConnectionFailed","tags":["facebook","omniauth","faraday-oauth"],"question_text":"(FYI: I'm following the Twitter Omniauth from railscast #241. I used Twitter successfully, now going onto Facebook)\nAs soon as I logged into Facebook using Omniauth, I get this error:\n...
{"title":"Python function pointer","tags":["python","function-pointers"],"question_text":"I have a function name stored in a variable like this:\n`myvar = 'mypackage.mymodule.myfunction'`\nand I now want to call myfunction like this\n`myvar(parameter1, parameter2)`\nWhat's the easiest way to achieve this?","answer_text...
{"title":"How to make user controls know about css classes in ASP.NET","tags":["asp.net","css","visual-studio-2008","user-controls"],"question_text":"Since there are no header sections for user controls in asp.net, user controls have no way of knowing about stylesheet files. So css classes in the user controls are not ...