Skip to content

Instantly share code, notes, and snippets.

@Bolt64
Bolt64 / gist:6476781
Last active December 22, 2015 13:08
A small script to interpolate data points and return a polynomial going through those points.
'''
README
To use this script you must have python and numpy installed.
Just download the script, open up the terminal and execute the
script as './interpolate.py -i' for the interactive mode
and './interpolate -f file' to use a file as the data source.
the file must be formatted as input/output pairs separated by a comma.
The script will print a list as output. The first number is the constant,
@Bolt64
Bolt64 / audacious_controller.py
Created November 1, 2013 17:08
A remote controller for audacious written in python
#!/usr/bin/env python
from os import system
import sys, tty
import alsaaudio
system('export DISPLAY=:0')
mixer=alsaaudio.Mixer()
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
build/
develop-eggs/
@Bolt64
Bolt64 / threading_pi_bot.py
Created February 6, 2014 06:48
Threading for a raspberry pi bot
#!/usr/bin/env python3
import threading
class led_thread(threading.Thread):
def run(self):
print('Doing led stuff')
#Other stuff
class listener_thread(threading.Thread):
import threading,time,urllib.request,queue
class fetcher(threading.Thread):
def __init__(self,print_lock,url_queue,threadId):
self.Id=threadId
self.print_lock=print_lock
self.url_queue=url_queue
threading.Thread.__init__(self)
def run(self):
@Bolt64
Bolt64 / conv.py
Last active August 29, 2015 13:56
def conversation(conversation_dict):
conversations=[i for i in conversation_dict]
for index,conv in enumerate(conversations):
print("{0}. {1}".format(index+1,conv))
choice=int(input("What do you say (enter number)?"))
outcome=conversation_dict[conversations[choice-1]]
if not type(outcome)==dict:
outcome()
else:
conversation(outcome)
@Bolt64
Bolt64 / duckdns.py
Created February 26, 2014 15:40
A script for duckdns
#!/usr/bin/env python3
"""
A script for duckdns
"""
import urllib.request
import time
INTERVAL=300
@Bolt64
Bolt64 / hdt.py
Created March 14, 2014 12:53
An efficient solution for euler problem 12
#!/usr/bin/env python3
'''
A script to determine the lowest triangular number with over 500 divisors
'''
import math
class Memoize(object):
@Bolt64
Bolt64 / perms.py
Created June 4, 2014 04:32
A script to recursively generate permutations in lexicographic order
#!/usr/bin/python3
def generate_permutations(sequence):
if len(sequence)==1:
yield sequence
elif len(sequence)>1:
for index, item in enumerate(sequence):
for perm in generate_permutations(sequence[:index]+sequence[index+1:]):
yield [item]+perm
@Bolt64
Bolt64 / mpd.conf
Created July 13, 2014 15:58
mpd.conf
music_directory "/mpd/Music"
playlist_directory "/mpd/conf/playlists"
db_file "/mpd/conf/database"
log_file "/mpd/conf/log"
pid_file "/mpd/conf/pid"
state_file "/mpd/conf/state"
sticker_file "/mpd/conf/sticker.sql"
user "mpd"
group "mpd"