Skip to content

Instantly share code, notes, and snippets.

View kevinpet's full-sized avatar

Kevin Peterson kevinpet

View GitHub Profile
#!/usr/bin/env ruby
# http://kdpeterson.net
# Copyright (c) 2009 Kevin Dempsey Peterson
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
class Mention
attr_accessor :topic, :prominence, :topic_sentiment, :other_sentiment
def initialize(topic, prominence, topic_sentiment, other_sentiment)
@topic = topic
@prominence = prominence
if(topic == "Apples")
topic_sentiment = topic_sentiment ** 3
elsif topic == "Bananas"
topic_sentiment = Math.sqrt topic_sentiment
end
<?php
# Nucleus legacy incoming links redirect script
# see blog post at http://kdpeterson.net/blog/ for explanation
$items = array(
"27" => "2007/05/1846-the-murder-of-jose-de-los-reyes-berreyesa-and-the-twin-brothers-named-haro-by-a-group-of-bear-f.html",
"43" => "2008/03/the-widescreen-rip-off-11-less-for-the-same-price.html",
"45" => "2008/03/changing-location-url-of-svn-repository-in-eclipse-1.html",
"46" => "",
<?php
# Nucleus legacy incoming links redirect script
# see blog post at http://kdpeterson.net/blog/ for explanation
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://$host$uri/atom.xml");
?>
package org.apache.hadoop.hbase.client.tableindexed;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.Map;
import org.apache.hadoop.hbase.util.Bytes;
/**
#!/usr/bin/ruby
require 'rubygems'
require 'hbase'
transport = Thrift::BufferedTransport.new(Thrift::Socket.new('127.0.0.1', 9090))
protocol = Thrift::BinaryProtocol.new(transport)
client = Apache::Hadoop::Hbase::Thrift::Hbase::Client.new(protocol)
transport.open
# Return a timestamp from an HBase cell
# [cell] the cell itself or its contents
def self.time_from_hbase(cell)
# unpack 8 bytes in network (big endian) byte order
if cell.respond_to? :value
a = cell.value
else
a = cell
end
halves = a.unpack "NN"
#!/usr/bin/ruby
require 'rubygems'
require 'redis'
REDIS_CMD = "./redis-server"
DIR = "redis-repl-test"
FileUtils.mkdir(DIR) unless File.directory?(DIR)
class Redis
@kevinpet
kevinpet / emacs.rb
Created September 25, 2011 16:34 — forked from rust/emacs.rb
Homebrew Emacs for OSX Lion with native full-screen
require 'formula'
class Emacs < Formula
url 'http://ftp.gnu.org/pub/gnu/emacs/emacs-23.3a.tar.bz2'
md5 'f2cf8dc6f28f8ae59bc695b4ddda339c'
homepage 'http://www.gnu.org/software/emacs/'
if ARGV.include? "--use-git-head"
head 'git://repo.or.cz/emacs.git'
else
@kevinpet
kevinpet / Nullery.java
Created April 11, 2012 16:57 — forked from anonymous/Nullery.java
Nullery: self-aware nulls for testing
public class Nullery {
private static MockObjectNamingScheme namingScheme = new CamelCaseNamingScheme();
private static Imposteriser imposteriser = ClassImposteriser.INSTANCE;
public static <T> T nulled(Class<T> typeToNull) {
return nulled(typeToNull, namingScheme.defaultNameFor(typeToNull));
}
public static <T> T nulled(Class<T> typeToMock, final String name) {