Skip to content

Instantly share code, notes, and snippets.

@Higgs1
Higgs1 / gist:08ec61fbb250c1c92151
Last active August 29, 2015 14:17
CoffeeScript Simple MD5
# Array sum helper function.
sum = (array) ->
array.reduce (x, y) -> x + y
md5 = do ->
# Per-round shift amounts.
s = [738695, 669989, 770404, 703814]
s = (s[i >> 4] >> i % 4 * 5 & 31 for i in [0..63])
# Constants cache generated by sine.
@Higgs1
Higgs1 / gist:d828714f8484390529cf
Last active August 29, 2015 14:17
CoffeeScript String ⇔ Hex
str2hex = do ->
hex = ['0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f']
hex = (hex[x >> 4] + hex[x & 15] for x in [0..255])
(str) ->
(hex[c.charCodeAt()] for c in str).join ''
hex2str = (hex) ->
(String.fromCharCode parseInt hex[i...i + 2], 16 for i in [0...hex.length] by 2).join ''
@Higgs1
Higgs1 / gist:cebedef2e775ea63fcbc
Created March 27, 2015 05:59
CoffeeScript CRC-32
crc32 = do ->
table =
for n in [0..255]
for [0..7]
if n & 1
n = 0xEDB88320 ^ n >>> 1
else
n >>>= 1
n
(str, crc = -1) ->
@Higgs1
Higgs1 / gist:3e2e4c0a3e1d547b5bd5
Created April 1, 2015 05:49
CoffeeScript "iter" function (Python-like)
iter = (x) ->
yield from x
@Higgs1
Higgs1 / gist:0a08c98af77a2cfd7b95
Created April 1, 2015 05:55
CoffeeScript "next" function (Python-like)
next = (x) ->
x.next().value
@Higgs1
Higgs1 / gist:e020321828ed3dc2d0a4
Last active August 29, 2015 14:23
Extended JSON Parsing / Scraping in Python3
"""
Rationale: Some websites make it difficult to scrape from by obfuscating their otherwise JSON data with
things such as unquoted object keys, concatenated strings, comments, etc. which are all valid JavaScript
constructs but invalid JSON. This usually forces would-be web scraper developers to emulate an entire
browser just to mine the data, which apparently is a fairly successful deterrent. This script parses the
JavaScript AST without executing any potentially malicious JavaScript DRM code, and correctly parses a
number of valid JavaScript constructs into a Python dictionary.
It also provides methods to quickly download a web page and search for a global variable using pyquery.
"""
@Higgs1
Higgs1 / startup.lua
Last active August 29, 2015 14:27
Computer Craft Induction Smelter Turtle
-- 1. Label Computer
-- 2. Save file as "/startup"
while true do
for slot=1,16 do
if turtle.getItemCount(slot) > 0 then
turtle.select(slot)
for j=slot+1,16 do
if turtle.compareTo(j) then
turtle.select(j)
@Higgs1
Higgs1 / gist:4426001
Last active December 10, 2015 11:09
F-List Plugin Icon
/Td6WFoAAATm1rRGAgAhARwAAAAQz1jM4Cf/FkBdABiNghz+hLr94AK3xzwehblXPYMYwErnPWg+OjV176yNUF7Bsoo/sliR3d8e1PmlTedMJpBSdERua6/zkiYn/6/HYol1fyHocRQ/eQhm8W22giOO0x/oOmY1TjpJJyIGcCdcb5BNnjRzSr4I+VUtYjpAFAl4dp/rVo7EA99nQx8lMC3D3FguDmQp3Ki2yD4Z6YJwHDmzX4r0C1ozUSkjQ/yv/SxUdhb8XiJnGhrRzDm2ykNvwxDJe8L4xA5uSil6DJICf02eXtXZgXK3AFPAjsuJZ803nqntJ7wM/LpJ3WA/qgca8ZkOCitNXNMzsjjB1y7yPUUbzhhlSfS+T0dqFGRtWv52DhF1Y2fkg+qRkfSHLXRIy3puL58b+Aon2//l6DrB+n/Axd1LnpFE0c3tR9MAgME0mgKjO6rG1NTf4FFuUWjquKvF1qgtySnepNjPUZpGqiZZD4CvnP0lOjktWglk1uejb44EKAiw3oYtMSBr4QN/aedOLfVc7qHQUwBEee2ai+DhHOQyeHnxtLHdNYLHxlAPMQCQJE+Oo3PxRt7BGn9ZEXM7BliFq76RZ/qcJDGVwgbVVjtLFvpNbdA05/kC5ja3fJnNjfrx1QNfNwglhFJH+s6SvoIRcWpr2EzTN5E8HwxVOGqLA4xxaVCFWNCmLl+Pb2HBOWZecb++Xqz8WvCcMD5gKlRb8VTWJJcSLR1Sg82jdCm6mwmnm863z/a8d3/qYhvSwf/tuWhqj+YotTS3hvJn6q+S/410mqm1QX9druFhOKiM9TnLb0DnYyN2RsLyz9dkkxGc822fsle2p2BLhq9+8ZiVPrFqKgu+9uZBdHJgBZcrkeTYsuffQtQ9fd5bz0cVB2cTZ0Rm7gfx72Byd0oj+6Dc175zYiNKkC616RX/EAGeO+tLJHASQ2naRS3kp7+dPVUkkQ0vd47vC3OUzMlV+y2ZK9V2ISUYEEi4d70DkXbvDpP6ZGvt1On9
@Higgs1
Higgs1 / gist:5299134
Last active December 15, 2015 17:49
Cipher for Minecraft lastlogin files implemented in JavaScript.
(function(a) {
var j = [1056971584,1092420379, 222248973,1128348931, 239223324, 473841219,
507790366, 924989, 457179966,1060977933,1092295748, 218317597,
1075723843,1141775679, 239223296, 505151553],
k = [1953896747, 688289143,2020897649,1982400117, 707557120,1897474930,
746061866, 443773466, 2848041,2003989273,1920337524, 721820017,
443754872, 746027052, 704673306,1903522858],
n = [ 206766165,1442849110, 576215071,1411535372,1359237899, 542266657,
1461722967, 72616785,1397826060, 525555200, 186799190,1477115989,
1461670228, 69279832,1381436498, 553932064],
@Higgs1
Higgs1 / modpack.zip
Last active December 19, 2015 21:21
Nukokapack 2015.12.19