Skip to content

Instantly share code, notes, and snippets.

View lusentis's full-sized avatar

Simone Lusenti lusentis

View GitHub Profile
apm install sync-settings
@lusentis
lusentis / merge.sh
Last active October 21, 2015 17:58
cloudformation-mixins
#!/bin/bash
set -e
STAGE=$1
if [ ! "$STAGE" ]; then
echo "Usage: $0 <stage>"
exit 1
fi
@lusentis
lusentis / Jakefile
Last active August 29, 2015 14:27
Lambda Toolkit
/*eslint quotes: [0] */
/*global desc, task, watchTask, complete, jake */
var assert = require('assert');
assert(process.env.NODE_ENV, 'NODE_ENV must be set');
var EXEC_OPTS = { printStdout: true, printStderr: true };
desc('Build the source with webpack');
task('build', { async: true }, function () {
@lusentis
lusentis / textnazi.js
Last active August 29, 2015 14:10
Fixup text typed by dumb italian people
/*jshint node:true, esnext:true */
'use strict';
module.exports.police = function (text) {
if (!text) { return ''; }
text = text.replace(/(\s|&nbsp;)+/g, ' '); // compact multiple places
text = text.replace(/e'\s+/g, 'è '); // apos -> accent
text = text.replace(/o'\s+/g, 'ò ');

Keybase proof

I hereby claim:

  • I am lusentis on github.
  • I am slusenti (https://keybase.io/slusenti) on keybase.
  • I have a public key whose fingerprint is B9FB B8B3 7D30 F2F6 1AB8 1168 11A0 1A91 E12B 1737

To claim this, I am signing this object:

# -.- coding: utf-8 -.-
import json
import urllib2
import predictionio
client = predictionio.Client(appkey="XXXXXXXXXXXXXXXXXXXXXXX")
total = 6028561
size = 1000
@lusentis
lusentis / gist:9120366
Last active August 29, 2015 13:56
automagically setup python & nodejs workspace
#!/bin/bash
if [ -f ".virtualenvname" ]; then
echo "~ detected python project ~"
echo "~ switcing to virtualenv $(cat .virtualenvname)"
workon $(cat .virtualenvname)
pip install -r requirements.txt
fi
@lusentis
lusentis / makePassword.js
Created February 10, 2014 11:55
Make a random password
'use strict';
var PASS_LENGTH = [1, 4, 2];
var _makePassword = module.exports.makePassword = function () {
var a = [
'ABCDEFGHJKMNPQRSTUVXZ',
'abcdefghjkmnpqrstuvxz',
'23564789'
].map(function (i) { return i.split(''); });
@lusentis
lusentis / version.txt
Created January 22, 2014 14:16
version.txt example
0.1.2
@lusentis
lusentis / findport.sh
Created January 16, 2014 11:40
bash script to find a free port to listen to
#!/bin/bash
#
# Please run as root.
# Usage: bash findport.sh 3000 100
#
if [[ -z "$1" || -z "$2" ]]; then
echo "Usage: $0 <base_port> <increment>"
exit 1