Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andychase
andychase / number_to_unique_tuple.py
Last active August 29, 2015 14:24
Split a number into tuples in a unique way each time
""" Andy Chase
>>> [number_to_unique_tuple(i, 256) for i in [0, 1, 2, 255, 256]]
[(0,), (1,), (2,), (255,), (0, 1)]
>>> [number_to_unique_tuple(i, 256, 1) for i in [0, 1, 2, 255, 256]]
[(0, 0), (1, 1), (2, 2), (255, 255), (0, 1)]
>>> [number_to_unique_tuple(i, 256) for i in [256*2, (256*256) - 2, (256*256) - 1, 256*256]]
[(0, 2), (254, 253), (255, 254), (0, 0, 1)]
>>> s = [number_to_unique_tuple(i, 256) for i in range(0,256*256)]
>>> len(list(s))
65536
@andychase
andychase / googleforms2slack.gs
Last active February 15, 2024 07:53
Google Forms Slack Notification
// Google Forms Slack Notification
// Andy Chase <github.com/andychase>
// License: CC0 1.0 Universal <creativecommons.org/publicdomain/zero/1.0>
// Install 1: This code goes in ( tools > script editor... ) of your google docs form
// Install 2: ( resources > current project triggers ) ( [onSubmit], [from Form], [On form submit] )
// Setup 1: Put your slack api url below
var POST_URL = "https://hooks.slack.com/services/";
function onSubmit(e) {
// This gist demonstrates a performance issue with DiffuseMap/DiffuseColor & directional light/shadow map in JME3
// Issue ticket: https://github.com/jMonkeyEngine/jmonkeyengine/issues/247
// Press Z/X to shift back and forth between the textures to see the performance diffence.
import com.jme3.app.SimpleApplication;
import com.jme3.input.ChaseCamera;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.AnalogListener;
import com.jme3.light.DirectionalLight;
import com.jme3.input.controls.KeyTrigger;
@andychase
andychase / sample_args.py
Last active December 24, 2015 04:49
Minimal Python command line argument processing
#!python
""" A fairly simple way of parsing arguments without using libraries.
Licenced: http://creativecommons.org/publicdomain/zero/1.0/
"""
import sys
def main(_=None, argument_1="", argument_2="", *args):
if not argument_1:
print("need arg 1!)"
@andychase
andychase / chrome_xxd.py
Last active May 20, 2019 00:34
Google Chrome Cache Hex Dump To XXD
""" USEAGE: xclip -o | python chrome_xxd.py | xxd -r - [destination]
To access chrome's cache, go to about:cache in the address bar.
Make sure you copy the second section of the hex dump (the first section is the header).
"""
import sys
for line in sys.stdin.readlines():
sys.stdout.write(line[1:].replace(" ", " "))