Skip to content

Instantly share code, notes, and snippets.

View guybrush's full-sized avatar

Patrick guybrush

View GitHub Profile
(function(exports, undefined){
/**
* obj2url() takes an object as argument and generates
* a querystring. pretty much like $.param() but without $
*
* @param Object json-object
* @param String current querystring-part
* @return String encoded querystring
*/
var obj2url = exports.obj2url = function(obj, temp) {
@guybrush
guybrush / contenteditable.html
Created August 11, 2010 12:08
contenteditable
<!DOCTYPE html>
<html lang="en" manifest="cache.manifest">
<head>
<meta charset="utf-8" />
<title>contenteditable and window.getSelection()</title>
<style type="text/css">
body {background:black; color:white;}
div {margin:10px;}
#editable {background:white; color:black;}
#editable p {border:1px dashed gray;}
@guybrush
guybrush / stringObj.js
Created August 16, 2010 03:55
stringObj
(function(exports, undefined) {
/**
* create/access objects with a key-string
*
* with eval(): with stringObj():
* ----------------------------- ------------------------------
* var keyString = 'json.data' var keyString = 'json.data'
* , value = 'a value'; , value = 'a value';
* eval(keyString+' = '+value); stringObj(keyString, value);
* alert(eval(keyString)); alert(stringObj(keyString));
<!DOCTYPE html>
<!-- Helpful things to keep in your <head/>
// Brian Blakely, 360i
// http://twitter.com/brianblakely/
-->
<head>
<!-- According to Heather Champ, former community manager at flickr,
you should not allow search engines to index your "Contact Us"
#!/usr/local/bin/node
var sys = require('sys'),
http = require('http'),
querystring = require('querystring'),
base64 = require('./lib/base64'),
Buffer = require('buffer').Buffer,
Irc = require('./vendor/IRC/lib/irc');
var twitter_auth = { user: "<YOUR_TWITTER_USERNAME>", pass: "<YOUR_TWITTER_PASSWORD>"};
@guybrush
guybrush / install node
Created September 11, 2010 05:36
install multiple nodejs versions, use same npm packages
#
# node ---------------> ~/.nvm/<node-version>/bin/node
# node-libraries -----> ~/.node_libraries
# node-binaries ------> ~/.node_binaries
#
aptitude install g++ curl libssl-dev apache2-utils make
git clone git://github.com/creationix/nvm.git ~/.nvm
vi ~/.bashrc
export PATH=$PATH:~/.node_binaries
NVM_DIR=$HOME/.nvm
app.get(/^\/foo\/(.+)/, function(req, res) {
var encoding = (/[.png]+$/.test(req.params[0])) ? 'binary' : 'utf-8';
var path = '/foo/'+req.params[0];
fs.readFile(path, encoding, function(err, data) {
if (err) {
throw err;
} else {
res.contentType(req.params[0]);
res.send(data);
}
/*!
* Table.js
* Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
/**
* http://github.com/Marak/table.js/blob/master/lib/table.js
*/
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
body {background:black; color:white;}
</style>
<script src="http://code.jquery.com/jquery.min.js" type="text/javascript"></script>
<link id="bespin_base" href="BespinEmbedded-0.9a2/prebuilt"/>
<script src="BespinEmbedded-0.9a2/prebuilt/BespinEmbedded.js"></script>
@guybrush
guybrush / pandoc.css
Created October 18, 2010 05:42
pandoc.css
body {
font: Arial;
/*
font: 18px/27px 'YanoneKaffeesatzRegular', Arial, sans-serif;
font-family:"Myriad Pro",georgia, helvetica, arial, sans serif;
*/
font-size:larger;
background:black; color:white; margin-left:300px; width:500px; padding:20px}
a {color:yellow; background:black;}
a:hover {color:black; background:yellow;}