Skip to content

Instantly share code, notes, and snippets.

View 607011's full-sized avatar
๐Ÿ
Yes, please?!

Oliver Lau 607011

๐Ÿ
Yes, please?!
View GitHub Profile
@607011
607011 / post-receive
Created April 14, 2016 12:07
Git post-receive hook to deploy latest release to a given directory
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, os, subprocess
from datetime import datetime
oldrev, newrev, branch = sys.stdin.read().split()
refs, head, branch = branch.split('/')
deploy_to = None
@607011
607011 / backup.sh
Last active July 11, 2017 07:08
Get a password from the macOS key chain
#!/bin/bash
SRCDIR=$HOME/PUT_SOURCE_DIRECTORY_HERE
DSTDIR=$HOME/PUT_DESTINATION_DIRECTORY_HERE
REMOTE_SHARE=PUT_SERVER_NAME_HERE/PUT_NAME_OF_SHARE_HERE
KEYCHAIN_SERVICE_TOKEN=CHANGE_TO_NAME_OF_SERVICE_AS_STORED_IN_KEYCHAIN
USERNAME=ola
PASSWORD=$(security find-generic-password -s $KEYCHAIN_SERVICE_TOKEN -w)
if [ ! -d "$DSTDIR" ]; then
<!DOCTYPE html>
<html>
<head>
<title>Fancy shadow demo</title>
<style type="text/css">
html, body {
font-family: sans-serif;
font-size: 10pt;
background-color: #fff;
color: #333;
#!/usr/bin/env python3
from pymouse import PyMouseEvent
import hashlib
import struct
class Entropist(PyMouseEvent):
def __init__(self, hashfunc=hashlib.sha512):
super(Entropist, self).__init__()
@607011
607011 / freedns.sh
Created June 12, 2018 08:50
freedns.afraid.org update script
#!/bin/sh
# update ip, log server reply (prepended by timestamp) to file
curl -s http://sync.afraid.org/u/XXXXXXXXXXXXXXXXXXXXXXXXXX/ | echo "`date +"%Y-%m-%d %H:%M:%S"` $(cat -)" >> /home/XXXX/log/XXXXXXXXXXXXXXX.log 2>&1
@607011
607011 / cccagent.js
Last active July 6, 2018 15:16
Cookie Clicker Click Agent
// ==UserScript==
// @name Cookie Clicker Click Agent
// @description Never again miss a golden cookie or sugar lump. Improve cookie production by automatically clicking the big cookie.
// @version 1
// @namespace *
// @include http://orteil.dashnet.org/cookieclicker/
// @grant none
// ==/UserScript==
/* DISCLAIMER
@607011
607011 / unicodeLength.js
Created January 5, 2019 07:47
Calculate length of unicode string
Object.defineProperty(String.prototype, 'unicodeLength', {
get: function() {
return this.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, '.').length;
}
});
@607011
607011 / deploy.sh
Created January 7, 2019 05:25
Minify HTML/CSS and JavaScript files, then deploy them via SSH
#!/bin/bash
DIST=dist/
DEST=host://path/to/html
JSFILES="worker.js wichtel.js"
HTMLFILES="index.html"
OTHERFILES=""
echo Cleaning up ...
@607011
607011 / b62.go
Last active May 11, 2019 10:08
Performance comparison of various base62 encoder techniques in Go
package main
import (
"fmt"
"math"
"reflect"
"runtime"
"sort"
"time"
)
@607011
607011 / endian.go
Created January 28, 2019 09:25
Get Endianness
func nativeEndianness() binary.ByteOrder {
buf := [2]byte{}
*(*uint16)(unsafe.Pointer(&buf[0])) = uint16(0xabcd)
switch buf {
case [2]byte{0xcd, 0xab}:
return binary.LittleEndian
case [2]byte{0xab, 0xcd}:
return binary.BigEndian
default:
panic("Could not determine native endianness.")