Skip to content

Instantly share code, notes, and snippets.

View lusentis's full-sized avatar

Simone Lusenti lusentis

View GitHub Profile
@lusentis
lusentis / rc.local
Created November 19, 2012 17:28
rc.local for autodeploy with user-data
BATTAHOME=/home/battaglia
ENVFILE=$BATTAHOME/env.sh
userdata=`curl http://169.254.169.254/2007-08-29/user-data`
repourl=`echo "$userdata" | head -n 1`
envurl=`echo "$userdata" | tail -n 1`
echo -e "\n===> Downloading env from $envurl"
wget "$envurl" -O $ENVFILE
#!/bin/bash
if [ "$(whoami)" != "root" ]
then
echo "Please run as root"
exit 1
fi
echo -en "Application name => "
@lusentis
lusentis / index.html
Last active December 11, 2015 18:39
CSS3 Rotate demo
<html>
<head>
<style type="text/css">
.box {
width: 200px;
height: 200px;
background-color: white;
border: 1px solid red;
position: absolute;
top: 100px;
@lusentis
lusentis / pandapicker.js
Last active December 11, 2015 21:48
panda picker - compiled - always visible - added current class
(function(moment, $) {
var cssPrefix, dayNames, template_html;
cssPrefix = 'pandapicker-';
dayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
template_html = "<table role=\"datepicker\">\n <thead>\n <tr>\n <th class=\"" + cssPrefix + "prev\" role=\"prevMonth\">&laquo;</th>\n <th class=\"" + cssPrefix + "title\" colspan=\"5\" role=\"title\"></th>\n <th class=\"" + cssPrefix + "next\" role=\"nextMonth\">&raquo;</th>\n </tr>\n <tr>\n <th>" + dayNames[0] + "</th>\n <th>" + dayNames[1] + "</th>\n <th>" + dayNames[2] + "</th>\n <th>" + dayNames[3] + "</th>\n <th>" + dayNames[4] + "</th>\n <th>" + dayNames[5] + "</th>\n <th>" + dayNames[6] + "</th>\n </tr>\n </thead>\n <tbody>\n </tbody>\n</table> ";
return $.fn.pandaPicker = function(options) {
var init, updateCalendar,
_this = this;
options = $.extend({
format: 'DD-MM-YYYY'
@lusentis
lusentis / inc.js
Created February 1, 2013 15:57
String increment
/*jshint laxcomma:true */
var alphainc = function (l) {
if (l === '9') return 'A';
if (l === 'Z') return 'a';
if (l === 'z') return '0';
return String.fromCharCode(l.charCodeAt(0) + 1);
};
var strinc = function (s, i) {
@lusentis
lusentis / tag-do-publish.js
Last active December 14, 2015 05:49
PubSub.publish automagically attached to DOM Elements.
/*jshint browser:true, indent:2, laxcomma:true, eqnull:true */
/*
* # Tag-Do-Publish
* Attach PubSub.publish to DOM Elements actions.
* Subscribed function get e.target as the only parameter.
* The event handler always do e.preventDefault(); return false;
*
* <a href="" data-publish="click:myClickTrigger">click</a>
* <div id="dropArea" data-publish="drop:dropHandler" data-publish-usecapture>drop your files here</a>
@lusentis
lusentis / Latex.sublime-build
Created March 5, 2013 17:38
Latex (xetex) build system for Sublime Text 2
// Compilation settings
// ====================
//
// The actual magic happens in the make_pdf command
// I stick to the format of standard ST2 sublime-build files
// with minor variations.
// NOTE: the viewer is NOT configured from here!
// As of 5/24/11, it cannot be changed, but I will introduce a setting later
{
@lusentis
lusentis / instance-setup.sh
Last active December 14, 2015 14:18
Instance setup script for node / django servers
#!/bin/bash
set -e
set -x
cd ~
sudo groupadd web || true
# system upgrade
sudo apt-get update
@lusentis
lusentis / website-setup.sh
Last active December 14, 2015 14:19
website-setup.sh
#!/bin/bash
set -e
#set -x
echo "#####################################"
echo "##### PLEASE DON'T RUN DIRECTLY #####"
echo "#####################################"
echo $(date)
@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