Skip to content

Instantly share code, notes, and snippets.

//License: http://creativecommons.org/publicdomain/zero/1.0/
//see https://blog.xkcd.com/2010/05/03/color-survey-results/
//adapted from: https://xkcd.com/color/rgb.txt
//several colors were defined twice once spaces and slashes
//were replaced with underscores
//those lines have simply been commented out
//the most useful ones like COLOR_BLACK and COLOR_BLUE are at the bottom of
//the file for some reason. ask randall. idk
#define COLOR_CLOUDY_BLUE 0xacc2d9
#define COLOR_DARK_PASTEL_GREEN 0x56ae57
"a quick vim script for distraction free writing
"use :NoDistractions
"turns off line numbers etc, shows word count in the ruler,
"no status line
"only in the current buffer
function! NoDistractions()
setlocal nolist
setlocal laststatus=0
setlocal rulerformat=%{wordcount().words}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>distance estimation</title>
</head>
<body>
<canvas id="canvas"></canvas>
<script>
//html5 <canvas> pixel shader for javascript
#folder denesting script for powershell
#also deletes empty folders
#you'll have to run it n times for n levels of nested folders
#but it outputs the number of folders denested and deleted
#this works for 99% of scenarios, but if you run into an edge case... sorry!
function DeNestFolders {
$ErrorActionPreference = "Stop"
echo "denesting folders!!"
$denests = 0
#Random string generation for passwords etc
#defaults to all printable ascii
#works either inclusively, building a character palette up from zero with switches like -Numbers
#or exclusively, starting with all printable ascii and removing characters, as with -NoNumbers
#`Random-String -Numbers $False` and `Random-String -NoNumbers` work the same
function Random-String {
[CmdletBinding()]
Param(
[Int]$Length = 16,
[Switch]$Letters,
@9999years
9999years / cleanup-utilities.ps1
Created December 16, 2016 00:12
A set of Powershell cmdlets for modifying file names (replacing strings and stripping end/start strings)
function StripStartName {
[CmdletBinding()]
Param(
[String]$Name
)
ls | %{
if($_.Name.StartsWith($Name)) {
ren -LiteralPath "$($_.FullName)" "$($_.Parent.FullName)\$($_.Name.Substring($Name.Length))"
}
}
" Script that uses Python and the `base64` module to provide base64 decode and
" encode commands. It’d be pretty simple to support any other base64 program as
" well, as long as it reads from stdin — just replace `python -m base64 -e` with
" the encoding command and `python -m base64 -d` with the decoding command.
"
" Some features this provides:
"
" * Supports ranges, converts only the current line by default (use
" `:%Base64Encode` to encode the whole file, for example, and it’ll work as
" expected from within visual mode, although it only converts whole lines)
var els = [],
g = {
img: document.getElementsByTagName("img")[0],
time: 0,
amt: 20,
amin: 5 /* amp */,
amax: 10,
ramin: 1 /* rot amp */,
ramax: 50,
pmin: 1 /* period */,
//see https://gist.github.com/9999years/8fd0184530fcbbe494ffc306bab8654b for more verbosity
//kinda golfed (1507 bytes)
var els = [], g = { img: document.getElementsByTagName("img"), time: 0, amt: 20,
amin: 5 /* amp */, amax: 10, ramin: 1 /* rot amp */, ramax: 50, pmin: 1 /* perio
d */, pmax: 10, rpmin: 1 /* rot period */, rpmax: 50 }; function randf(min, max)
{ return Math.random()*(max-min)+min; } function randSign() { return Math.round(
Math.random()) ? -1 : 1; } function sin(amp, period) { return amp * Math.sin((g.
time / period) * 2*Math.PI); } function randEl(arr) { return arr[Math.floor(Math
.random()*arr.length)]; } function generateVariables() { for(var i = els.length;
% usage: \unicode[font]{codepoint}, e.g. \unicode[\emojifont]{1F60E} or \unicode{1F47D}
% requires --shell-escape be enabled (to use \write18) and curl to be in the path
% prints something like U+XXXX § SECTION SIGN
% note that the codepoint MUST be in all-caps, due to how \symbol works
\newcommand{\unicode}[2][]
{\immediate\write18{curl https://codepoints.net/api/v1/name/#2 -o .cp#2.txt}
\texttt{U+#2} {#1\symbol{"#2}}
\texttt{\input{.cp#2.txt}}\immediate\write18{del .cp#2.txt}}