View list-globals.js
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
objs = new Set | |
nameToObj = new Map | |
function t(obj) { | |
if (!obj || objs.has(obj) || typeof obj !== 'object') { return } | |
if (obj.nodeName === 'IFRAME') { return } // iframe descendants can cause security errors | |
objs.add(obj) | |
let proto = Object.getPrototypeOf(obj) | |
let name = (obj.constructor && obj.constructor.name) || (proto && proto.constructor && proto.constructor.name) | |
if (!nameToObj.has(name)) { nameToObj.set(name, []) } | |
nameToObj.get(name).push(obj) |
View convert-patterns.vim
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
" Pattern 1: | |
" | |
" * Operate over a whole file: :call ConvertFile() | |
" * Or operate over a selection: :'<,'>call ConvertLine() | |
" * Supports the same :s// and normal commands you regularly use in Vim | |
" * So minimal Vim Script knowledge needed | |
function! ConvertFile() | |
%global/^/call ConvertLine() | |
endfunction |
View jsizes.c
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
// gcc -I$JAVA_HOME/include -I$JAVA_HOME/include/linux jsizes.c -o jsizes && ./jsizes | |
#include <stdio.h> | |
#include <jni.h> | |
int main() { | |
printf("jboolean %li\n", sizeof (jboolean)); | |
printf("jbyte %li\n", sizeof (jbyte)); | |
printf("jchar %li\n", sizeof (jchar)); | |
printf("jshort %li\n", sizeof (jshort)); |
View store.js
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
// Moved to: https://github.com/mkropat/todomvc-tagsjs/blob/main/lib/store.js |
View jsizes.c
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
// gcc -I$JAVA_HOME/include -I$JAVA_HOME/include/linux jsizes.c -o jsizes && ./jsizes | |
#include <stdio.h> | |
#include <jni.h> | |
int main() { | |
printf("jboolean %li\n", sizeof (jboolean)); | |
printf("jbyte %li\n", sizeof (jbyte)); | |
printf("jchar %li\n", sizeof (jchar)); | |
printf("jshort %li\n", sizeof (jshort)); |
View encrypt.ps1
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
function Compute-Sha256($Str) { | |
$sha256 = New-Object System.Security.Cryptography.SHA256Managed | |
$sha256.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($Str)) | |
} | |
function Get-RandomBytes($Size) { | |
$rng = New-Object System.Security.Cryptography.RNGCryptoServiceProvider | |
$bytes = [System.Byte[]]::new($Size) | |
$rng.GetBytes($bytes) | |
$bytes |
View traverse-level-order.js
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
function traverseLevelOrder(thing, predicate, maxDepth=20) { | |
function traverse(thing, predicate, targetDepth, depth=0) { | |
if (targetDepth !== depth) { | |
for (const key in thing) { | |
const val = traverse(thing[key], predicate, targetDepth, depth + 1); | |
if (val) { | |
return val; | |
} | |
} | |
return; |
View dump-partitions.sh
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/sh | |
echo "| Name | Partition | Size (kB) | Path | Type |" | |
echo "|------|-----------|-----------|------|------|" | |
for d in /dev/block/bootdevice/by-name/*; do | |
name=$(basename -- "$d") | |
device=$(basename "$(readlink -- "$d")") | |
read -r _ fsmount fstype _ <<EOF |
View Extract-Roms.ps1
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
$ErrorActionPreference = 'Stop' | |
function Get-RomFromArchive { | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory=$True, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True)] | |
[Alias("PsPath")] | |
[string] $Path, | |
[Parameter(Mandatory=$True)] |
View com.codetinkerer.caffeinate.plist
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>com.codetinkerer.caffeinate.plist</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/usr/bin/caffeinate</string> | |
<string>-d</string> |
NewerOlder