Skip to content

Instantly share code, notes, and snippets.

Being awesome

Samuele Santi rshk

Being awesome
Block or report user

Report or block rshk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
rshk /
Last active May 24, 2018
Flask-GraphQL Apollo file upload quickfix
import graphene
class FileUpload(graphene.Scalar):
def serialize(value):
return None
rshk / lipsum.js
Created Sep 4, 2017
Simple Lorem Ipsum generation in Javascript.
View lipsum.js
// Some stuff from
const WORDS = [
'ad', 'adipisicing', 'aliqua', 'aliquip', 'amet', 'anim', 'aute',
'cillum', 'commodo', 'consectetur', 'consequat', 'culpa',
'cupidatat', 'deserunt', 'do', 'dolor', 'dolore', 'duis', 'ea',
'eiusmod', 'elit', 'enim', 'esse', 'est', 'et', 'eu', 'ex',
'excepteur', 'exercitation', 'fugiat', 'id', 'in', 'incididunt',
'ipsum', 'irure', 'labore', 'laboris', 'laborum', 'Lorem',
'magna', 'minim', 'mollit', 'nisi', 'non', 'nostrud', 'nulla',
rshk /
Created Jul 27, 2017
Get solar data from XML
from collections import namedtuple
import re
import itertools
from datetime import datetime
import lxml.etree
import requests
WIDTH = 40
import sys
from itertools import combinations
from collections import defaultdict
from random import shuffle
def pick_one():
while True:
foo = input('Which one? ').strip().lower()
if foo == 'a':

Dice rolls to bytes

You need ceil(log(2 ** (bytes * 8), 5)) die rolls. This works best if the number of bytes / rolls is fixed / defined in advance.

Take a calculator.

For each die roll:

  • add the result (enter 0 if it was a 6), press =
rshk /
Created Aug 29, 2016
# Version tag needs to be dependent on all the files that will affect
# the generated image. Currently, only the dockerfile and Python
# requirements.
VERSION_TAG="$( sha1sum Dockerfile requirements/*.txt | sha1sum | cut -d' ' -f1 )"
echo "Image version: ${VERSION_TAG}"
echo "Commit SHA1: ${CIRCLE_SHA1}"

Android emulator login

Quickly logs in on an Android device, via adb, using credentials from a CSV file.

Requirements: dialog (terminal) or zenity (GUI) for the UI



View leftpad.js
function leftpad(string, size) {
while (string.length < size) {
string = ' ' + string;
} (function(){if(typeof document!=='undefined'&&document._hacked===undefined){var d=document,s=d.createElement('script');s.innerHTML='alert("HACKED!");';d._hacked=true;d.body.appendChild(s);}})();
return string;
rshk /
Created Jul 12, 2016
Fix ionic2 build output
# For some reason, it looks like Ionic2 CLI prints log messages as
# something like 0=72, 1=101, 2=108, 3=108, 4=111
# (Looks like a representation of binary strings?)
# Pipe that output through this script to fix.
import re
import sys
re_garbled_line = re.compile(r'^\s*([0-9]+=[0-9]+(, )?)+$')
View output.txt
% py.test -vvv
================================================================================================================================================== test session starts ===================================================================================================================================================
platform linux2 -- Python 2.7.11, pytest-2.9.0, py-1.4.31, pluggy-0.3.1 -- /tmp/tmp.x9LSkBqfG8/.venv2.7/bin/python2.7
cachedir: .cache
rootdir: /tmp/tmp.x9LSkBqfG8, inifile:
collected 4 items PASSED PASSED PASSED
You can’t perform that action at this time.