A timeline of the last four years of detecting good old window.localStorage
.
October 2009: 5059daa
A timeline of the last four years of detecting good old window.localStorage
.
October 2009: 5059daa
function toTitleCase(str) { | |
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); | |
} |
A very exclusive collection of only must-have JavaScript links. I'm only listing my favorite links. Nothing else makes the cut. Feel free to suggest links if you think they're good enough to make this list. The really curious should feel free to browse the comments to find other links. I can't guarantee the quality of links in the comments.
Some of these links are affiliate links, meaning that if you make a purchase, I might earn a little money. This has absolutely no bearing on whether or not links make the list. None, whatsoever. However, it does allow me more resources to fight poverty with code. Every little bit counts.
package com.greenchiu.nets; | |
import java.io.UnsupportedEncodingException; | |
import java.util.Map; | |
import org.json.JSONException; | |
import org.json.JSONObject; | |
import com.android.volley.NetworkResponse; | |
import com.android.volley.ParseError; |
DisplayMetrics metrics = getApplicationContext().getResources().getDisplayMetrics(); | |
int height = metrics.heightPixels; | |
int width = metrics.widthPixels; |
Perl and PHP Regular Expressions | |
PHP regexes are based on the PCRE (Perl-Compatible Regular Expressions), so any regexp that works for one should be compatible with the other or any other language that makes use of the PCRE format. Here are some commonly needed regular expressions for both PHP and Perl. Each regex will be in string format and will include delimiters. | |
All Major Credit Cards | |
This regular expression will validate all major credit cards: American Express (Amex), Discover, Mastercard, and Visa. | |
//All major credit cards regex | |
'/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|622((12[6-9]|1[3-9][0-9])|([2-8][0-9][0-9])|(9(([0-1][0-9])|(2[0-5]))))[0-9]{10}|64[4-9][0-9]{13}|65[0-9]{14}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})*$/' |
/** | |
* Variant of Avraham Plotnitzky's String.prototype method mixed with the "fast" version | |
* see: https://sites.google.com/site/abapexamples/javascript/luhn-validation | |
* @author ShirtlessKirk. Copyright (c) 2012. | |
* Licensed under WTFPL (http://www.wtfpl.net/txt/copying) | |
*/ | |
function luhnChk(luhn) { | |
var len = luhn.length, | |
mul = 0, |
// send to current request socket client | |
socket.emit('message', "this is a test"); | |
// sending to all clients, include sender | |
io.sockets.emit('message', "this is a test"); | |
// sending to all clients except sender | |
socket.broadcast.emit('message', "this is a test"); | |
// sending to all clients in 'game' room(channel) except sender |
function getCheckedStudents() { | |
var students = $("input[name=student]:checked") | |
.map(function () { | |
return this.value; | |
}).get().join(", "); | |
return students; | |
} |
/** | |
* Modify the parts you need to get it working. | |
*/ | |
var should = require('should'); | |
var request = require('../node_modules/request'); | |
var io = require('socket.io-client'); | |
var serverUrl = 'http://localhost'; |