Skip to content

Instantly share code, notes, and snippets.

View oprypin's full-sized avatar

Oleh Prypin oprypin

View GitHub Profile
@oprypin
oprypin / 1-tok_gen.py
Last active August 29, 2015 14:27
A tokenizer feeding into parser+builder
# Generator functions in Python give out results one by one, and you can iterate over them in a for-loop
def tokens_generator():
yield "{"
yield "Hash"
yield "("
yield "Int32"
yield ","
yield "Array"
yield "("
yield "Int32"
import dbus
bus = dbus.SessionBus()
proxy = bus.get_object("org.freedesktop.Notifications", "/org/freedesktop/Notifications")
proxy.Notify("app", dbus.UInt32(0), "", "title", "body", dbus.Array([], signature="s"), dbus.Dictionary({}, signature="sv"), 1000)
@oprypin
oprypin / 1.py
Created July 14, 2015 20:26
Inception
%if False:
print(5)
print("a")
print("lol")
for i in range(10):
%if True:
print(6)
print(8)
#!/usr/bin/python3
import subprocess
import re
#repl = {6:2, 7:2} # Mouse buttons to be replaced
repl = {6:8, 7:9} # Mouse buttons to be replaced
out = subprocess.check_output(['xinput', 'list'])
for s in out.decode('utf-8').lower().split('\n'):
try:
@oprypin
oprypin / chipmunk.cr
Created June 1, 2015 18:31
crystalize.py Chipmunk
lib CP
fun message = "cpMessage"(condition : UInt8*, file : UInt8*, line : Int32, is_error : Int32, is_hard_error : Int32, message : UInt8*, ...) : Void
alias Float = Float64
alias HashValue = LibC::SizeT
alias CollisionID = UInt32
alias Bool = UInt8
@oprypin
oprypin / examples.md
Last active August 29, 2015 14:22
crystalize.py examples
@oprypin
oprypin / crystalize.py.diff
Created June 1, 2015 18:17
crystalize.py PCRE
diff --git a/crystalize.py b/crystalize.py
index 8f85408..d53a4ac 100755
--- a/crystalize.py
+++ b/crystalize.py
@@ -76,7 +76,7 @@ code = []
keywords = 'alias and begin break case class def defined do else elsif end ensure false for if in module next nil not or redo rescue retry return self super then true undef unless until when while yield BEGIN END'.split()
-lib_name = 'Lib'
+lib_name = 'PCRE'
@oprypin
oprypin / csfml.diff
Last active August 29, 2015 14:20
API changes between SFML 2.2 and 2.3
git diff CSFML-2.2 CSFML-master | grep -vP '^([^-+]|. *//)' | sed -r 's/^[-+]{3} .+\///g' | uniq
SoundBuffer.h
-CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromSamples(const sfInt16* samples, size_t sampleCount, unsigned int channelCount, unsigned int sampleRate);
+CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromSamples(const sfInt16* samples, sfUint64 sampleCount, unsigned int channelCount, unsigned int sampleRate);
-CSFML_AUDIO_API size_t sfSoundBuffer_getSampleCount(const sfSoundBuffer* soundBuffer);
+CSFML_AUDIO_API sfUint64 sfSoundBuffer_getSampleCount(const sfSoundBuffer* soundBuffer);
Audio.h
+#include <SFML/Audio/SoundStatus.h>
+#include <SFML/Audio/SoundStream.h>
%if false:
echo 5
echo "a"
echo "lol"
for i in 0..10:
%if true:
echo 6
echo 8
import macros
macro doThis(s: static[string]): stmt =
let n = parseStmt(s)
quote do:
template actuallyDoIt: stmt =
`n`
template exec*(s: string) {.immediate.} =
doThis(s)