Skip to content

Instantly share code, notes, and snippets.

View binki's full-sized avatar

Nathan Phillip Brink binki

View GitHub Profile
@binki
binki / output.txt
Created June 11, 2018 20:39
demo gzip’s inability to do cross-archive deduplication
ohnobinki@gibby /tmp/.private/ohnobinki/testx $ LC_ALL=C ls -la
total 14636
drwxr-xr-x 2 ohnobinki users 120 Jun 11 20:37 .
drwx-----T 16 ohnobinki users 440 Jun 11 20:17 ..
-rw-r--r-- 1 ohnobinki users 3069158 Jun 11 20:17 IMG_20180327_165234.jpg
-rw-r--r-- 1 ohnobinki users 2939105 Jun 11 20:37 x.7z
-rw-r--r-- 1 ohnobinki users 5900455 Jun 11 20:18 x.tar.gz
-rw-r--r-- 1 ohnobinki users 3069158 Jun 11 20:17 x2.jpg
@binki
binki / find-likely-angular-injection-failures.sh
Last active June 11, 2018 17:33
Find old-style angular files likely to fail injection during minification
#!/bin/sh
# The find ignores any VS build folders and minified files. It
# then grabs any *.js and passes them to xargs.
#
# The xargs runs a script per each file which is unfortunately inside
# of "" so everything has to be escaped, making the inside unreadable.
# The sed takes any line ending in opening square bracket ‘[’, comma ‘,’,
# space ‘ ’ and removes the newline. It took me a long time to figure out
# how to get sed to join lines together. It involves some ridiculousness
@binki
binki / addUseStrict.js
Last active February 9, 2022 12:06
jscodeshift codemod to add "use strict" to any file where it is not already the first statement
module.exports = function (fileInfo, {
jscodeshift,
}, options) {
// Work around for https://github.com/facebook/jscodeshift/issues/262
const isUnix = fileInfo.source.indexOf('\r\n') === -1;
const dom = jscodeshift(fileInfo.source);
const topLevelStatements = jscodeshift(dom.get('program', 'body').value).filter(path => {
return jscodeshift.Statement.check(path.node);
});
// Don’t add another one if it is already there.
@binki
binki / gist:61513c005b87b120dc5d069ea5ed85e9
Created March 8, 2018 00:12
csharp hex can be unsigned if big enough
csharp> 0x80000000.GetType()
System.UInt32
csharp> 0x40000000.GetType()
System.Int32

lol, only Canada is sane xD

@binki
binki / main.c
Created February 19, 2018 01:15
Windows command line
#include <windows.h>
int main(
int argc,
const char *const argv[]) {
const HANDLE stdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
if (stdOutput == INVALID_HANDLE_VALUE) {
return 1;
}
const LPSTR cmdLine = GetCommandLine();
if (!WriteFile(stdOutput, cmdLine, lstrlenA(cmdLine), NULL, NULL)) {
ohnobinki@gibby ~/downloads $ gcc -Wall -o opennofollow opennofollow.c
ohnobinki@gibby ~/downloads $ touch x.txt
ohnobinki@gibby ~/downloads $ ln -s x.txt y.txt
ohnobinki@gibby ~/downloads $ ./opennofollow
-1
ohnobinki@gibby ~/downloads $ cat y.txt
ohnobinki@gibby ~/downloads $ rm y.txt
ohnobinki@gibby ~/downloads $ touch y.txt
ohnobinki@gibby ~/downloads $ ./opennofollow
3
@binki
binki / analysis.md
Last active December 30, 2017 04:15

initial tweet of luceleaftea: https://twitter.com/luceleaftea/status/946938980574089216 followup: https://twitter.com/ohnobinki/status/946944544528007168

Ran them all to see which ones are faster. Some of them have values that are too close to tell if they are actually better or just flucuations in the environment.

ohnobinki@gibby ~/downloads $ for x in $(seq 0 4); do echo -n "doStuff(${x}) "; python3 -m timeit -s 'from blahstar import doStuff' "doStuff(${x})"; done
doStuff(0) 10 loops, best of 3: 211 msec per loop
doStuff(1) 10 loops, best of 3: 179 msec per loop
doStuff(2) 10 loops, best of 3: 179 msec per loop
@binki
binki / README.md
Last active June 20, 2024 18:29
Doki Doki Literature Club Base64 Natsuki Message/Poem Starting With T3B

image of base64

@binki
binki / post-file.js
Last active October 4, 2023 14:35
posting a file loaded through fs.readFile() through axios+form-data
#!/usr/bin/env node
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
const filePath = __dirname + '/../accept-http-post-file/cookie.jpg';
fs.readFile(filePath, (err, imageData) => {
if (err) {
throw err;
}