Skip to content

Instantly share code, notes, and snippets.

{
"semi": true,
"tabWidth": 2,
"printWidth": 100,
"singleQuote": true,
"trailingComma": "all",
"jsxBracketSameLine": true
}
@motleytech
motleytech / circleChords.html
Created September 20, 2019 05:52
Geometric fun part 1 - chords in a circle
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Draw a line</title>
<style>
#DemoCanvas {
border: 1px solid #ddd;
}
</style>
@motleytech
motleytech / pysync2.py
Created December 5, 2018 22:51
Rsync like functionality using python distutils.dir_util.copy_tree
import sys
import distutils.log
import distutils.dir_util
import os
if len(sys.argv) != 3:
print ('Usage : python pysync2.py src dest')
exit(1)
src, dest = map(os.path.abspath, sys.argv[1:])
@motleytech
motleytech / pysync.py
Last active December 5, 2018 22:40
Rsync like functionality via python and cp - much faster for certain purposes
# script to smartly backup files using cp rather than rsync
import sys
import os
import exceptions
from pprint import pprint as pp
def removeFile(fp):
os.remove(fp)
@motleytech
motleytech / renameFiles.py
Last active November 30, 2018 19:06
Rename files
import sys
import os
import traceback
from pprint import pprint as pp
import string
def cleanupName(s):
while ' ' in s:
s = s.replace(' ', ' ')
@motleytech
motleytech / revMouseScroll3.py
Last active January 14, 2019 18:23
Python 3 Script to edit Registry for reversing mouse scroll direction
from winreg import *
import os
def is_admin():
if os.name == 'nt':
try:
# only windows users with admin privileges can read the C:\windows\temp
temp = os.listdir(os.sep.join([os.environ.get('SystemRoot','C:\\windows'),'temp']))
except:
return False
@motleytech
motleytech / revMouseScroll.py
Created April 6, 2018 05:46
Python script to reverse mouse scroll direction.
from _winreg import *
"""print r"*** Reading from HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\HID ***" """
aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)
FLIP_FLOP_VALUE = 1
aKey = OpenKey(aReg, r"SYSTEM\CurrentControlSet\Enum\HID")
for i in range(1024):
@motleytech
motleytech / verbalArith.py
Last active June 16, 2023 18:52
Verbal arithmetic
from pprint import pprint as pp
from time import time
st = time()
def codeForGuess(ch, firsts, indent):
ind = ' '*indent
v1 = """\
%sfor %s in %s:
%s urem(%s)""" % (ind, ch, "udiff(set0)" if ch in firsts else "ucopy()",
@motleytech
motleytech / javascript_useful_methods.js
Last active July 3, 2016 02:12
Javascript useful methods
// returns a range as a list
function range(start, stop, step) {
let result = []
if (step === undefined) {
step = 1
}
if (stop === undefined) {
stop = start
start = 0
}
@motleytech
motleytech / random.js
Created June 29, 2016 23:32
Utility functions for random number generation
// Returns a random number between min (inclusive) and max (exclusive)
function rand(min, max) {
return Math.random() * (max - min) + min;
}
// Returns a random integer between min (included) and max (excluded)
// Using Math.round() will give you a non-uniform distribution!
function randInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}