Skip to content

Instantly share code, notes, and snippets.

View ibebrett's full-sized avatar
🕶️

Brett Jurman ibebrett

🕶️
  • The Dev Effect
  • NYC
View GitHub Profile
visited = set([(0,0)])
# point = (3, 4)
# x, y = point
# x == 3
# y == 4
def visit(point):
#print('at ', point)
x, y = point
struct SDLContext {
sdl: sdl2::Sdl,
audio: sdl2::AudioSubsystem,
window: Box<sdl2::video::Window>,
canvas: Box<sdl2::render::WindowCanvas>,
//texture_creator: sdl2::render::TextureCreator<sdl2::video::WindowContext>,
}
impl SDLContext {
import pygame, sys
WHITE = (255, 255, 255, 0)
BLUE = (255, 0, 0, 0)
# set up pygame
pygame.init()
# set up the window
windowSurface = pygame.display.set_mode((500, 400))
# import the pygame module
import pygame
# import pygame.locals for easier access to key coordinates
from pygame.locals import *
# Define our player object and call super to give it all the properties and methods of pygame.sprite.Sprite
# The surface we draw on the screen is now a property of 'player'
class Player(pygame.sprite.Sprite):
def __init__(self):
import pygame, sys
WHITE = (255, 255, 255)
BLUE = (255, 0, 0)
# set up pygame
pygame.init()
# set up the window
windowSurface = pygame.display.set_mode((500, 400), 0, 32)
const zalloc = @import("zalloc/index.zig");
const std = @import("std");
const debug = std.debug;
const Allocator = std.mem.Allocator;
test "test idiotic alloc low value" {
var allocator: Allocator = zalloc.IdioticAllocator(200).init().allocator;
var slice = try allocator.alloc(*i32, 100);
const std = @import("std");
const Allocator = std.mem.Allocator;
/// A "IdioticAllocator." An idiotic allocator that does not free, ignores
/// alignment and simply returns an offset into a static buffer. Not useful
/// for anything but a learning tool.
pub fn IdioticAllocator(comptime bufferSize: usize) type {
return struct {
const Self = @This();
import argparse
import hashlib
from videoads import VideoCreative
def main(path):
new_path = '{0}-converted'.format(path)
VideoCreative.convert(path, new_path)
phash_key = '1-md5-%s' % hashlib.md5(unicode(VideoCreative.video_phash(new_path, 2))).hexdigest()
print phash_key
@ibebrett
ibebrett / gist:f242dcef85b836789f64
Created September 25, 2014 18:40
Shortest Path
pathRecurse :: Board -> [Pos] -> Pos -> Pos -> Maybe [Pos]
pathRecurse b visited pa pb
| pa == pb = Just (visited++[pb])
| null neighbors = Nothing
| null subpaths = Nothing
| otherwise = Just ( minimumBy (comparePath) subpaths )
where subpaths = catMaybes ( map (\n -> pathRecurse b (visited++[pa]) n pb) neighbors)
neighbors = filter (\x -> (walkable b x) && not (x `elem` visited)) (getNeighbors b pa)
comparePath x y = compare (length x) (length y)
def fact(x):
if x == 0:
return 1
else
return x*fact(x-1)