Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View GammaGames's full-sized avatar
🎃
👉😎👉 zoop

Jesse GammaGames

🎃
👉😎👉 zoop
View GitHub Profile
@GammaGames
GammaGames / fib.py
Created June 15, 2018 15:55
python3 fib
from functools import lru_cache
@lru_cache(None)
def fib(n):
return n if n < 2 else fib(n-1) + fib(n-2)
@GammaGames
GammaGames / wifi.py
Last active February 11, 2023 20:50
Generate wifi qr code in python3
import pyqrcode, sys, base64
if len(sys.argv) < 2:
print("Usage: python3 wifi.py [network] [password]")
quit()
network = sys.argv[1]
if len(sys.argv) > 2:
protocol = "WPA/WPA2"
pwd = sys.argv[2]
@GammaGames
GammaGames / .bashrc
Last active June 10, 2020 17:33
~/.bashrc
export EDITOR=vim
fortune | cowsay -f duck | lolcat
alias grit=". /home/$USER/Documents/grit/grit"
alias please='sudo $(fc -ln -1)'
alias pyss="python3 /home/$USER/Documents/pyss/pyss.py"
alias serv='python3 -m http.server'
alias timer='echo "Ctrl+C to stop"; time cat'
alias upt='sudo apt update && apt list --upgradable'
alias calc='bc'
alias c='code'
@GammaGames
GammaGames / godot.desktop
Created September 21, 2018 05:52
Desktop file for godot
[Desktop Entry]
Type=Application
Name=Godot
GenericName=Game engine
Comment=2D and 3D game engine
Exec=/home/username/Public/Godot_v3.0.6-stable_x11.64
Icon=/home/username/Public/godot.png
@GammaGames
GammaGames / hue.py
Last active July 25, 2022 01:43
kano wand + phillips hue
from kano_wand.kano_wand import Shop, Wand, PATTERN
from qhue import Bridge
import moosegesture as mg
import time
import random
import math
class GestureWand(Wand):
def post_connect(self):
self.gestures = {
from contextlib import contextmanager
from inspect import currentframe, getouterframes
@contextmanager
def let(**bindings):
frame = getouterframes(currentframe(), 2)[-1][0] # 2 because first frame in `contextmanager` decorator
locals_ = frame.f_locals
original = {var: locals_.get(var) for var in bindings.keys()}
locals_.update(bindings)
yield
@GammaGames
GammaGames / relative_import.py
Last active March 8, 2019 18:28
python relative import to current file
import sys
import os
# Get the absolute path from the current file
# Get the file's directory
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
# If you don't have access to the __file__ global
sys.path.append(os.path.dirname(os.path.abspath(sys.argv[0])))
# Print the last item in the path
@GammaGames
GammaGames / pryaml.py
Last active September 10, 2019 15:13
Print json representation of yaml to check structure
from os import path
import yaml
import json
import sys
if len(sys.argv) < 2:
print("Please provide a file name")
quit()
filename = sys.argv[1]
@GammaGames
GammaGames / parse_md.py
Created April 26, 2019 03:32
Parse markdown files into html files
from markdown2 import Markdown
import os
markdown = Markdown()
for root, dirs, files in os.walk("/var/www/html", topdown=False):
for name in files:
if name.endswith(".md"):
filename = os.path.join(root, name)
with open(filename, 'r') as md_file:
html_filename = os.path.join(root, "{}.html".format(os.path.splitext(filename)[0]))
- height*moisture:
- 1@2:rock,1:snow
- 2@1:sand,2:dirt,2:grass
- 3@1:=water
- tile*population:
- sand@9:-,1:buildings
- grass,dirt@3:-,1:buildings