Skip to content

Instantly share code, notes, and snippets.

@luk-
luk- / ajax.html
Created March 10, 2012 02:31
for Todd
<!DOCTYPE html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
var get_servlet_call = function (url) {
$.get (url, function (data) {
// this callback function is called on successful return of the url passed to $.get
// function (data) is the callback here — in javascript it's considered an anonymous function.
alert(data);
String.prototype.validate = function (regex) {
var pattern = {
zip: /^\d{5}([\-])?$/,
email: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,
ip: /(?:\d{1,3}\.){3}\d{1,3}/
};
return pattern[regex].test(this.trim());
}
> console.log(util.inspect(Date, true, null))
{ [Function: Date]
[now]: { [Function: now] [arguments]: null, [length]: 0, [name]: 'now', [caller]: null },
[arguments]: null,
[UTC]: { [Function: UTC] [arguments]: null, [length]: 7, [name]: 'UTC', [caller]: null },
[length]: 7,
[name]: 'Date',
[prototype]:
{ Invalid Date
[constructor]: [Circular],
@luk-
luk- / ziptastic.html
Created April 11, 2012 02:18
ziptastic
<script type="text/javascript">
var client = new XMLHttpRequest();
client.open("GET", "http://zip.elevenbasetwo.com?zip=48867", true);
client.onreadystatechange = function () {
if(client.readyState == 4) {
alert(client.responseText);
};
};
curl http://api.nodejitsu.com -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.83 Safari/535.11' -v
[ { '@':
{ b1: '475174',
start_tfs_zulu: '2012-04-17T03:12:59Z',
event: 'Single',
start_tfs: '231259',
num: '75',
b2: '460026',
pitcher: '543022',
batter: '475174',
b3: '',
@luk-
luk- / http_build_query.js
Created May 17, 2012 22:42
php's http_build_query() in javascript
var build_query = function (obj, num_prefix, temp_key) {
var output_string = []
Object.keys(obj).forEach(function (val) {
var key = val;
num_prefix && !isNaN(key) ? key = num_prefix + key : ''
<VirtualHost *:80>
ServerName mtambo.com
ServerAlias www.mtambo.com
DocumentRoot /var/www/mtambo.com/htdocs
ErrorLog /var/www/mtambo.com/logs/error.log
CustomLog /var/www/mtambo.com/logs/acomess.log common
</VirtualHost>
NameVirtualHost *:80
<Directory /var/www/>
AllowOverride All
</Directory>
<VirtualHost *:80>
</VirtualHost>
Include sites-enabled/*
if (err || !files) return (err ? console.log(err) : (function() {throw new Error('no files')})())