Skip to content

Instantly share code, notes, and snippets.

View talhasyed's full-sized avatar

Talha Umer Syed talhasyed

View GitHub Profile
@talhasyed
talhasyed / score_sc2_squad.md
Created September 9, 2011 17:55
Score SC2 Squad

Talha

  • username: tlithralas
  • name: Talha Syed
  • character code: 190

David

  • username: OtherEye
  • name: David Evans
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'redis'
r = Redis.new
r.select("1")
loop do
doc = Nokogiri::XML(open("http://blogs.thescore.com/tbj/feed/?#{rand(1000)}=#{rand(1000)}"))
class GameOfLife
attr_accessor :state, :height, :width, :rules
def initialize options={}
self.rules = options[:rules] || [ [0,0,0,1,0,0,0,0,0], [0,0,1,1,0,0,0,0,0] ]
self.height = options[:size] || options[:height] || 10
self.width = options[:size] || options[:width] || 10
self.state = options[:seed] || grid { rand(2) }
require 'soap/wsdlDriver'
class Akamai
WSDL_URL = "https://ccuapi.akamai.com/ccuapi-dotnet.wsdl"
# To debug, put @soap_client.wiredump_file_base = "log"
def self.purge(*urls)
@soap_client = SOAP::WSDLDriverFactory.new(WSDL_URL).create_rpc_driver
# with/without email notification
require 'rubygems'
require 'RMagick'
require 'pp'
include Magick
CURRENT_DIR = File.dirname(File.expand_path(__FILE__)) + "/"
country_names = [
"Algeria",
"Argentina",
# This was during the whole only 10% of programmers can write a binary search on their first try
# Ars Technica had a thread on the issue at http://arstechnica.com/civis/viewtopic.php?f=20&t=1106689
def search(number, array=[])
return false if array.empty?
middle = array.length/2
number_at_middle = array[middle]
return true if number_at_middle==number
return false if array.length==1 && !(number_at_middle==number) # program failed before, it was missing this line
@cached_leaders[:meta] ||= {}
@cached_leaders[:meta][:stat_period] = season.current_interval_name
defaults write com.macromates.textmate OakDefaultLanguage E00B62AC-6B1C-11D9-9B1F-000D93589AF6
@talhasyed
talhasyed / k_means_clustering.rb
Created March 19, 2010 20:39
Just trying out K-Means Clustering by following a blog post about it
require 'pp'
def k_means_cluster(clusters=[[]])
# pp clusters
clusters_with_centroids = clusters.inject({}) do |centroids, cluster|
cluster_centroid = (cluster.inject(0.0) {|item, sum| sum+=item})/cluster.size
centroids[cluster_centroid] = cluster
centroids
### API ###
# LyrisMember
# SelectMember(email, list)
"http://lyris-servis.kaboose.com/[email protected]&list=kaboose_crafts" # [lyris_member, ...]
# EmailOnWhatLists(email)
"http://lyris-servis.kaboose.com/users/12345/lists" # returns [newsletter.to_xml, ...]
# CreateSingleMember(email, name, list)
"http://lyris-servis.kaboose.com/users" # POST request with list name, demographics etc