This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bash completion for packagebuilder pb command | |
# (wrapper for pacman and aur on Arch Linux) | |
_pb() { | |
local word; | |
word=${COMP_WORDS[$COMP_CWORD]}; | |
COMPREPLY=( $(pb -Ss "^${word}" 2>/dev/null | grep '^\S' | sed -e 's/^.*\/\(\S\+\)\s.*/\1/') ); | |
return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python2 | |
""" | |
Visual hash (see [html5 implementation](https://github.com/sametmax/VizHash.js) and | |
[original creator's website](http://sebsauvage.net/wiki/doku.php?id=php:vizhash_gd)) | |
reimplemented using a Python script with PIL. | |
""" | |
from PIL import Image,ImageDraw | |
import hashlib | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' If you've copied certain files from folder A to folder B | |
' And wanted to move them instead | |
' You can use this to remove files in B from A | |
' On windows just double click this script and you'll be prompted for folders | |
Dim fso | |
Set fso = CreateObject("Scripting.FileSystemObject") | |
Dim folderObj, arcFolder, cleanFolder, fileObj, filename |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Finds locations within data structure that a specific key/value can be found | |
* - Handles looping data structures (for instance window.window = window) | |
* - Flexible query format (provide key to match, value to match, or both) | |
* - Handy for reverse engineering and understanding javascript code on websites | |
* - Note, it's a little hack-ish, but it's just a tool anyway | |
* Examples: | |
* a = {b: 4, c: [1, 2, {d: 5, e: [0, 5, 2]}]}; | |
* searchObj(a, {key: d}); // --> ["root.c.2.d"] | |
* searchObj(a, {value: 2}); // --> ["root.c.1", "root.c.2.e.2"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Date select copy</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.min.js"></script> | |
<script type="text/javascript"> | |
if (typeof($) == "undefined") { | |
$ = document.getElementById.bind(document); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var tty = require('tty') | |
var readline = require('readline') | |
var util = require('util') | |
// Config | |
var keyBindings = { | |
"C-x": "quit", | |
"C-r": "draw-screen", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Looking for a way to reduce a list of 9 digits into a sum that is unique if the digits are those between 1 and 9 inclusively. | |
This is for a solution to a Sudoku problem, but it was fun to mess around with functional programming. | |
""" | |
import itertools, functools, inspect | |
def findAllSimilar(individualOperation, aggregationOperation): | |
# Note: doing range inverse to make sure operation is commutative | |
expected = functools.reduce(aggregationOperation, map(individualOperation, range(9, 0, -1))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
import sys | |
import string | |
while True: | |
b = sys.stdin.read(16) | |
if not b: | |
break | |
print "".join(map(lambda x: "%02x " % x, map(ord, b))) + " " + "".join(map(lambda x: x if x in string.printable else chr(0xA7), b)).replace('\t',' ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.sun.net.httpserver.HttpServer | |
HttpServer.create(new InetSocketAddress(8899), 0).with { | |
createContext("/") { http -> | |
http.with { | |
println (requestMethod + " " + requestURI + " HTTP/1.1") | |
requestHeaders.each{ | |
a,b -> b.each{ | |
y -> println a + ": " + y | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Quick and dirty way to see raw requests made, for debugging. | |
*/ | |
import java.net.ServerSocket | |
def server = new ServerSocket(4444) | |
while(true) { | |
server.accept { socket -> | |
socket.withStreams { input, output -> | |
byte[] buf = new byte[256] |
OlderNewer