Skip to content

Instantly share code, notes, and snippets.

View alexhanh's full-sized avatar

Alexander Hanhikoski alexhanh

View GitHub Profile
class Post
include MongoMapper::Document
key :title, String
end
import sc2reader
from sc2reader.exceptions import ParseError
replay = sc2reader.read("1.SC2Replay")
print replay.build
print replay.release_string
for event in replay.events:
print event.name
# Replay
# has_many :plays, :dependent => :destroy
# has_many :players, :through => :plays
# Nested include
replay = Replay.includes(:plays => [:player]).where(:id => 1361).first
for play in replay.plays
p play.player.name
SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"players"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
def set_event
pack = Pack.includes(:replays).find(params[:id])
if !params[:event_id].nil? && !params[:event_id].empty?
event = Event.find(params[:event_id])
pack.replays.update_all(:event_id => event.id)
else
pack.replays.update_all(:event_id => nil)
end
redirect_to pack, :notice => "Event has been updated succesfully for all pack's replays."
@alexhanh
alexhanh / attack.log
Created July 9, 2011 03:31
Attack on drop.sc 9.7.2011
Started GET "/muieblackcat" for 211.20.239.143 at 2011-07-09 02:52:27 +0000
Started GET "/scripts/setup.php" for 211.20.239.143 at 2011-07-09 02:52:33 +0000
Started GET "/admin/scripts/setup.php" for 211.20.239.143 at 2011-07-09 02:52:34 +0000
Started GET "/admin/pma/scripts/setup.php" for 211.20.239.143 at 2011-07-09 02:52:36 +0000
Started GET "/admin/phpmyadmin/scripts/setup.php" for 211.20.239.143 at 2011-07-09 02:52:37 +0000
Started GET "/db/scripts/setup.php" for 211.20.239.143 at 2011-07-09 02:52:38 +0000
Started GET "/dbadmin/scripts/setup.php" for 211.20.239.143 at 2011-07-09 02:52:40 +0000
Started GET "/myadmin/scripts/setup.php" for 211.20.239.143 at 2011-07-09 02:52:41 +0000
Started GET "/mysql/scripts/setup.php" for 211.20.239.143 at 2011-07-09 02:52:42 +0000
Started GET "/mysqladmin/scripts/setup.php" for 211.20.239.143 at 2011-07-09 02:52:43 +0000
def foo
bar = 1
end
#!/bin/bash
while [ 1=1 ]
do
echo $(sysbench --test=cpu --max-time=2 run | egrep "events") -- $(date + %H:%M:%S)
done
def fetch
data = {}
begin
io = open(URI.encode(@baseurl))
doc = Nokogiri::HTML(io)
io.close!
# ... process doc ...
end
rescue Errno::ETIMEDOUT
return nil
def better_fetch
data = {}
io = nil
begin
io = open(...)
rescue OpenURI::HTTPError => e
# Handle interesting http errors
rescue Timeout::Error, StandardError
# It was most likely a Net/Socket error we are not interested in, so just fail.