Skip to content

Instantly share code, notes, and snippets.

View pathsny's full-sized avatar

Vishnu Iyengar pathsny

View GitHub Profile
@pathsny
pathsny / formula.rb
Created September 28, 2012 16:20
php52
This file has been truncated, but you can view the full file.
require 'formula'
class Php52 <Formula
@url='http://www.php.net/get/php-5.2.17.tar.bz2/from/www.php.net/mirror'
@version='5.2.17'
@homepage='http://php.net/'
@md5='b27947f3045220faf16e4d9158cbfe13'
depends_on 'jpeg'
depends_on 'freetype'
@pathsny
pathsny / cycle_detection.js
Created June 7, 2012 21:08
About toBridge
var _ = require('underscore');
function serialize(arr, object) {
if (_(arr).contains(object))
{
throw "cycle detected";
}
var szfn = _(serialize).bind(null, arr);
@pathsny
pathsny / client.js
Created May 22, 2012 16:21
test of timed events on node
var http = require('http');
var client = http.createClient(1337, 'localhost'); // to access this url i need to put basic auth.
for (var j=0; j<=100000; j++) {
var request = client.request('GET', '/',
{'host': 'www.example.com'});
request.end();
}
{-# LANGUAGE BangPatterns #-}
module Main where
import System.IO
import System.Environment (getArgs)
import Control.Arrow (first)
main = do
handle <- openFile "IntegerArray.txt" ReadMode
numbers <- fmap (map read . lines) $ hGetContents handle
print (countInversions numbers)
@pathsny
pathsny / inversions.hs
Created March 23, 2012 22:27
Inversions
module Main where
import System.IO
import System.Environment (getArgs)
main = do
handle <- openFile "IntegerArray.txt" ReadMode
numbers <- fmap (map read . lines) $ hGetContents handle
print (countInversions numbers)
hClose handle
@pathsny
pathsny / gist:1549496
Created January 2, 2012 05:41
gzip http data
var http = require('http');
zlib = require('zlib')
var request = http.get({ host: 'www.desilva.biz',
path: '/php/zlib.html',
port: 80,
headers: { 'accept-encoding': 'gzip,deflate' } });
request.on('response', function(resp){
var headers = resp.headers['content-encoding']
@pathsny
pathsny / gist:1548058
Created January 1, 2012 19:04
require error
> require('compress')
Error: Cannot find module 'compress'
at Function._resolveFilename (module.js:334:11)
at Function._load (module.js:279:25)
at Module.require (module.js:357:17)
at require (module.js:368:17)
at repl:1:2
at REPLServer.eval (repl.js:80:21)
at Interface.<anonymous> (repl.js:182:12)
at Interface.emit (events.js:67:17)
@pathsny
pathsny / request_with_caching.js
Created May 2, 2011 07:07
request with caching
request: function(options, cb) {
var cache;
if (options.cache) cache = './data/cache/' + options.cache;
var http_req = function() {
req(options, function(error, response, body){
if (!error && options.cache) {
if (response.headers['content-encoding'].search('gzip') != -1) {
// UHOH
}
@pathsny
pathsny / keeploggedin.rb
Created April 21, 2011 21:28
keeploggedin.rb
#! /usr/bin/ruby
require 'rubygems'
require 'syslog_logger'
require 'net/http'
require 'logger'
COOKIE_FILE = File.expand_path('../cookies.yml', __FILE__)
def log
@log ||= SyslogLogger.new('keep_logged_in')
var sys = require('sys');
var irc = require('irc');
var channel = "#animestan";
var incoming = 'message' + channel;
function make_client(server) {
var client = new irc.Client(server, 'ze_bot', {
channels: [channel],
});
client.addListener('error', function(message) {