Skip to content

Instantly share code, notes, and snippets.

View leegao's full-sized avatar
💭
Backpacking the 🌍

Lee Gao leegao

💭
Backpacking the 🌍
View GitHub Profile
def getAllNeighbors(origin, steps = 1):
seen = {origin}
worklist = [origin]
while steps:
new_worklist = []
for next in worklist:
seen.add(next)
for neighbor in next.get_all_neighbors(15):
if neighbor not in seen: new_worklist.append(neighbor)
worklist = new_worklist
\documentclass[11pt,a4paper,svgnames]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb,amsthm}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{algorithm}
\usepackage{algorithmicx}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@leegao
leegao / patch.c
Last active February 26, 2016 23:20
// Let's not mangle these names
extern "C" {
#include "lua.h"
#include "lauxlib.h"
#include <sys/mman.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
@leegao
leegao / patch.c
Last active February 26, 2016 23:32
Null-packet protection
// Let's not mangle these names
extern "C" {
#include "lua.h"
#include "lauxlib.h"
#include <sys/mman.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
// Let's not mangle these names 0x0819ec3c
extern "C" {
#include <lua5.2/lua.h>
#include <lua5.2/lauxlib.h>
#include <sys/mman.h>
#include <stdio.h>
#include <limits.h>
#ifndef PAGESIZE
#define PAGESIZE 4096
'BLD18qQhOwEylkVki91hjILTcIwbEMhUHamjkAzgyIWnl1tqOZvO+7AvOTqn036uyHAQVVbSH3/BzYMjNHTMXvogJBWI1siiMZF2zFzD0GEpuGdF+WbSIrug4fzHojQ/AAaBx2HT/tZ8hP+ITRc8z9a7ecsrGX+EBq+b3mada6zeJPxE2j47psb/J4Xnx0AEfh+lEb2GLpczI7e3o0BGP9GlmQYPSXINq87N2D8G175+cBwbMmzdfsIxr9hNGJgLGTFe/NdMP6NoAERNJOij9vzbgwiaOpdvmqBkV2HLp//Pj28HgIc392BrzFQ/slGN0/TqxugL1UY9GMpmI+GQVDSMzswGVWZ5VMjs4sSvkAmQ/p5AnrRyDoszxO+SKI5HV+OwHS0G7NcKXUMCx32xk6mVNxcpl0DwivGhJuvk/gphiG0b2f0gciQaaDJzuOJASND397ryTg4EuRYRw8D2A1lNF5lGEkzxMCGi56t4zCLduBcROWbbjBKKZer6enhbgsEytVBmzo4ONfQ+ZFv3sLhaEb72lnMkVKDD3tw7hzAoL86ObHGLOEGMUY3n9wihn1peBNBTcL3kSfH4/t9KF4qZ3GtXA++WO1h5/0edqVhDygXMUzQ87EZvcGuqLMk6iR08pFBO529aAADg8o9hHKfspYvwghDW/5HtJGL7CrGpE4Sr8FnvNvv7J3AGa9csWrhMB00P/dupnCafDuJAeCgFL0l'
@leegao
leegao / qsqrt.c
Last active August 29, 2015 13:56
See http://www.phailed.me/2012/08/somewhat-fast-square-root/ for the full derivation, including the error compensation trick, except I later discovered 3/7 worked better than 2/5
/*
* qsqrt.c
*
* Created on: Jun 6, 2012
* Author: Lee
*/
#include <stdio.h>
#include <math.h>
@leegao
leegao / graphviz.c
Last active December 30, 2015 20:09
graphviz generator
#include <stdio.h>
#include "minifile.h"
#include "minifile_private.h"
#include "minithread.h"
#include "miniheader.h"
/*
node [shape = record,height=.1];
nodei - ith block
\documentclass[11pt,a4paper]{article}
%\usepackage{fullpage}
\usepackage[total={6.5in,8.75in},
top=1.2in, left=0.9in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath, amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}