Skip to content

Instantly share code, notes, and snippets.

View fabiomontefuscolo's full-sized avatar

Fabio Montefuscolo fabiomontefuscolo

View GitHub Profile
@fabiomontefuscolo
fabiomontefuscolo / input-inspector.sh
Created August 7, 2015 21:25
Run command passing files throught pipe and redirections to see from where you should read
#!/bin/bash
script_id="$$";
files=`find /proc/$script_id/fd -not -type d`;
for file in $files;
do
echo $file && ls -l $file
if [ -a "$file" ]; then echo $file' -a - True if file exists.'; fi
@fabiomontefuscolo
fabiomontefuscolo / Default (Linux).sublime-keymap
Created September 26, 2014 20:14
My Sublime 3 conf files.
[
{ "keys": ["ctrl+k", "ctrl+m"], "command": "md5fy" },
{ "keys": ["ctrl+k", "ctrl+n"], "command": "numbering" }
]
@fabiomontefuscolo
fabiomontefuscolo / md5fy.py
Created September 25, 2014 20:59
Sublime3 command that replace selected strings by their md5 hashes.
# -*- coding: utf-8 -*-
import hashlib
import sublime
import sublime_plugin
class Md5fyCommand(sublime_plugin.TextCommand):
def run(self, edit, *args):
for region in self.view.sel():
if not region.empty():
@fabiomontefuscolo
fabiomontefuscolo / Array.group.js
Last active August 29, 2015 14:06
Groups elements of array
// http://jsfiddle.net/montefuscolo/ogtzpt4t/
Object.defineProperty(
Array.prototype,
'group',
{
enumerable: false,
value: function (n) {
var initial = [
[]
@fabiomontefuscolo
fabiomontefuscolo / Code.gs
Created August 15, 2014 14:43
Export a Google Spreadsheet as JSON Webapp
/**
* I'm not author of this script. The author (I guess) can be found
* at http://pipetree.com/qmacro/blog/2013/10/sheetasjson-google-spreadsheet-data-as-json/
*/
function doGet(request) {
var output = ContentService.createTextOutput();
var data = {};
var id = request.parameters.id;
var sheet = request.parameters.sheet;
var ss = SpreadsheetApp.openById(id);
@fabiomontefuscolo
fabiomontefuscolo / jquery-django-csrf.js
Created July 31, 2014 15:09
Configure jQuery to send 'X-CSRFToken' required by Django. With this piece of code loaded after jQuery, it's not necessary to config headers in every jQuery.post against Django.
(function($){
if(!$) {
return;
}
var match = document.cookie.match(/csrftoken=(\w+)/);
var token = match ? match[1] : '';
$.ajaxSetup({
headers: { 'X-CSRFToken': token }
#!/usr/bin/env bash
# Send UPnP message
#
# @param 1 - host:port/query (optional when UPNP_URL is set)
# @param 2 - service#action (optional when UPNP_ACTION is set)
# @param 3 - message arguments in XML format (optional)
upnp_send()
{
# prefer arguments over presets
@fabiomontefuscolo
fabiomontefuscolo / fallback-to-less.html
Created May 7, 2014 14:25
In HTML5 page, I try to load a CSS generated by Less. When the CSS does not exist, I fallback to Less file.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Fallback to Less</title>
<script type="text/javascript">
function fallbackToLess(){
var script = document.createElement('script');
script.src = "js/libs/less-1.7.0.min.js";
@fabiomontefuscolo
fabiomontefuscolo / sources.list
Created April 11, 2014 19:48
sources.list for ubuntu 8.10
deb http://old-releases.ubuntu.com/ubuntu/ intrepid main restricted
deb-src http://old-releases.ubuntu.com/ubuntu/ intrepid main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://old-releases.ubuntu.com/ubuntu/ intrepid-updates main restricted
deb-src http://old-releases.ubuntu.com/ubuntu/ intrepid-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://old-releases.ubuntu.com/ubuntu/ intrepid universe
@fabiomontefuscolo
fabiomontefuscolo / desobsfuscahouaiss.py
Created February 26, 2014 17:40
remove obsfucação dos arquivos do dicionário houaiss
#!/usr/bin/python2
# -*- coding: utf-8 -*-
#
# Coloque esse script na pasta com os arquivos dhx.
# O resultado estará em iso-8859-1
#
#
# Segui o tutorial em http://www.caloni.com.br/blog/archives/conversor-de-houaiss-para-babylon-parte-1