Skip to content

Instantly share code, notes, and snippets.

@Bolt64
Bolt64 / natural_selection.py
Last active August 29, 2015 14:06
A natural selection simulator and graph plotter made for UB101 assignment
#!/usr/bin/env python3
"""
Author: Sayantan Khan
Date: 8th September, 2014
"""
import matplotlib.pyplot as plt
import random
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM default
Jan 01 07:09 : alsa_output: Failed to open "Pi Speakers" [alsa]: Failed to open ALSA device "default": No such file or directory
Jan 01 07:09 : output: Failed to open audio output
@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"
@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 / 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 / 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 / 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)
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 / 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):
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
build/
develop-eggs/