Skip to content

Instantly share code, notes, and snippets.

View lusentis's full-sized avatar

Simone Lusenti lusentis

View GitHub Profile
@lusentis
lusentis / forever.sh
Last active January 3, 2016 08:29
Run a script forever, optionally executing a setup.sh script after each restart.
#!/bin/bash
## forever.sh
#
# Run a script forever,
# optionally executing a setup.sh
# script after each restart.
#
SLEEP_TIME=5
@lusentis
lusentis / .aliases
Last active December 26, 2015 23:39
bash/zsh aliases
# handy
alias l="xscreensaver-command -lock"
alias c="clear"
alias s="supervisor app.js"
alias n="node app.js"
# ls
alias ls="ls --color=auto"
alias la="l -a"
@lusentis
lusentis / .gitignore
Last active December 26, 2015 21:29
Simple express-like methods for connect
node_modules
npm-debug.log
#!/bin/bash
# Run this file at boot, as $USER
cd ~/app
source ~/.env-prod
forever start -w --watchDirectory . app.js
exit $?
#!/bin/bash
app=
port=
#cmd="~/.venv/bin/gunicorn_django -b 127.0.0.1:$port"
cmd="~/nodejs/bin/node app.js"
if [ ! -f ~/mon.pid ]
then
echo '0' > ~/mon.pid
@lusentis
lusentis / eo.js
Created August 16, 2013 17:42
Evented Objects for the browser
/*jshint browser:true, laxcomma:true, indent: 2, eqnull:true, devel:true */
/*global define */
define('eo', ['vendor/asEvented'], function (asEvented) {
'use strict';
var Eo = function (props, name) {
if ('string' === typeof props) {
this._fromJSON(props);
} else {
@lusentis
lusentis / makePassword.js
Last active December 20, 2015 13:29
Hashes an user-entered password.
/*jshint node:true */
'use strict';
var bcrypt = require('bcrypt')
, read = require('read');
read({ prompt: 'Password (typing will be hidden): ', silent: true, replace: '*' }, function (err, pass) {
var hash = bcrypt.hashSync(pass, 12);
process.stdout.write(hash + '\n');
@lusentis
lusentis / coolog_logentries.js
Last active December 19, 2015 12:49
Push log messages collected from coolog to Logentries
if (LOGENTRIES_APIKEY) {
var logentries_logger = logentries.logger({
token: LOGENTRIES_APIKEY
});
coolog.on('log', function (severity, args) {
var _logger
, le_severity;
if (severity === 'debug') {
@lusentis
lusentis / ApollonianGasket.js
Last active December 18, 2015 18:09
ApollonianGasket generator for node.
/*jshint node:true, laxcomma:true, indent:2, white:true, curly:true, plusplus:true, undef:true, strict:true, trailing:true */
'use strict';
/*
* LICENSE (MIT)
* =============
*
* Copyright © 2013 Plastic Panda & others
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
@lusentis
lusentis / example.js
Created May 28, 2013 15:50
Simple router for the browser.
var routes = {
'/login': login
, '/admin': adminIndex
, '/404': function () { alert('404 not found'); router.navigate('/'); } // mandatory
};
var router = new Router(routes);
router.attach();
router.initial('/login', true); // Forces going to login