This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
visited = set([(0,0)]) | |
# point = (3, 4) | |
# x, y = point | |
# x == 3 | |
# y == 4 | |
def visit(point): | |
#print('at ', point) | |
x, y = point |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fact(x): | |
if x == 0: | |
return 1 | |
else | |
return x*fact(x-1) |
NewerOlder