Skip to content

Instantly share code, notes, and snippets.

@sherjilozair
sherjilozair / specnorm.py
Last active May 3, 2018 03:08
Spectral Normalization
import tensorflow as tf
import numpy as np
class SpecNorm(object):
def build(self, input_shape):
self.indim = input_shape[-1] * np.array(self.kernel_size).prod()
self.outdim = self.filters
self.u = self.add_variable(name='u', shape=(1, self.indim), trainable=False)
self.v = self.add_variable(name='v', shape=(self.outdim, 1), trainable=False)
super().build(input_shape)
[n.global]
output = sfml
[n.include]
/usr/local/include/SFML/
[Window/VideoMode.h]
preprocess = true
defines = true
SherjilOzair:build sherjilozair$ examples/05_triangle
Initialized SDL: ''
[2018-05-04 20:20:01.819393][Error] Error in OpenGL call:
Location: /Users/sherjilozair/gf/library/Window.cc:111
Expression: glEnable(GL_BLEND)
Error: GL_INVALID_ENUM
Description: An unacceptable value is specified for an enumerated argument.
Gamedev Framework (gf) example #05: Triangle
This example prints the hello world triangle of OpenGL.
You can click on the screen to see the screen coordinates and world coordinates.
#include "animal.h"
void Animal::inc(int i){
this->counter += i;
}
void Animal::say(){
std::cout << this->counter << std::endl;
}
@sherjilozair
sherjilozair / main.c
Last active March 27, 2025 06:29
Minimal SDL2 + OpenGL3 example
#include <SDL2/SDL.h>
#ifdef __APPLE__
#include <OpenGL/gl3.h>
#include <OpenGL/gl3ext.h>
#else
#include <GL/gl.h>
#endif
#include <stdbool.h>
#define CODE(...) #__VA_ARGS__
#include <stdio.h>
typedef struct Color{
int r, g, b, a
} Color;
typedef struct Vertex{
float x, y, z;
Color color;
} Vertex;
@sherjilozair
sherjilozair / sdl-sokol-sprite.c
Created June 9, 2018 14:05
Minimal sprite rendering example with SDL2 for windowing, sokol_gfx for graphics API using OpenGL 3.3 on MacOS
#include <OpenGL/gl3.h>
#include <SDL2/SDL.h>
#define SOKOL_IMPL
#define SOKOL_GLCORE33
#include <sokol_gfx.h>
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
#define CODE(...) #__VA_ARGS__
/*
* Nuklear - 1.32.0 - public domain
* no warrenty implied; use at your own risk.
* authored from 2015-2016 by Micha Mettke
*/
/*
* ==============================================================
*
* API
*
@sherjilozair
sherjilozair / celeste.lua
Created June 17, 2018 19:18
Source code for pico-8 version of Celeste
-- ~celeste~
-- matt thorson + noel berry
-- globals --
-------------
room = { x=0, y=0 }
objects = {}
types = {}
freeze=0
import numpy as np
import itertools
import gym
import random
env = gym.make("BowlingNoFrameskip-v4")
def enact(step, partitions, actions):
step = step % partitions[-1]
for p, a in zip(partitions, actions):
if step < p: