Skip to content

Instantly share code, notes, and snippets.

View naufraghi's full-sized avatar

Matteo Bertini naufraghi

View GitHub Profile
# This is the "normal" way
class C(object):
def __init__(self):
self._x = None
@property
def x(self):
return self._x
@x.setter # will copy C.x and add the setter
def x(self, value):
self._x = value
@naufraghi
naufraghi / .vimrc
Created October 9, 2013 14:48
naufraghi: move easily in tags tag->first, tselect->list, tjump->list-if-more-than-one
" naufraghi: move easily in tags
" tag->first, tselect->list, tjump->list-if-more-than-one
map <silent><C-Right> :exec("tjump ".expand("<cword>"))<CR>
map <silent><C-Left> :pop<CR>
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# http://www.bradshawenterprises.com/blog/2008/5-ways-to-make-using-bash-more-productive/
# erase old dups and skip commands starting with spaces
export HISTCONTROL="ignorespace:ignoredups"
<!DOCTYPE html>
<html>
<head>
<title>Scola la pasta</title>
<style type='text/css'>
@import url(http://fonts.googleapis.com/css?family=Krona+One);
h1 {
font-family: 'Krona One', sans-serif;
font-size: 8em;
font-size: 8vm;
@naufraghi
naufraghi / backup-google-authenticator.py
Last active July 10, 2020 20:11
Script to backup Google Authenticator secrets as QR-codes
#!/usr/bin/env python3
# Copyright 2014 Matteo Bertini [email protected]
# Released as Public Domain
#
# Latest version:
# wget http://slug.it/backup-google-authenticator.py
#
# Requirements
# ============
#
@naufraghi
naufraghi / retry.py
Created June 12, 2014 12:41
Generic Python retry decorator
def retry(func, exception=Exception, num=3, wait=0.5):
"""
Example usage:
f = retry(open, IOError, num=3, wait=0.5)(file_path, 'w')
"""
def _retry(*args, **kwargs):
c = num
while True:
c = c-1
try:
@naufraghi
naufraghi / android_sdk.yml
Created August 8, 2014 07:23
Ansible Playbook for Android SDK + gradle on c9.io
---
- hosts: local
sudo: yes
vars:
home: "{{ lookup('env','HOME') }}"
tasks:
- name: enable multiarch
command: dpkg --add-architecture i386
- name: install deps
apt: name={{ item }} update_cache=yes cache_valid_time=3600
@naufraghi
naufraghi / keybase.md
Created September 18, 2014 09:42
Keybase proof

Keybase proof

I hereby claim:

  • I am naufraghi on github.
  • I am naufraghi (https://keybase.io/naufraghi) on keybase.
  • I have a public key whose fingerprint is C01B A13F 5190 29A7 82E1 975A C4D1 A495 B316 6AF3

To claim this, I am signing this object:

from PyQt4.Qt import *
def teeSignal(*sig_args, **kwargs):
if "name" not in kwargs:
raise ValueError("Signal name required for old style emit compatibility")
class X(QObject):
signal = pyqtSignal(*sig_args, **kwargs)
x = X()
sig_name = kwargs["name"]
has_args = len(sig_args) > 0

elm-package-search

This script is a simple jq wrapper to search Elm packages.

Elm packages use the pattern <username>/<packagename> but for me is quite usual to remember only the package name.

This is a fast and dirty solution built upon the fantastic jq tool.

Analytics