Skip to content

Instantly share code, notes, and snippets.

View bryanbibat's full-sized avatar

Bryan Bibat bryanbibat

View GitHub Profile
openssl req -new -sha1 -newkey rsa:1024 -nodes -keyout client.key -out request.pem
mkdir -p demoCA/newcerts
touch demoCA/index.txt
touch demoCA/index.txt.attr
vim demoCA/serial
sudo openssl ca -cert /etc/ssl/certs/ssl-cert-snakeoil.pem -keyfile /etc/ssl/private/ssl-cert-snakeoil.key -policy policy_anything -out signed.pem -infiles request.pem
sudo openssl pkcs12 -export -in signed.pem -inkey client.key -certfile /etc/ssl/certs/ssl-cert-snakeoil.pem -name "testp12" -out test-p12.p12
<div class="field">
<input id="ballot_city_quezon_city" name="ballot[city]" type="radio" value="Quezon City" />
<label for="ballot_city_quezon_city">Quezon City</label>
</div>
<div class="field">
<input id="ballot_city_manila" name="ballot[city]" type="radio" value="Manila" />
<label for="ballot_city_manila">Manila</label>
</div>
...
class Node
attr_accessor :value, :next
def initialize(value)
@value = value
end
end
class LinkedList
attr_accessor :head, :tail
def initialize
@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 = []
@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 / 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 / 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 / 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 / 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 / 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