Convert string to title case with JavaScript

Convert string to title case with JavaScript

Is there a simple way to convert a string to title case? E.g. john smith becomes John Smith. I'm not looking for something complicated like John Resig's solution, just (hopefully) some kind of one- or two-liner. 1:Try this:function toTi

Get escaped URL parameter

Get escaped URL parameter

I'm looking for a jQuery plugin that can get URL parameters, and support this search string without outputting the JavaScript error: "malformed URI sequence". If there isn't a jQuery plugin that supports this, I need to know how to modify i

What's the purpose of the LEA instruction?

What's the purpose of the LEA instruction?

For me, it just seems like a funky MOV. What's its purpose and when should I use it? 1:As others have pointed out, LEA (load effective address) is often used as a "trick" to do certain computations, but that's not its primary purpose. Th

How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request?

How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request?

I have a JavaScript widget which provides standard extension points. One of them is the beforecreate function. It should return false to prevent an item from being created. I've added an Ajax call into this function using jQuery:beforecreat

How to check visibility of software keyboard in Android?

How to check visibility of software keyboard in Android?

I need to do a very simple thing - find out if the software keyboard is shown. Is this possible in Android? 1:NEW ANSWER added Jan 25th 2012Since writing the below answer, someone clued me in to the existence of ViewTreeObserver and frie

What should my Objective-C singleton look like? [closed]

What should my Objective-C singleton look like? [closed]

My singleton accessor method is usually some variant of:static MyClass *gInstance = NULL;+ (MyClass *)instance{ @synchronized(self) { if (gInstance == NULL) gInstance = [[self alloc] init]; } return(gInstance);

JSON Parse File Path

JSON Parse File Path

I'm stuck trying to get the correct path to the local file. I have the following directories:Resources -> data -> file.json js -> folder -> script.js html -> folder -> file1.htmlI'm executing script.js fr

How do you do polymorphism in Ruby?

How do you do polymorphism in Ruby?

In C#, I can do this:class Program{ static void Main(string[] args) { List animals = new List(); animals.Add(new Dog()); animals.Add(new Cat()); foreach (Animal a in animals) {

is there a way to pass nested initializer lists in C++11 to construct a 2D matrix?

is there a way to pass nested initializer lists in C++11 to construct a 2D matrix?

Imagine you have a simple matrix classtemplate class Matrix { T* data; size_t row, col;public: Matrix(size_t m, size_t n) : row(m), col(n), data(new T[m*n]) {} //... friend std::ostream& operatorIs there a way that I can initial

Update AngularJS ng-model only on keypress enter?

Update AngularJS ng-model only on keypress enter?

I have this input field I am using for a search:There are many other filters I use as well (checkboxes, radio, etc) and I have a $watch on filter so any changes will fire a search. The problem is that I don't want the search to fire for the

Subfolders in .gitignore

Subfolders in .gitignore

I have many subfolders in my repo, in which there are few build/ directories I'd like to ignore when committing my code. As I understand it, there are two ways to ignore all of the folders:*/build/ (Unix wildcards)build/ (git way of ignorin

Initializing List with given number of nulls without loop?

Initializing List with given number of nulls without loop?

Can a List be initialized to contain a given number of nulls, where T is a type parameter of the class of which the list is a member? I sure can do it with a loop, but like to know whether it is possible without.List myList = new ArrayList(

How does “Angular 2.0 for TypeScript” (alpha) animation work?

How does “Angular 2.0 for TypeScript” (alpha) animation work?

I am very new in the Angular scene. I just started to learn Angular 2.0 for TypeScript and I was wondering, how the animation (like in a simple HTML with jQuery) works in Angular 2.0In the homepage of the Angular 2.0 (angular.io > Features)

Python convert tuple to array [duplicate]

Python convert tuple to array [duplicate]

This question already has an answer here: Making a flat list out of list of lists in Python 33 answers How can I convert at 3-Dimensinal tuple into an

Video 100% width and height

Video 100% width and height

I have a video, and I want it to FILL 100% of the width, and 100% of the height. And keep the aspect ratio.Is it possible that it at least fills 100% for both? And if a bit of the video has to be out of the screen to keep the aspect ratio,

Django annotation with nested filter

Django annotation with nested filter

Is it possible to filter within an annotation? In my mind something like this (which doesn't actually work)Student.objects.all().annotate(Count('attendance').filter(type="Excused"))The resultant table would have every student with the numbe

MAX function in where clause mysql

MAX function in where clause mysql

How can I use max() function in where clause of a mysql query, I am trying: select firstName,Lastname,MAX(id) as max where id=max;this is giving me an error:Unknown column 'max' in 'where clause'Any Help? Thanks in advance. 1:You can't r

overflow-x: visible; doesn't work with overflow-y: auto; any workaround? [duplicate]

overflow-x: visible; doesn't work with overflow-y: auto; any workaround? [duplicate]

This question already has an answer here: CSS overflow-x: visible; and overflow-y: hidden; causing scrollbar issue 5 answers i am trying.item { width

c array - warning: format not a string literal

c array - warning: format not a string literal

I'm attempting to learn C and already I've run into an issue. I assume its trivial but I need to know it. I have written:#include #include int main() { char str_a[20]; strcpy(str_a, "Hello, world!\n"); printf(str_a);}Once I attempt

How do you tweak “-webkit-” prefixed CSS properties in jQuery?

How do you tweak “-webkit-” prefixed CSS properties in jQuery?

$(this).css({ -webkit-transform:'rotate(180deg)', -moz-transform: 'rotate(180deg)', -o-transform: 'rotate(180deg)', -ms-transform: 'rotate(180deg)'});This is throwing the error: Uncaught SyntaxError: Unexpected token -I'm reall

What is jQuery (edge) in jsfiddle.net?

What is jQuery (edge) in jsfiddle.net?

In jsfiddle.net if one choose framework as jQuery or Mootools they will get an option for choosing jQuery ( edge ) and Mootools( edge ).I googled it quite a bit but did not get any good answers. My questions areWhat are those versions?How a

Type definition with a trait: Differences of specifying an explicit lifetime bound?

Type definition with a trait: Differences of specifying an explicit lifetime bound?

I'm having issues understanding the lifetime bound requirements when I use a trait in a type definition. For instance:trait Kind { /* ... */ }type CollectionOfKind = Vec;// => error: explicit lifetime bound requiredThe requirement for lifet

How to manage “paging” with Solr?

How to manage “paging” with Solr?

I have a classifieds website...I have Solr doing the searching of the classifieds, and then return ID:nrs which I then use to put into an array. Then I use this array to find any classifieds in a MySql db where the ID:s match the ID:s in th

How to convert a Java Long to byte[] for Cassandra?

How to convert a Java Long to byte[] for Cassandra?

Lazy programmer alert. :)Cassandra stores column values as bytes (Java example). Specifying a LongType comparator compares those bytes as a long. I want the value of a long into a Cassandra-friendly byte[]. How? I poked around for awhil

Square instead of rounded corners in UITableViewCell grouped style

Square instead of rounded corners in UITableViewCell grouped style

I want to have square corners for my grouped tableview cells instead of the default rounded corners, and I don't just want to use an image to give that effect. Is it possible? 1:Most simply, in your tableView:cellForRowAtIndexPath: usece