This file contains hidden or 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 Post | |
| include MongoMapper::Document | |
| key :title, String | |
| end |
This file contains hidden or 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 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 |
This file contains hidden or 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
| # 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 |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| 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." |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| def foo | |
| bar = 1 | |
| end |
This file contains hidden or 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 | |
| while [ 1=1 ] | |
| do | |
| echo $(sysbench --test=cpu --max-time=2 run | egrep "events") -- $(date + %H:%M:%S) | |
| done |
This file contains hidden or 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
| def fetch | |
| data = {} | |
| begin | |
| io = open(URI.encode(@baseurl)) | |
| doc = Nokogiri::HTML(io) | |
| io.close! | |
| # ... process doc ... | |
| end | |
| rescue Errno::ETIMEDOUT | |
| return nil |
This file contains hidden or 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
| 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. |
OlderNewer