Skip to content

Instantly share code, notes, and snippets.

@hikerpig
hikerpig / gitcommit.snippets
Last active September 2, 2020 06:33
UltiSnips snippet for gerrit
global !p
#! /usr/bin/env python
import hashlib
def make_change_id():
fd = open("/dev/urandom", "rb")
buf = fd.read(80)
hash = hashlib.sha1()
hash.update(buf)
@hikerpig
hikerpig / play-reverse.js
Created March 13, 2020 09:13
Web Audio tricks
// copy from https://stackoverflow.com/questions/9874167/how-can-i-play-audio-in-reverse-with-web-audio-api
var context = new AudioContext(),
request = new XMLHttpRequest();
request.open('GET', 'path/to/audio.mp3', true);
request.responseType = 'arraybuffer';
request.addEventListener('load', function(){
context.decodeAudioData(request.response, function(buffer){
var source = context.createBufferSource();
Array.prototype.reverse.call( buffer.getChannelData(0) );
Array.prototype.reverse.call( buffer.getChannelData(1) );
@hikerpig
hikerpig / SimpleHTTPServerWithUpload.py
Created October 17, 2018 05:52 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@hikerpig
hikerpig / keybase.md
Last active March 8, 2020 06:56
keybase proof

Keybase proof

I hereby claim:

  • I am hikerpig on github.
  • I am hikerpig (https://keybase.io/hikerpig) on keybase.
  • I have a public key ASDARfNz6qbXyIykCZAq9RvkZrlDZjGCJt8bAeDOnPKt9Ao

To claim this, I am signing this object:

@hikerpig
hikerpig / csv2keepassxml.rb
Last active August 15, 2018 02:53
lastpass2keepass
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# thanks https://github.com/lifepillar/csv2keepassxml/blob/master/csv2keepassxml
# @example `csv2keepassxml -U 1 -u 2 -p 3 -n 4 -t 5 -g 6 lp.csv`
# Convert a CSV file into a KeePass 2 XML file.
require 'csv'
require 'date'
require 'htmlentities'
@hikerpig
hikerpig / delete_branches.sh
Last active June 27, 2018 03:59
Git snippets #tags:bash
#!/usr/bin/env bash
cat remote_branches.txt | xargs -I 'Branch' git push origin :Branch
@hikerpig
hikerpig / useful-commands.sh
Last active July 12, 2018 08:53
Shell commands
# Show the size of files under current directory(recursively) in bytes, and sort them in numeric order
find . | xargs -I _ stat -f "%z %N" _ | sort -n
@hikerpig
hikerpig / cloudSettings
Last active October 16, 2021 13:02
vscode sync
{"lastUpload":"2021-10-16T13:02:35.750Z","extensionVersion":"v3.4.3"}
@hikerpig
hikerpig / require_formatter.txt
Last active August 29, 2015 14:19
Tiny vimscript to align the require statement in js/coffee
if exists("g:loaded_require_formatter")
finish
endif
let g:loaded_require_formatter = 1
"Function: :format
"Desc: align the require statement
"
func! s:format()
python << EOF
@hikerpig
hikerpig / index.html
Created January 13, 2015 07:30
三角测试 // source http://jsbin.com/tuvonu
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>三角测试</title>
<style id="jsbin-css">
.dropdown a {
padding: 10px;
background: #aa4599;
position: relative;