Skip to content

Instantly share code, notes, and snippets.

@asiletto
asiletto / mp3tomp4.bat
Last active August 29, 2015 13:57
convert mp3 to mp4 with ffpmeg
@echo off
IF "%~4"=="" GOTO showusage
ffmpeg -loop 1 -i %1 -t %4 silent.mp4
ffmpeg -i silent.mp4 -i %2 -vcodec copy -acodec copy %3
del silent.mp4
GOTO end
:showusage
@asiletto
asiletto / DisegnaAlianti.java
Created March 16, 2014 15:28
test gliderbot per app meteor Giuliano
package test;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import me.kutrumbos.DdpClient;
import me.kutrumbos.examples.SimpleDdpClientObserver;
java -classpath sync.jar;commons-cli-1.1.jar;commons-codec-1.3.jar;
commons-httpclient-3.0.jar;commons-logging-1.0.4.jar;icu4j-3_8.jar;
icu4j-charsets-3_8.jar;rcleartool.jar;remote_core.jar;stpcc.jar;
stpclientws.jar;stpcmmn.jar;stpcq.jar;stpwvcm.jar;teamapiextensions.jar;
ucleardiffmerge.jar;unicodetypemgr.jar; test.Sync
@asiletto
asiletto / etc-init.d-templog
Created March 29, 2014 18:14
init script for rpi temp logger & terrarium controller
#! /bin/sh
# /etc/init.d/templog
# ### BEGIN INIT INFO
# Provides: templog
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
@asiletto
asiletto / NetTail.java
Last active August 29, 2015 14:00
tail over http with java
package test;
import java.io.InputStream;
import java.net.URL;
import java.util.List;
import org.apache.commons.io.IOUtils;
import org.apache.http.Header;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
@asiletto
asiletto / hosts
Last active August 29, 2015 14:01
block skype ads
# Block skype ads
127.0.0.1 apps.skype.com
@asiletto
asiletto / htaccess
Last active August 29, 2015 14:02
enable CORS on drupal 7
<IfModule mod_headers.c>
#CORS
SetEnvIf Origin "^http(s)?://(.+\.)?(siletto\.it|localhost|localhost2)$" DYN_ORIGIN=$0
Header set Access-Control-Allow-Origin %{DYN_ORIGIN}e
Header set Access-Control-Allow-Methods "GET, PUT, POST, OPTIONS"
Header set Access-Control-Allow-Credentials true
Header set Access-Control-Allow-Headers "Authorization, Origin, Content-Type, X-CSRF-Token"
...
...
</IfModule>
@asiletto
asiletto / enable_mod_headers.sh
Created June 3, 2014 14:12
enable mod headers on apache2
# a2enmod headers
# /etc/init.d/apache2 restart
@asiletto
asiletto / cors.js
Last active August 29, 2015 14:02
jquery/Drupal/restws CORS example
var username = "admin";
var password = "passw";
console.log("authentication...")
$.ajax({
url:"http://my.host/restws/session/token-cors",
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
},
xhrFields: {
@asiletto
asiletto / android dp.java
Created July 23, 2014 15:57
Get width height and orientation in android
Display display = getWindowManager().getDefaultDisplay();
DisplayMetrics outMetrics = new DisplayMetrics();
display.getMetrics(outMetrics);
float density = getResources().getDisplayMetrics().density;
float dpHeight = outMetrics.heightPixels / density;
float dpWidth = outMetrics.widthPixels / density;
Log.d("SIZE","height: "+dpHeight+"dp, width:"+dpWidth+"dp, orientation:"+display.getRotation());