Skip to content

Instantly share code, notes, and snippets.

View chucknthem's full-sized avatar

Charles Ma chucknthem

View GitHub Profile
package rx.internal.util.unsafe;
import java.lang.reflect.Field;
public class Unsafe {
public int getIntVolatile(Object obj, long offset) {
return 0;
}
@chucknthem
chucknthem / nodeproxysniffer.js
Created November 25, 2010 12:29
Proxy server in node js, logs http requests
var http = require('http');
var sys = require('sys');
server = http.createServer(function(request, response) {
sys.log(request.connection.remoteAddress + ": " +
request.method + " " +
request.url);
var proxy = http.createClient(80, request.headers['host']);
#include <stdio.h>
#include <string.h>
#include <malloc.h>
char * rot(const char *origStr, int shift) {
char *newStr = (char*)malloc(strlen(origStr) + 1);
int i = 0;
while(origStr[i]) {
if('a' <= origStr[i] && origStr[i] <= 'z') {
newStr[i] = (origStr[i] - 'a' + shift)%26 + 'a';
#include <stdio.h>
#include <malloc.h>
#include <assert.h>
void printArray(int *array, int low, int high) {
while(low <= high) {
printf("%d ", array[low++]);
}
printf("\n");
}
void swap(int *a, int *b) {
#include <stdio.h>
#include <malloc.h>
int nextPrime(int i, char *sieve, int max) {
while(i < max && !sieve[i]) {
i++;
}
return i;
}
void setNotPrime(int i, char *sieve, int max) {
var fs = require("fs");
/**
* Asyncronous file appender in node js that allows you to easily append to a file
* without doing it all once
*/
var Appender = function(filename) {
var queue = Array();
var isOpen = false;
var curObj = this;