Skip to content

Instantly share code, notes, and snippets.

View fmarani's full-sized avatar

Federico Marani fmarani

View GitHub Profile
def generate_tag_string(post_id, tags=[], new=False):
"""
...
"""
if new:
tags.append('new')
post = get_post(post_id)
post_tags = [t.decode("utf8", "ignore") for t in post.get('tags', [])]
@fmarani
fmarani / app.html
Last active May 16, 2017 22:45
control netflix
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
@fmarani
fmarani / pyside-webkit-inspector.py
Created December 5, 2014 08:48
python webkit integration test - with inspector
import sys
from PySide.QtCore import QObject, Slot, QTimer, Qt
from PySide.QtGui import QApplication, QWidget, QSplitter, QVBoxLayout, QShortcut, QKeySequence
from PySide.QtWebKit import QWebView, QWebSettings, QWebInspector
html = """
<html>
<body>
<h1>Hello!</h1><br>
@fmarani
fmarani / pyside-webkit.py
Created December 5, 2014 08:47
python webkit integration test
import sys
from PySide.QtCore import QObject, Slot, QTimer
from PySide.QtGui import QApplication
from PySide.QtWebKit import QWebView, QWebPage
import logging
html = """
<html>
<body>
@fmarani
fmarani / bkk.py
Created November 29, 2014 17:24
very simple content tracker
#!/usr/bin/env python
import sys
import os
import dbm
import json
import uuid
print("BaKKit up")
try:
op = sys.argv[1]
@fmarani
fmarani / offliner.py
Created January 19, 2013 16:55
some ideas about offline pre-computation of functions in python
import inspect
REGISTRY = []
CACHE = {}
def offline_runner():
for fn, kwargs in REGISTRY:
#print "OFFLINE", fn, kwargs
CACHE[(fn, str(kwargs))] = fn(**kwargs)
@fmarani
fmarani / language-detection.sh
Created December 13, 2011 23:38
poor man's language classifier
echo "this is a text in engish written only to demonstrate the validity of this method in selecting the right language" > corpus_en
echo "questo è un testo in italiano scritto solamente per dimostrare la validita di questo metodo nel selezionare il linguaggio voluto" > corpus_it
echo "questa è una prova di testo per testare la versione italiana" > test
(echo `cat corpus_en test | gzip | wc -c` en; echo `cat corpus_it test | gzip | wc -c` it) | sort -n | head -1
echo "this is a test for the english version"> test
(echo `cat corpus_en test | gzip | wc -c` en; echo `cat corpus_it test | gzip | wc -c` it) | sort -n | head -1
@fmarani
fmarani / pipeline.py
Created July 15, 2011 10:42
Transformation pipeline in Python
#!/usr/bin/env python
import itertools
import random
import string
import functools
# support functions
#Sample implementation of ireduce()
@fmarani
fmarani / md5chunks.py
Created May 18, 2011 14:54
calculate md5 hashes of chunks of a file, configurable block size
#!/usr/bin/env python
from optparse import OptionParser
import hashlib
import sys
parser = OptionParser()
parser.add_option("-b", "--blocksize", dest="blocksize", type=int, default=1024,
help="Specify blocksize", metavar="blocksize")
@fmarani
fmarani / monad.php
Created March 23, 2011 14:16
Monad in PHP?!
<?php
/**
* Monad boxing integer side effects
*
* @package default
* @subpackage default
* @author Federico Marani
**/
class IntegerBox
{