Skip to content

Instantly share code, notes, and snippets.

View ahawker's full-sized avatar

Andrew Hawker ahawker

View GitHub Profile
@ahawker
ahawker / README.md
Last active July 27, 2023 23:30
ingredient-selector

Ingredient Selector

Perform a random selection (weighted) of ingredients from the data files.

Development

Update the ingredient files and run! The script will automatically decrement the weights of its selections to promote new items.

Usage

### Keybase proof
I hereby claim:
* I am ahawker on github.
* I am hawker (https://keybase.io/hawker) on keybase.
* I have a public key ASD6wGH9jznfLABTvGu3WN9nfmKR6PwDFLe54ahD7HkDqwo
To claim this, I am signing this object:
@ahawker
ahawker / cracklepop.py
Created February 5, 2018 19:23
Snap, Crackle, Pop!
"""
CracklePop
~~~~~~~~~~
A simple fizzbuzz alternative for RC.
Usage: `python3 cracklepop.py`
"""
import sys
@ahawker
ahawker / battery.cs
Last active June 13, 2024 21:07
Battery info from win32 api
using System;
using System.IO;
using Microsoft.Win32.SafeHandles;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Text;
namespace Test
{
@ahawker
ahawker / state
Created December 13, 2013 19:51
A basic "state machine" built using python descriptors.
NO_OP = lambda *args, **kwargs: True
def iterable(item):
"""
Return an iterable which contains the given item.
"""
if isinstance(item, collections.Iterable) and not isinstance(item, basestring):
return item
return (item,) if item is not None else ()
@ahawker
ahawker / test.py
Created March 14, 2013 20:57
Crython example per request from user.
import crython
import time
@crython.job(second='*') #fired every second
def hello_world():
print 'hello_world called every second.'
@crython.job(second='*/4') #fired every 4 seconds
def hello_fours():
print 'hello_fours called every 4 seconds.'
@ahawker
ahawker / fizzbuzz.py
Created December 15, 2012 01:11
FizzBuzz in Python (2.7).
#!/usr/bin/env python
def main():
for x in xrange(1, 101):
div3 = x % 3 == 0
div5 = x % 5 == 0
if div3 and div5:
print 'FizzBuzz'
elif div3:
print 'Fizz'