Skip to content

Instantly share code, notes, and snippets.

@vo
vo / f.cpp
Created September 13, 2010 06:43
// Problem F: Three Sides Make A Triangle
// Author: Christopher Vo
#include <cstdio>
#include <cmath>
#define TOLERANCE 0.01
#define swap(a,b,c) {c t=a; a=b; b=t;}
double len(double x1, double y1, double x2, double y2)
{
#! /usr/bin/env python
# A script to delete all e-mails over IMAP
import imaplib, getpass
host = 'imap.server.com'
port = 993
user = 'user'
@vo
vo / D.cpp
Created September 15, 2010 21:32
// Problem D: A Round Peg in a Ground Hole
// Author: Christopher Vo
#include <iostream>
#include <cmath>
using namespace std;
struct Point
{
double x, y;
/*
* ACM 534: Frogger (ANSI C version)
* Author: Christopher Vo (cvo1@cs.gmu.edu)
*/
#include <stdio.h>
#include <math.h>
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max(a, b) (((a) > (b)) ? (a) : (b))
struct point {
int x, y;
// Frogger
// # 534
// tags: dijkstra's, minimax, frogs
//
// by jamesob
import java.util.*;
public class Main {
@vo
vo / travel.c
Created October 19, 2010 17:33
#include <stdio.h>
#include <string.h>
int main()
{
int n, roads, min, i, j, k, l, u, v;
while (scanf("%d %d %d", &n, &roads, &min) == 3 && n != 0)
{
char A[n][n], P[n][n], tmp[n][n];
int n2 = n * n;
@vo
vo / StopWatch.java
Created November 4, 2010 10:08
A Simple Multiple-Stopwatch Application
// StopWatch
// Simple multiple-stopwatch application
// Author: Christopher Vo (cvo1@cs.gmu.edu)
public class StopWatch extends javax.swing.JFrame {
private static final long serialVersionUID = -7040646868513878300L;
private static int numTimers = 5;
public StopWatch() {
// make main window
@vo
vo / gist:765273
Created January 4, 2011 19:37
Example for how to use m+2d
void simMKPusher::computeOffset()
{
c_mksum mksum;
c_ply & p = getP();
p.beginPoly();
for (int i = 0; i < m_target_border.size; i++)
p.addVertex(m_target_border.data[i].x(), m_target_border.data[i].y());
p.endPoly();
@vo
vo / gist:783202
Created January 17, 2011 18:26
Tiny Script to get Number of Search Results for wu*t
#!/usr/bin/env python
# getting number of search results from google
# by christopher vo
import urllib2, re, time
reg = re.compile('About(.*?)results')
for i in range(1, 20):
wut = 'w' + 'u'*i + 't'
url = 'http://www.google.com/search?q=' + wut
request = urllib2.Request(url)
request.add_header('User-agent', 'Chrome')
@vo
vo / gist:888679
Created March 26, 2011 22:04
heisenbug!
// this works!
for (RigidBodyList::const_iterator i = rigid_bodies.begin(),
end = rigid_bodies.end(); i != end; ++i) {
1+1; // do nothing
checkCollision(target_body, *i);
}
// this does not work.
for (RigidBodyList::const_iterator i = rigid_bodies.begin(),
end = rigid_bodies.end(); i != end; ++i) {