Skip to content

Instantly share code, notes, and snippets.

@d48
d48 / numberWithCommas.js
Created June 28, 2012 22:12
number with commas
numberWithCommas: function(num) {
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
@d48
d48 / ssl.md
Created June 6, 2012 19:58 — forked from 8bitDesigner/ssl.md
Getting Apache SSL working locally

Lovingly skimmed from this guide

  1. Find your local host name, and hang onto it for later use
$ hostname
  1. Create a self-signed SSL cert:
openssl req -new -x509 -days 365 -sha1 -newkey rsa:1024 -nodes \
@d48
d48 / object.js
Created April 20, 2012 08:29
js object with sample leading comma structure
{
"validthis" : true
, "laxcomma" : true
, "laxbreak" : true
, "browser" : true
, "boss" : true
, "expr" : true
, "asi" : true
}
@d48
d48 / debug-js-console.php
Created April 10, 2012 07:20
php debug to javascript console.log
function debug ($data) {
echo "<script>\r\n//<![CDATA[\r\nif(!console){var console={log:function(){}}}";
$output = explode("\n", print_r($data, true));
foreach ($output as $line) {
if (trim($line)) {
$line = addslashes($line);
echo "console.log(\"{$line}\");";
}
}
echo "\r\n//]]>\r\n</script>";