Skip to content

Instantly share code, notes, and snippets.

View alecbz's full-sized avatar

Alec Benzer alecbz

View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
typedef struct node {
int data;
struct node* next;
} node;
node* new_node() {
node* n = malloc(sizeof(node));
void renderText(TTF_Font* font, string text) {
SDL_Color color = {255, 0, 0};
SDL_Surface* rendered = TTF_RenderText_Solid(font, text.c_str(), color);
// slightly modified from http://stackoverflow.com/questions/5289447/using-sdl-ttf-with-opengl
GLint colors = rendered->format->BytesPerPixel;
GLenum format;
if (colors == 4) { // alpha
if (rendered->format->Rmask == 0x000000ff) {
format = GL_RGBA;
let start k = k []
let push stack x k = k (x :: stack)
let pop (_ :: stack) k = k stack
let add (a :: b :: stack) k = k (a + b :: stack)
let stop (x :: _) = x
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int a;
} foo_t;
int main() {
foo_t *a;
a = calloc(10, sizeof(foo_t));
#include <stdio.h>
int main() {
unsigned int x = 11;
printf("count:"" %u", x);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
unsigned int countOnes(unsigned int input) {
// lab answer here
}
unsigned int countOnesSlow(unsigned int input) {
int count = 0;
package main
import (
"bufio"
"fmt"
"os"
"unicode"
)
type node struct {
I don't know if using a tool like [ctrlp for vim](https://github.com/kien/ctrlp.vim) is always such a great idea, especially when exploring a directory structure that you're unfamiliar with. ctrlp is great, and I love it for things like rails projects, where I more or less know where all the files are but I'm getting ready to bash my head in from having to type app/views/post/show.html.erb in 50 billion times.
Unfortunately, I'm also tempted to love ctrlp in situations where I'm not familiar with the directory structure. While going through some google training exercises, there are parts that go "open blah.cc", which happens to reside in a directory structure I'm not so familiar with. It's really tempting to just ctrl+p and type "blah.cc", but now I have no idea where the file was, and I get to go on doing stuff without getting an understanding of the directory structure. It's much better to spend some time digging through the directory tree to see what's what and where what is.
Fuzzy finders like cltrp are
#inclsdfsdf
s
fsd
faf
sdf
#include <iostream>
#include <fstream>
#include <set>
#include <algorithm>
#include <cctype>
using namespace std;
class Trie
{
public: