Skip to content

Instantly share code, notes, and snippets.

readFromDatabase(function(data) {
printData(data);
})
doSomethingUnrelatedLikeFetchingSomethingElse();
$.ajax({
url: '/path/to/file',
type: 'POST',
dataType: 'json',
data: {param1: 'value1'},
complete: function(xhr, textStatus) {
doSomethingOnComplete();
},
success: function(data, textStatus, xhr) {
doSomethingOnSuccess();
// Import standard system and HTTP libraries
var sys = require('sys'),
http = require('http');
// Create an HTTP server listening on port 8000 and attach a function to handle incoming requests
http.createServer(function (request, response) {
//Set response headers
response.writeHead(200, {'Content-Type': 'text/plain'});
hydra:~ jpadilla$ sudo curl https://github.com/atmos/cinderella/raw/master/bootstrap.sh \
> -o - | sh
Password:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
102 1333 102 1333 0 0 1722 0 --:--:-- --:--:-- --:--:-- 12695
Ensuring we have the latest version of cinderella installed
A first time install takes about 45 minutes on a modern machine
Cinderella installed successfully
[Sun, 21 Nov 2010 11:50:39 -0400] INFO: Setting the run_list to ["homebrew", "homebrew::dbs", "homebrew::misc", "ruby", "ruby::irbrc", "node", "python"] from JSON
mysql -uUSER -pPASSWORD
mysql> source /home/jpadilla/dump001.sql
// Scraping Made Easy with jQuery and SelectorGadget
// (http://blog.dtrejo.com/scraping-made-easy-with-jquery-and-selectorga)
// by David Trejo
//
// Install node.js and npm:
// http://joyeur.com/2010/12/10/installing-node-and-npm/
// Then run
// npm install jsdom jquery http-agent
// node numresults.js
//
@jpadilla
jpadilla / gist:834329
Created February 18, 2011 20:15
Re-calculate's primary index id
set @primary_key := 0;
UPDATE `table_name` SET `id` = @primary_key := @primary_key + 1 ORDER BY `id`;
# SupperfeedrPshb
require 'httparty'
module SuperfeedrPshb
class SuperfeedrPshb
include HTTParty
attr_accessor :hub, :auth, :callback_root
base_uri nil
def initialize(username, password, callback_root, hub = "http://superfeedr.com/hubbub")
#!/bin/bash
# To run do: curl https://theurl.com/bootstrap.sh | bash && source ~/.profile
#
# Based on Amazon EC2 AMI ID ami-ccf405a5 Ubuntu Server 10.10
# This script must install the following requirements
# * apache2
# * mod_wsgi
# * mysql
# * pip
#!/bin/bash
# To run do:
# wget http://url.com/bootstrap.sh && chmod +x bootstrap.sh && ./bootstrap.sh && source ~/.profile
#
# Based on Amazon EC2 AMI ID ami-ccf405a5 Ubuntu Server 10.10
# This script will:
# * install/config apache2
# * install mod_wsgi
# * install/config nginx