Skip to content

Instantly share code, notes, and snippets.

@sposmen
sposmen / Query.sql
Created May 29, 2012 20:47 — forked from elhoyos/Query.sql
Sort by two factors
-- Todos los artículos de 'RAFA' primero ordenados por serial y luego el resto de artículos ordenados igualmente por serial.
SELECT a.* FROM articulos a LEFT JOIN (SELECT 'RAFA' COLLATE utf8mb4_general_ci AS nombre) r on r.nombre = a.usuario
ORDER BY r.nombre DESC, serial
@sposmen
sposmen / gist:3973289
Created October 29, 2012 12:38 — forked from abimaelmartell/gist:3929229
Ubuntu 12.10 setup (rbenv/rvm, janus, postgres)

Basic pre-requisites

  • Some utilities:
sudo apt-get install vim tmux git curl
  • Copy/paste from the command line:
sudo apt-get install xclip
@sposmen
sposmen / kinesis-2013-11-04.js
Last active December 29, 2015 10:29 — forked from chrishamant/kinesis-2013-11-04.js
DEPRECATED - Actually AWS-SDK-JS has kinesis support

Its relatively easy to stub in support for new services using their sdks. I have an application I'm trying this service out with and have stubbed rudimentary support for this service.

Just fetch this library locally, install the deps and npm link it.

  • copy kinesis-2013-11-04.js to lib/services/api/kinesis-2013-11-04.js
  • copy kinesis.js to lib/services/kinesis.js
  • you'll also need to add the line 'require('./services/kinesis');' to lib/services.js Since this is a json based api this pretty much works how I want it - only nag is I have to manually base64 encode/decode a Buffer for the 'Data' field of 'putRecord'

The service definition is really woefully incomplete with only input parameters specified for 'createStream','describeStream','getNextRecords','getShardIterator','listStreams' and 'putRecord' - you'll have to add the parameters for the other operations yourself if needed. I didn't waste too much time doing this cause I'm pretty sure this stuff just gets automagically generated from a service defin

@sposmen
sposmen / browser_helper.js
Last active August 29, 2015 13:59 — forked from todoubled/spec_helper.coffee
Emulate browser inside nodejs
var window;
if (typeof window === "undefined" || window === null) {
window = {};
}
if (typeof jQuery === "undefined" || jQuery === null) {
global.$ = require('jquery');
}
// Connect to origin db
use some_database; // This will be named db
// Connecto to destiny db2
db2 = db.getSiblingDB('some_other_db');
// Only if needed clean destiny collection
db2.some_or_other_collection.remove({});
// Search all origin collection and copy each to destiny collection
'use strict';
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;
}
UrlAdapter.prototype.parse = urlLib.parse;
@sposmen
sposmen / crawler.py
Last active August 29, 2015 14:05 — forked from Azazeo/crawler.py
MAX_THREADS = 5
delay = 0.5
import psycopg2
import re
import sys
import time
import threading
import urllib2
import urlparse
var net = require('net');
var clients = [];
net.createServer(function (socket) {
clients.push(socket);
socket.on('data', function (data) {
broadcast(data, socket);
});

#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.