AutoHotKey (i can show you how to use it)
This file contains hidden or 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 currency { | |
| Begin { | |
| # make sure we can use Web.HttpUtility | |
| Add-Type -AssemblyName System.Web | |
| } | |
| Process { | |
| $encoded = [Web.HttpUtility]::UrlEncode($args -join " ") | |
| $response = Invoke-WebRequest ` | |
| "https://google.com/search?q=$encoded" |
This file contains hidden or 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
| // these are usually defined in math.h ... | |
| #define NAN 0.0 | |
| // actually a bit smaller than DBL_MAX | |
| #define INFINITY 1e+308 | |
| /** | |
| * atof as described in ISO/IEC 9899:2011 (the C11 standard) | |
| * | |
| * case-insensitive input syntax EBNF: | |
| * |
This file contains hidden or 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
| " add all builtin keywords and methods/attributes to syntax | |
| " put in $VIM/vimfiles/after/syntax/python.vim | |
| if exists('b:loaded_pythoncustomsyntax') | |
| finish | |
| endif | |
| let b:loaded_pythoncustomsyntax=1 | |
| syn keyword pythonExceptions ModuleNotFoundError |
This file contains hidden or 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 run { | |
| Start-Process $args[0] -ArgumentList ( | |
| $args[1..$args.Length] -join " " | |
| ) | |
| } |
This file contains hidden or 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
| # This is a total of 5 logical LOC, but the API is... well hidden and highly opaque | |
| # (magic numbers everywhere!) so it warrents a few dozen lines of comments | |
| function Enable-ANSIEscapes { | |
| # Enable ANSI / VT100 16-color escape sequences: | |
| # Original discovery blog post: | |
| # http://stknohg.hatenablog.jp/entry/2016/02/22/195644 | |
| # Esc sequence support documentation | |
| # https://msdn.microsoft.com/en-us/library/windows/desktop/mt638032(v=vs.85).aspx |
This file contains hidden or 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
| import argparse | |
| parser = argparse.ArgumentParser( | |
| description='Print prime factors of number[s]' | |
| ) | |
| parser.add_argument('num', type=int, nargs='*') | |
| args = parser.parse_args() | |
| nums = args.num |
This file contains hidden or 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
| # sign funcs | |
| import math | |
| # cli arguments | |
| import argparse | |
| # random rationals | |
| import random | |
| def sign(x): | |
| return math.copysign(1, x) |
This file contains hidden or 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
| # generates the nth iteration of the koch snowflake and outputs | |
| # it for use in LaTeX / tikz | |
| # sources the iteration count from the args or defaults to 0 | |
| # you could easily modify it to request a default with | |
| # iterations = int(prompt("iterations? ") or something | |
| import sys | |
| # get the first numeric argument for our iteration count | |
| iterations: int |
This file contains hidden or 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
| import math | |
| import re | |
| def get_float(prompt): | |
| return float(input(prompt)) | |
| # ok, this one is kinda complicated to describe | |
| # scales a number val (assumed to be in the range of valmin to valmax) | |
| # to the equivalent fractional distance from min to max | |
| # eg if you have a percent value and you want it to be a byte val |