Skip to content

Instantly share code, notes, and snippets.

View pydsigner's full-sized avatar

Daniel Foerster pydsigner

View GitHub Profile
g = [locals().__setitem__('_x', (yield locals().get('_x', x)) or locals().get('_x', x)) for x in range(10)]
# >>> next(g)
# 0
# >>> next(g)
# 0
# >>> g.send(3)
# 3
# >>> next(g)
# 3
# >>> next(g)
@pydsigner
pydsigner / deferredsounds.py
Last active June 7, 2018 05:55
Example For Loading Pygame Sounds in Background
import pygame
import thread # _thread in Python 3
class FakeSound:
def play(self, *args, **kw):
pass
class SoundStore:
>>> lines = c.split('\n')
>>> S1 = set()
>>> S2 = set()
>>> for line in lines:
... S1.add(line.split()[0])
... if '->' in line:
... for stacked in line.split('->')[-1].split(','):
... S2.add(stacked.strip())
...
>>> S1 - S2
@pydsigner
pydsigner / secretsanta.py
Last active November 2, 2017 19:09
Secret Santa One-line
import random
print (lambda names, used, assigned: [((lambda n=n: (n, assigned.add(n))[0])(), (lambda p: (p, used.add(p))[0])(next(x for x in (random.choice(list(names - used - {n})) for i in xrange(10**9)) if 1 or len(names - used - {x}) != 1 or (used | {x} != assigned | {n})))) for n in names])(set(raw_input().split(',')), set(), set())
@pydsigner
pydsigner / rapgod.py
Last active August 25, 2017 15:37
hip-hop creation assistance tool
#!/usr/bin/python2
'''
Impress your friends and become the next
2pac using rapgod.py, a state-of-the-art
rhymez and raps assistance tool.
dsc@dev4 $ rapgod en python
brighten brighton frighten icahn
icon ikon lightning lightson
ptyon pythons tighten titan
@pydsigner
pydsigner / .i3status.conf
Last active August 5, 2017 02:24
i3 config file
# i3status configuration file.
# see "man i3status" for documentation.
# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!
general {
colors = true
@pydsigner
pydsigner / stacktrace.gdb
Created April 14, 2017 05:44
Hatchet Compile-time Stacktrace
#0 0x00000000004dbb40 in putIntoReg_ZsUE1JVxG9cRVXlAiTkBa3Q ()
#1 0x00000000004e62ed in evalMacroCall_NNZcYiEoPcdLz5gpQBCUgQ ()
#2 0x0000000000487c69 in semMacroExpr_woULc1D9b2DCEYOx5yRZXRg ()
#3 0x000000000047a11c in semIndirectOp_tayBCUAEli3HMPwxdS9aMbg_18 ()
#4 0x000000000047afc6 in semExpr_tayBCUAEli3HMPwxdS9aMbg_2.part.63 ()
#5 0x0000000000476cab in semExprWithType_tayBCUAEli3HMPwxdS9aMbg ()
#6 0x000000000048415f in semAsgn_41mPO3XBCUDPZnbaNrwpNw ()
#7 0x000000000047aa67 in semExpr_tayBCUAEli3HMPwxdS9aMbg_2.part.63 ()
#8 0x000000000048c13b in semStmtList_tayBCUAEli3HMPwxdS9aMbg_25 ()
#9 0x000000000047a945 in semExpr_tayBCUAEli3HMPwxdS9aMbg_2.part.63 ()
@pydsigner
pydsigner / vizstats.py
Created October 12, 2016 03:28
VizStats Rework
class VizStats(NTPStats):
percs = {} # dictionary of percentages
unit = 's' # display units: s, ppm, etc.
multiplier = 1
percentile_map = {p: 0 for p in (99, 95, 50, 5, 1)}
range_map = {r: 0 for r in [(99, 1), (95, 5)]
mu = 0 # arithmetic mean
pstd = 0 # population standard distribution, one sigma
@pydsigner
pydsigner / messagelog.pl
Created October 14, 2015 22:57
Human/machine readable logging for irssi messages
#!/usr/bin/perl -w
use strict;
use Irssi 20010120.0250 ();
use vars qw($VERSION %IRSSI);
$VERSION = "0.2";
%IRSSI = (
authors => 'Daniel Foerster',
contact => 'pydsigner@gmail.com',
name => 'messagelog',
@pydsigner
pydsigner / npc_demo.aph
Last active April 28, 2016 03:33
Aphor — NPC Demo
; Requires a comparison expression→comparison function post-processor
npcs.script("The Doctor", 184, "009-2", 110, 44) {
func(`main) {
if(player.level < 25) {
npc.message("Hmm, it's very interesting, very ... (mumbling).")
}
elif(player.qvars.episode = nil) {
introduction()
}