Skip to content

Instantly share code, notes, and snippets.

@9999years
9999years / wttr.in for PowerShell
Last active August 16, 2023 12:46 — forked from chubin/Enable-wttr.in-for-PowerShell
How to enable wttr.in in a PowerShell console
<#
.DESCRIPTION
Fetches wttr.in for a terminal weather report.
.LINK
http://stknohg.hatenablog.jp/entry/2016/02/22/195644
.LINK
http://www.nivot.org/blog/post/2016/02/04/Windows-10-TH2-(v1511)-Console-Host-Enhancements
//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 / integral-approximations.mac
Last active December 11, 2016 07:16
Maxima functions for approximating integrals
/* functions for trapezoidal, midpoint, and
* right/left endpoint approximations of integrals
* arguments:
* f(t): function to be approximated
* t: dependent variable of f(t)
* bottom: bottom limit of integration
* top: top limit of integration
* n: number of samples/slices to be used in approximation
*/
@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 */,