git clone https://github.com/ahiguti/HandlerSocket-Plugin-for-MySQL.git
cd HandlerSocket-Plugin-for-MySQL
./autogen.sh
./configure --disable-handlersocket-server
make
sudo make install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
$@ | |
if [ "$?" = "0" ] | |
then | |
growlnotify --image /Users/vince/bin/images/doom_succ.png --message "$1" Command Succeeded! | |
else | |
growlnotify --image /Users/vince/bin/images/doom_fail.png --message "$1" Command Failed! | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.actors.Actor | |
import scala.actors._ | |
import scala.collection.mutable.Map | |
import java.io._ | |
import java.net.{InetAddress,ServerSocket,Socket,SocketException} | |
class Coordinator extends Actor { | |
var clients = Map[String, Client]() | |
var numClients = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BoyerMoore | |
attr_accessor :text | |
attr_reader :pattern, :matches | |
def initialize( opts ) | |
@text = opts[:text] | |
end | |
def search( pattern_str ) | |
@pattern = Pattern.new( pattern_str ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.collection.mutable.ArrayBuffer | |
class Pattern(val pattern: String) { | |
val length = pattern.length | |
def shiftBy(badChar: Char, pos: Int): Int = { | |
scala.math.max(badCharShift(badChar, pos), goodSuffixShift(pos)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find k-smallest integers from an array of N integers | |
# | |
# Given an array of N integers in no particular order, what is the fastest | |
# way to determine which are the smallest k of them? | |
# | |
# Solution: Use a heap! | |
# | |
# First, the solution of this problem seems easy. Just sort the N-Array, and | |
# take the first K-values. Indeed, in Ruby, this can be done as a simple | |
# one-liner: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# >> Heap | |
# | |
# A Heap or Max heap is a data structure based on a tree that satisfies the | |
# Heap property: | |
# | |
# If K is a child of J, then val(J) >= val(K) | |
# | |
# In other words, the value of the parent node is always greater than or equal | |
# to the value of its children. Because of this property, the root of the tree | |
# will *always* be the largest value stored in the heap. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
binwidth = ARGV[0].to_f | |
filename = ARGV[1] | |
rand_file_name = "rand_file-#{(rand*1000000).to_i}.data" | |
nums = File.open(filename, "r") {|f| f.readlines}.collect {|n| n.to_f } | |
binned_data = {} | |
nums.each do |n| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> Loofah::Helpers.strip_tags("<script>var foo;</script>") | |
=> "<script>var foo;</script>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> num = 5.0/3 | |
>>> print "num = %.2f" % (num) | |
num = 1.67 | |
>>> print "num = %.3f" % (num) | |
num = 1.667 | |
>>> print "num = %6.3e" % (num) | |
num = 1.667e+00 |