Skip to content

Instantly share code, notes, and snippets.

View bryanbibat's full-sized avatar

Bryan Bibat bryanbibat

View GitHub Profile
@bryanbibat
bryanbibat / team_x_prob_a.rb
Created December 3, 2012 15:43
DevCon Code Challenge Cup Solutions
def trunc(x)
(x * 100.0).floor / 100.0
end
output = File.open("bestfit2.txt", "w")
count, point_count, points, = nil, nil, nil
IO.readlines("bestfit.txt").each do |line|
@bryanbibat
bryanbibat / gist:4160851
Created November 28, 2012 12:21
C-cup installation
sudo apt-get install build-essential ruby1.9.1 php5-cli mono-complete mono-vbnc nodejs-legacy openjdk-7-jdk
@bryanbibat
bryanbibat / meh.txt
Last active October 10, 2015 09:17
ruby from source (ubuntu)
$ sudo apt-get -y install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev autoconf libc6-dev libncurses5-dev automake libtool bison subversion
$ wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
$ tar xvf yaml-0.1.4.tar.gz
$ cd yaml-0.1.4
$ ./configure
@bryanbibat
bryanbibat / ab2x.txt
Created August 1, 2012 03:20
nginx with file-based caching
bry@linode:~$ ab -n 1000 -c 20 http://pd.bryanbibat.net/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking pd.bryanbibat.net (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
@bryanbibat
bryanbibat / apache-bench.txt
Created July 31, 2012 14:48
A few tweaks later...
bry-temp@webgeek:~# ab -n 1000 -c 20 http://webgeek.ph/devcup/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking webgeek.ph (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
@bryanbibat
bryanbibat / pagelines-retina.js
Created June 23, 2012 23:47
Replaces the title and all images with class="retina" in a WP blog that uses Pagelines theme
//logic shamelessly copied from https://github.com/imulus/retinajs
jQuery(document).ready(function() {
var replaceRetina = function(elem) {
if (elem.complete) {
var src = elem.src;
var path_segments = src.split('.');
var path_without_extension = path_segments.slice(0, (path_segments.length - 1)).join(".");
var extension = path_segments[path_segments.length - 1];
elem.setAttribute('width', elem.offsetWidth);
@bryanbibat
bryanbibat / stemmer.coffee
Created June 1, 2012 05:31
Custom implementation of the Porter2 stemming algorithm
class Stemmer
# Custom implementation of the Porter2 stemming algorithm
# http://snowball.tartarus.org/algorithms/english/stemmer.html
@getStems: (text) ->
exclusionList = ["", ",", "/", "&", "of", "the", "by", "a", "*", "-", "'", "'s", "=", ">", "s'", "\"", "~", "and", "with", "for", "in", "500ml", "to", "at", "or", "n", "x", "pcs"]
stems = (@stem(word) for word in text.split /[ ,()!:@\/]/)
(word for word in stems when word not in exclusionList and word.search(/^[\d]+(\.[\d]+)?"?$/) == -1)
@stem: (word) ->
@bryanbibat
bryanbibat / dog.rb
Created May 7, 2012 05:23
assessment test spoilers
class Animal
def initialize(name, age)
@name, @age = name, age
end
def getName
@name
end
def getAge
@bryanbibat
bryanbibat / .vimrc
Created May 2, 2012 16:57
my gvim vimrc
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'bzx/vim-theme-pack'
Bundle 'ap/vim-css-color'
@bryanbibat
bryanbibat / neural_network.coffee
Created April 10, 2012 06:28
Basic feedforward neural network that's coded by every kid who took an AI class in college. Test case for XOR training included.
class Synapse
constructor: (@sourceNeuron, @destNeuron) ->
@prevWeight = @weight = (Math.random() * 2.0) - 1.0
class Neuron
learningRate: 1.0
momentum: 0.3
constructor: ->
@synapsesIn = []