Skip to content

Instantly share code, notes, and snippets.

View gpestana's full-sized avatar
🧑‍🚀
the future is now

Gonçalo Pestana gpestana

🧑‍🚀
the future is now
View GitHub Profile
var zmq = require('zmq');
var ip = require('ip')
var port = 'tcp://'+process.argv[2]
var cli_sock = zmq.socket('dealer');
var srv_sock = zmq.socket('router')
var recv_port = 'tcp://'+ip.address()+':2222'
cli_sock.identity = recv_port
cli_sock.connect(port)
@gpestana
gpestana / gist:d040412efe89f1160282
Last active August 29, 2015 14:14
opensource js code quality & team tools
package.json ===
{
"name": "",
"version": "",
"description": "",
"main": "",
"scripts": {
"codestyle": "./node_modules/.bin/jscs src/index.js tests/*.js",
"lint": "./node_modules/.bin/jshint .",
def solution(A):
eqIndex = []
sums = [0]*len(A)
sums[0]=A[0]
for index, val in enumerate(A):
if index!=0:
sums[index]=sums[index-1]+A[index]
print sums
@gpestana
gpestana / gist:bdc554631e08005f97f5
Created February 16, 2015 11:46
detectIntruder
#!/usr/bin/python
import fileinput
def detectIntruder(str):
arr = list(str)
i, j = 0, len(arr)-1
while i <= j:
if arr[i] != arr[j]:
if arr[i] == arr[j-1]:
@gpestana
gpestana / gist:7a30bd699dfaf833c141
Created February 16, 2015 13:46
First Missing Positive
class Solution:
def firstMissingPositive(self, arr):
if not arr:
return 1
res = checkArrayComplete(arr)
if res:
return res
else:
return checkFirstMissing(arr)
//in initDb.js
var DB = require('mongodb').Db,
client = require('mongodb').MongoClient
var remoteURI = 'mongodb://user:user@ds029950.mongolab.com:29950/scheduler'
var db = 'not ready'
var connect = function(remoteURI, cb) {
client.connect(remoteURI, function(err, db_res) {
server {
listen 8080 default_server;
server_name domain.co www.domain.co;
#fallback to europe
set $site eu.domain.com;
if ($geoip_country_code = PT) {
set $site domain.co/us;
}
@gpestana
gpestana / gist:2dac6bf1b9ef9b96c5a7
Created March 11, 2015 15:32
NGINX redirection
server {
listen 8080 default_server;
server_name slushed.co www.slushed.co;
#logging
access_log /home/user/www/slushed.co/logs/access.log;
error_log /home/user/www/slushed.co/logs/error.log error;
#fallback to europe
define(['settings'],
function (Settings) {
"use strict";
return new Settings({
datasources: {
influx: {
default: true,
type: 'influxdb',
@gpestana
gpestana / virtualbox
Created June 30, 2015 02:30
virtualbox headers
gpestana@workstation:/$ ls /usr/src/
linux-config-3.16 linux-headers-3.16.0-4-amd64 linux-source-3.16.tar.xz
linux-headers-3.13.0-4 linux-headers-3.16.0-4-common vboxhost-4.3.28
linux-headers-3.13.0-4-generic linux-kbuild-3.16
gpestana@workstation:~/inst$ uname -a
Linux workstation 3.13-1-amd64 #1 SMP Debian 3.13.5-1 (2014-03-04) x86_64 GNU/Linux
gpestana@workstation:~/inst$ sudo dpkg -i virtualbox-4.3_4.3.28-100309~Debian~wheezy_amd64.deb