Skip to content

Instantly share code, notes, and snippets.

@alepez
alepez / loop.js
Created February 4, 2014 10:14
requestAnimationFrame and time since last frame (seconds)
var Loop = function (step) {
var self = this;
var lastFrameTimestamp = null;
var nextStep = function (timestamp) {
if (lastFrameTimestamp === null) {
lastFrameTimestamp = timestamp;
}
var tslf = timestamp - lastFrameTimestamp;
step(tslf);
lastFrameTimestamp = timestamp;
@alepez
alepez / jquery-boilerplate.js
Created February 4, 2014 11:52
jquery plugin boilerplate
/*global jQuery:true*/
// jQuery Plugin Boilerplate
// A boilerplate for jumpstarting jQuery plugins development
// by Alessandro Pezzato
// Original author: Stefan Gabos http://stefangabos.ro/jquery/jquery-plugin-boilerplate-revisited/
//
// remember to change every instance of "pluginName" to the name of your plugin!
(function ($) {
@alepez
alepez / client.js
Last active September 3, 2022 11:04
nodejs file transfer with http post
var request = require('request');
var path = require('path');
var fs = require('fs');
var filename = process.argv[2];
var target = 'http://localhost:3000/upload/' + path.basename(filename);
var rs = fs.createReadStream(filename);
var ws = request.post(target);

Livereload + NodeWebkit

Aggiungere questo a myproject/index.html

  <script src="http://localhost:35729/livereload.js"></script>

Eseguire questi comandi:

sudo npm install -g livereload

cd myproject

@alepez
alepez / hide_system_bar.java
Created April 2, 2014 10:50
Android: hide system bar (kiosk mode) [ROOT]
try {
String command = "LD_LIBRARY_PATH=/vendor/lib:/system/lib service call activity 42 s16 com.android.systemui";
Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", command }, null);
proc.waitFor();
} catch (java.io.IOException e) {
e.printStackTrace();
} catch (java.lang.InterruptedException e) {
e.printStackTrace();
}
@alepez
alepez / gist:9935270
Created April 2, 2014 14:27
Raspberry silent boot: console, logo.nologo, logleve
dwc_otg.lpm_enable=0 console=tty3 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait loglevel=3 logo.nologo
@alepez
alepez / raspi-sd.sh
Created June 18, 2014 11:02
backup/resume sd with three partitions (boot, system, contents). Made for Rapsberry Pi
#!/bin/bash
ACTION=$1
SRC=$2
DST=$3
function pull {
mkdir "${DST}"
cd "${DST}"
mkdir mnt mnt/1 mnt/2 mnt/3
@alepez
alepez / raspi-fakeclock-set.sh
Created July 16, 2014 13:36
set fake clock raspberry pi
date -u "+%Y-%m-%d %H:%M:%S" > /etc/fake-hwclock.data
@alepez
alepez / Format.h
Created July 25, 2014 11:03
Create a string as printf do
#ifndef FORMAT_H_
#define FORMAT_H_
#include <string>
#include <cstdarg>
#include <cstdio>
class Format: public std::string {
public:
inline Format(const char* format, ...) {
@alepez
alepez / profile_sync.sh
Last active August 29, 2015 14:04
sync browser profile (saves ssd)
#!/bin/bash
BROWSER=$2
PERMANENT_DIR=$3
function resume {
rm ${PERMANENT_DIR}
mv ${PERMANENT_DIR}.backup ${PERMANENT_DIR}
}