Skip to content

Instantly share code, notes, and snippets.

📰
mypapermag

André Laszlo andrelaszlo

📰
mypapermag
Block or report user

Report or block andrelaszlo

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
@andrelaszlo
andrelaszlo / fix_repos.sh
Last active May 18, 2017
Hack to fix a broken url using the GitHub API
View fix_repos.sh
#!/usr/bin/env bash
source token.sh # should export the ACCESS_TOKEN and USER variables
PAGE=1 # Run once per page (manually for now)
PER_PAGE=100 # Max 100
function list_repos {
echo "Listing repos" > /dev/stderr
curl -s -H "Authorization: token $ACCESS_TOKEN" "https://api.github.com/search/code?page=$PAGE&per_page=$PER_PAGE&q=http://www.eecs.harvard.edu/~kirsch/pubs/bbbf/esa06.pdf" | \
View keybase.md

Keybase proof

I hereby claim:

  • I am andrelaszlo on github.
  • I am sibilant (https://keybase.io/sibilant) on keybase.
  • I have a public key ASAKC1ZDD5z85BC8yXhLazRLqad48O593CtMoupET-WBiAo

To claim this, I am signing this object:

@andrelaszlo
andrelaszlo / activate
Last active Mar 17, 2016
Modified virtualenv2 activate script
View activate
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly
# This script was modified to introduce the following features:
# * Save and restore PYTHONPATH on activate/deactivate
# * Source .virtualenvrc if it exists
deactivate () {
unset pydoc
@andrelaszlo
andrelaszlo / drop_shell.py
Created Nov 3, 2014
Start interactive shell inside pythons cript
View drop_shell.py
def drop_shell(global_vars, local_vars):
""" Call with drop_shell(global_vars().copy(), locals()) """
import readline # optional, will allow Up/Down/History in the console
import code
global_vars.update(local_vars)
shell = code.InteractiveConsole(global_vars)
shell.interact()
@andrelaszlo
andrelaszlo / dc_sum.py
Last active Aug 29, 2015
Python version of the dc command found here http://stackoverflow.com/a/453290/98057
View dc_sum.py
### Implement some commands from dc
registers = {'r': None}
stack = []
def add():
stack.append(stack.pop() + stack.pop())
def z():
stack.append(len(stack))
def less(reg):
if stack.pop() < stack.pop():
registers[reg]()
@andrelaszlo
andrelaszlo / argparse_interactive.py
Created Oct 31, 2014
Incomplete example function that lets a user fill out the parameters for an ArgumentParser interactively
View argparse_interactive.py
def run_interactive(parser):
"""Inspect the argument parser and let the user decide on values for
all parameters interactively.
"""
args = []
print "You are running this script in interactive mode. " + \
"Press C-d to abort. Run with --help to see more options."
try:
@andrelaszlo
andrelaszlo / personnummer.js
Created Jun 26, 2012
Function that checks if a swedish personnummer is valid
View personnummer.js
/*
* Function that checks if a swedish personnummer is valid.
* Author: André Laszlo <andre@laszlo.nu>
*/
function check_personnummer(pnr) {
// Do formatting and sanity control
pnr = pnr.replace(/[^0-9]/g, ''); // only keep digits
if (12 == pnr.length) // year format 1985 → 85
pnr = pnr.substr(2);
@andrelaszlo
andrelaszlo / password.py
Created Jun 14, 2012
Generate a truly random password, based on atmospheric noise (random.org!)
View password.py
#!/usr/bin/python
###############################################################################
#
# Script for generating a truly random password, using atmospheric noise. The
# generator uses the web service at random.org
#
# Usage:
# password.py [password length] [alphabet]
# For example: password.py 5 abcdefgh
@andrelaszlo
andrelaszlo / duego-preregister.user.js
Created Apr 26, 2012
Show desktop notification (chrome) when the duego.com pre-register page updates
View duego-preregister.user.js
// ==UserScript==
// @match http://duego.com/preregister*
// @require http://code.jquery.com/jquery-1.4.2.min.js
// ==/UserScript==
var load,execute,loadAndExecute;load=function(a,b,c){var d;d=document.createElement("script"),d.setAttribute("src",a),b!=null&&d.addEventListener("load",b),c!=null&&d.addEventListener("error",c),document.body.appendChild(d);return d},execute=function(a){var b,c;typeof a=="function"?b="("+a+")();":b=a,c=document.createElement("script"),c.textContent=b,document.body.appendChild(c);return c},loadAndExecute=function(a,b){return load(a,function(){return execute(b)})};
loadAndExecute("//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js", function() {
function Notifier() {};
View kombinationer.html
<html>
<head><title>Kombinationer</title></head>
<body>
<script>
// shorthand function
function $(id) {
return document.getElementById(id);
}
You can’t perform that action at this time.