Skip to content

Instantly share code, notes, and snippets.

@anlsh
anlsh / unspoiler_avatar.user.js
Created August 24, 2014 22:21
Remove spoiler tags from /r/TheLastAirbender
// ==UserScript==
// @name Unspoiler Avatar
// @namespace unspoiler_avatar.pipsqueaker
// @include http://www.reddit.com/r/TheLastAirbender/
// @include http://www.reddit.com/r/TheLastAirbender/*
// @include https://www.reddit.com/r/TheLastAirbender/
// @include https://www.reddit.com/r/TheLastAirbender/*
// @version 1
// @grant none
// ==/UserScript==
HAI 1.2
BTW This program can multiply or divide two inputs
OBTW Execute this at
http://repl.it/0VH/6
TLDR
I HAS A NUM
I HAS A BUM
I HAS A DEEZIRE
@anlsh
anlsh / draw_triangle
Created March 11, 2015 22:18
Could I have help diagnosing the problem in this?
#define GLEW_STATIC
#include <GL/glew.h>
#include "SDL2/SDL.h"
#include "SDL2/SDL_opengl.h"
#include "iostream"
const GLchar* vertexSource =
"#version 150 core\n"
@anlsh
anlsh / gist:eab5c250a8d84a336e95
Created May 31, 2015 16:39
Undefined errors, oh no!
/tmp/ccgA5o4g.o: In function `__Pyx_PyObject_GetAttrStr':
common.c:(.text+0xb1): undefined reference to `PyObject_GetAttr'
/tmp/ccgA5o4g.o: In function `__pyx_pf_6common_sin':
common.c:(.text+0x291): undefined reference to `PyMethod_Type'
common.c:(.text+0x3e9): undefined reference to `PyTuple_New'
common.c:(.text+0x5a2): undefined reference to `PyMethod_Type'
common.c:(.text+0x736): undefined reference to `PyTuple_New'
/tmp/ccgA5o4g.o: In function `__pyx_pf_6common_2cos':
common.c:(.text+0xc9f): undefined reference to `PyMethod_Type'
common.c:(.text+0xdf7): undefined reference to `PyTuple_New'
@anlsh
anlsh / Common.h
Last active August 29, 2015 14:23
#ifndef LEARNOPENGL_COMMON_H
#define LEARNOPENGL_COMMON_H
#define GLEW_STATIC
#include <GL/glew.h>
#include <SDL2/SDL_opengl.h>
#include "vector"
#include "common.h"
int main() {
std::vector<GLfloat> source = {1, 2, 3, 4, 5, 6, 5, 6, 1, 2, 7, 8};
std::vector<GLfloat> * optimized_verts = new std::vector<GLfloat>();
std::vector<GLint> ebo = {};
common::GenOptimizedArrays<GLfloat, GLint>(2, &source, optimized_verts, &ebo);
namespace common {
template<typename V, typename E>
void GenOptimizedArrays(const int& vertex_size, const std::vector<V> & vertex_source,
std::vector<V> *vertex_out, std::vector<E> *ebo_out) {
bool vertex_is_unique = true;
vertex_out->insert(vertex_out->end(), vertex_source.data(), vertex_source.data() + 2);
ebo_out->push_back(0);
@anlsh
anlsh / Shaders.h
Last active August 29, 2015 14:25
#ifndef TINY2D_SHADERS_H
#define TINY2D_SHADERS_H
#define GLEW_STATIC
#include <GL/glew.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
#include <stdexcept>
#include <fstream>
#include "Shaders.h"
t2d::Shader::Shader(const char * foo, GLenum type, int loadmode = LOAD_FROM_FILE) {
if (loadmode == LOAD_FROM_FILE) {
std::ifstream in(foo);
source = std::string((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
glSource = (GLchar *) source.c_str();
} else if (loadmode == LOAD_FROM_STRING) {
#define GLEW_STATIC
#include <GL/glew.h>
#include "SDL2/SDL.h"
#include "SDL2/SDL_opengl.h"
#include "shaders.h"
#include <iostream>
#include <typeinfo>