Skip to content

Instantly share code, notes, and snippets.

@pencil
pencil / script.js
Last active December 6, 2021 22:35
GitHub: Set merge message to PR title and description
// ==UserScript==
// @name GitHub: Set merge message to PR title and description
// @namespace https://github.com/pencil
// @version 0.6
// @description Set the default GitHub merge title and description to the one of the PR itself.
// @author Nils Caspar
// @match https://github.com/*
// @icon https://github.githubassets.com/favicons/favicon.png
// @grant none
// @downloadURL https://gist.githubusercontent.com/pencil/51460c59d4c21e10e2d33f1a7208db04/raw/script.js

Keybase proof

I hereby claim:

  • I am pencil on github.
  • I am user (https://keybase.io/user) on keybase.
  • I have a public key whose fingerprint is 015F D8BF 7EB7 5A7C 3791 A258 63B9 F5D7 3BF3 4514

To claim this, I am signing this object:

IEC_PREFIXES = ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi']
SI_PREFIXES = ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']
def human_readable_size(size, precision = 2, use_iec_prefix = false)
size = size.to_f
if use_iec_prefix
prefixes = IEC_PREFIXES
base = 1024
else
prefixes = SI_PREFIXES
base = 1000

Navigating

visit('/projects')
visit(post_comments_path(post))

Clicking links and buttons

#!/usr/bin/env sh
if ! which md5sum > /dev/null; then
echo Install md5sum
exit 1
fi
if ! which curl > /dev/null; then
echo Install curl
exit 1
@pencil
pencil / syncscript.rb
Last active October 12, 2015 14:37 — forked from petermanser/syncscript.sh
HSR Syncscript (Ruby)
#!/usr/bin/env ruby
require 'fileutils'
require 'optparse'
SOURCEDIR='/Volumes/root/skripte'
DESTDIR="/Users/#{ENV['USER']}/Dropbox/Documents/HSR/Semester5/skripte"
MAX_SIZE='20m'
Subject = Struct.new :source, :destination, :parameters
@pencil
pencil / RandomSort.java
Last active April 10, 2023 13:57
Random Sort (bogosort, stupid sort) implementation in Java
public class RandomSort {
public RandomSort(int[] i) {
int counter = 0;
System.out.println("I'll sort " + i.length + " elements...");
while (!isSorted(i)) {
shuffle(i);
counter++;
}
System.out.println("Solution found! (shuffled " + counter + " times)");