Skip to content

Instantly share code, notes, and snippets.

@shadowmint
shadowmint / gist:6928668
Created October 11, 2013 02:20
SDL2 mixer example
import ctypes
import unittest
import time
import os.path
from sdl2 import *
from sdl2.sdlmixer import *
class MixerTests(unittest.TestCase):
@shadowmint
shadowmint / gist:7004832
Last active March 23, 2024 22:19
Kivy example using sqlalchemy to build a layout.
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine
from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import sessionmaker
from sqlalchemy import ForeignKey
from sqlalchemy.orm import relationship, backref
from kivy.graphics import Rectangle
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.widget import Widget
@shadowmint
shadowmint / gist:7017962
Created October 17, 2013 01:38
console test script
import re
import sys
import os
import time
import logging
import subprocess
import time
from os.path import expanduser, join, abspath, dirname
@shadowmint
shadowmint / scrap.ts
Created January 21, 2014 06:21
Example of deferred~
/* Load page navigation */
public loadNav():void {
var nav = new bs.widgets.Nav(this._$nav.find(PageLayout.NAV_ACCORDION));
nav.register('bedroom-layout', () => {
console.log(this);
this._loadPage('room_selector_nav.html', 'room_selector_page.html').then(() => {
bs.app.room.loadRoom();
});
});
nav.register('bedroom-doors', () => {
#[macro_escape];
#[macro_export]
macro_rules! trace(
($($arg:tt)*) => (
::std::io::stdout().write_line(format_args!(::std::fmt::format, $($arg)*))
);
)
#[test]
@shadowmint
shadowmint / game_menu.rs
Last active August 29, 2015 13:57
Rusts stuff
use game_state::GameState;
mod game_state;
pub struct GameWindow {
window: ~int,
state: ~GameState,
}
impl GameWindow {
@shadowmint
shadowmint / gist:9406982
Created March 7, 2014 07:29
Rust oddness
extern crate uuid;
use uuid::Uuid;
use std::fmt;
struct BlahLF {
id: Uuid
}
struct StateLF;
@shadowmint
shadowmint / gist:9478400
Created March 11, 2014 02:30
rust nstrcmp
macro_rules! trace(
($($arg:tt)*) => (
{ let x = ::std::io::stdout().write_line(format_args!(::std::fmt::format, $($arg)*)); println!("{}", x); }
);
)
macro_rules! nstrcmp(
($x:ident, $y:ident, $n:expr) => (
$x.len() >= $n && $y.len() >= $n && $x.slice(0, $n) == $y.slice(0, $n)
);
@shadowmint
shadowmint / gist:9511455
Created March 12, 2014 17:06
Rust list example
use std::cast;
#[deriving(Show)]
struct Node<T> {
next:Option<~Node<T>>,
data:Option<T>
}
enum NodeErr {
Nope
@shadowmint
shadowmint / gist:9542616
Last active August 29, 2015 13:57
Crate with a macro
#[feature(macro_rules)];
#[crate_id = "junk#0.1"];
#[no_mangle]
pub fn dothing(a: int, b:int) -> int {
return a + b;
}
#[macro_escape]