Skip to content

Instantly share code, notes, and snippets.

@cakebaker
cakebaker / gist:823574
Created February 12, 2011 07:11
Nicer interface for removing query string params with Node.js
var urlLib = require('url');
function UrlAdapter(urlString) {
this.urlObj = urlLib.parse(urlString, true);
// XXX remove the search property to force format() to use the query object when transforming the url object to a string
delete this.urlObj.search;
}
exports.UrlAdapter = UrlAdapter;
@markoa
markoa / deploy.rb
Created October 10, 2011 13:31
Ingredients to monitor Resque with God automatically via Capistrano (on Ubuntu)
namespace :deploy do
desc "Hot-reload God configuration for the Resque worker"
task :reload_god_config do
sudo "god stop resque"
sudo "god load #{File.join(deploy_to, 'current', 'config', 'resque-' + rails_env + '.god')}"
sudo "god start resque"
end
end
# append to the bottom:
window = {} unless window?
global.$=require('jquery') unless jQuery?
global._=require('underscore') unless _?
global.Backbone=require('backbone') unless Backbone?
global.Mustache=require('../lib/mustache') unless Mustache?
global.localStorage=require('localStorage') unless localStorage?
global.Store=require('../lib/backbone.localStorage') unless Store?
global.jsdom = require("jsdom").jsdom
global.document = jsdom('<html><body></body></html>')
global.window = document.createWindow()
@tkihira
tkihira / gist:2367067
Created April 12, 2012 13:02
rmdir recursively in node.js
var fs = require("fs");
var path = require("path");
var rmdir = function(dir) {
var list = fs.readdirSync(dir);
for(var i = 0; i < list.length; i++) {
var filename = path.join(dir, list[i]);
var stat = fs.statSync(filename);
if(filename == "." || filename == "..") {
@sposmen
sposmen / rsync-ssh.md
Last active October 23, 2020 08:15
Rsync con ssh, o sea para que no pida contraseñas, es decir,con certificados

Realizar backups de manera facil con rsync y ssh Enviado por RazaMetaL el Mié, 2007-02-14 14:27. Tengo dos servidores, uno tiene un eggdrop que guarda el log de actividad de un canal en /home/bot/logs/canal. Hasta ahi todo esta muy bien, pero requiero que esos logs se publiquen en un sitio web que se encuentra en otro servidor.

La manera mas sencilla y practica que encontre para hacer esta tarea fue usando rsync para sincronizar los archivos de log desde un servidor a otro y que solo se copien los archivos nuevos o modificados.

Primero vamos a decidir las opciones para rsync, en mi caso y como lo explico en el parrafo anterior requiero copiar todos los archivos al nuevo servidor, despues que copie solo los nuevos archivos y/o los modificados. Todo esto lo logro pasando las opciones -avz y -e ssh a rsync.

-a para copiar recursivamente manteniendo privilegios, fecha de creacion, permisos, etc.;

@icodejs
icodejs / highchartsDraggable.js
Created October 25, 2012 08:34
JS: Highcharts draggable shim
// http://jsfiddle.net/icodejs/TAVz5/
(function(Highcharts) {
var
addEvent = Highcharts.addEvent,
each = Highcharts.each;
/**
* Filter by dragMin and dragMax
*/
@ryansobol
ryansobol / gist:5252653
Last active November 22, 2023 11:53
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

module.exports = {
format: 'json',
apiVersion: '2013-11-04',
endpointPrefix: 'kinesis',
jsonVersion: '1.1',
serviceFullName: 'Amazon Kinesis',
signatureVersion: 'v4',
targetPrefix: 'Kinesis_20131104',
timestampFormat: 'iso8601',
operations: {
@Azazeo
Azazeo / crawler.py
Created January 13, 2014 09:49
Crawler and data extractor for airbnb.com website
MAX_THREADS = 5
delay = 0.5
import psycopg2
import re
import sys
import time
import threading
import urllib2
import urlparse
@mdunisch
mdunisch / How you get Sail.js running on Openshift.md
Last active July 13, 2023 14:51
Get Sails.js running on Openshift

#How you get Sail.js running on Openshift#

This instruction is tested with:

  • Sails.js v0.9.16
  • Node.js 0.10 on Openshift ( 05 May 2014)

###1) package.json

If you use the package.json build by sails new Projectname than you have to add a few fields for openshift – so the server can start you app automatically. Sails uses Grunt to build minify css/js and so on. Openshift dont have grunt installed so you have to add this also.