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
<?php | |
$searchURL = "http://services.runescape.com/m=hiscore/overall.ws"; | |
$perPage = 22; | |
$namesToReturn = 1; | |
for ($index = 1; $index <= $namesToReturn; $index++) | |
{ | |
// $search = rand(1, 500000); |
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
EXPLAIN ANALYZE | |
SELECT COUNT(*) FROM j_msg | |
Row QUERY PLAN | |
1 Aggregate (cost=1360105.49..1360105.50 rows=1 width=0) (actual time=140042.984..140042.985 rows=1 loops=1) | |
2 -> Seq Scan on j_msg (cost=0.00..1318772.99 rows=16532999 width=0) (actual time=8.377..137051.294 rows=16532999 loops=1) | |
3 Total runtime: 140057.576 ms | |
==== |
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
framework "ScriptingBridge" | |
unless `ps aux | grep Safari.ap[p]` == "" | |
safari ||= SBApplication.applicationWithBundleIdentifier("com.apple.Safari") | |
if ARGV.empty? | |
safari.windows.each do |window| | |
puts "Window #{window.index}:" | |
window.tabs.each do |tab| | |
puts "\t#{tab.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
rows = 8 | |
t = [] | |
rows.times do |i| | |
t[i] = [] | |
(i+1).times do |j| | |
if j == 0 || j == i | |
t[i] << 1 | |
else | |
t[i] << t[i-1][j-1] + t[i-1][j] |
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
str = "It's not too scary when you realize that everything is an object" | |
str.size # => 64 | |
str.class # => String | |
str = "and you call methods on them" | |
str.reverse # => "meht no sdohtem llac uoy dna" | |
# EVERYTHING is an object |
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
# Blocks are a way of "injecting" code to run in the context of the original method. | |
# Side note: we can open an existing class and add methods. | |
# Let's make the String class awesome, don't worry about the blocks yet | |
class String | |
def hax0rify | |
replac0rs = { | |
'o' => '0', | |
'a' => '4' | |
} |
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
# Symbols aren't anything special really, just use a colon in front of a word instead of quotes | |
:foo.class # => Symbol | |
"foo".class # => String | |
# They are easier to write and pass around than strings so we use them. That's all you really need to know about them. | |
# They also don't come with all the baggage methods strings do (which we wouldn't need for identifiers) | |
:foo.methods.count # => 50 | |
"foo".methods.count # => 176 |
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
require 'resolv' | |
hostname = 'hiscore.runescape.com' | |
names = [ "The Orange", "SkyTeck", "Font", "iGlacor", "Tohru x", "Weir", "Parenthesis", "OneLegendKid", "Lekerashi", "Aus Zealand", "Lordofd70", "No Orion", "BadSmurF", "Dunder_miffl", "Stephen VII", "Jonnys D", "God H8s Bots", "Wey burn", "nabulsi", "Blur", "Man killa", "Titsicle", "Bedevere", "lilybele", "l Jigg l", "zabeey", "xRatonhnhake", "st drew", "Kre8tive", "He Belongs", "Sannse", "almostcomp", "IrishEIK", "Haydunn", "kouth sorea", "dark_king_I4", "Unheard pray", "Co Justin", "Chalder", "mihal80", "inburst21", "Slaye", "Mish", "Doctor Doak", "ttaM", "nova science", "Rrman of w48", "saylor", "minergoo", "jason 72", "Advokat", "Lofna", "Dissori", "R2h Guard", "Izobelle", "Eleanor Lamb", "Mischievio", "Dead Masterr", "Man killa", "iBryce", "Boo Bee", "Mattmann28", "xowen", "fdsatakanuva", "Steeve", "J T R9", "mercifull", "Randomjagged", "Samyuel", "Cassus", "Dyzt", "Melbshuffle", "Neo687", "Metabolizer", "S9 Gnit2", "Joe Longo", "3u0", "Xw0", "Saul", |
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
-- Setup some tables. | |
CREATE TABLE `users` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`name` varchar(45) NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB AUTO_INCREMENT=1; | |
CREATE TABLE `internal_messages` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`owner_user_id` int(11) DEFAULT NULL, |
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 Article < ActiveRecord::Base | |
scope :published, -> { where("draft = false AND publish_at <= ?", Time.now) } | |
end | |
foo = Article.find(123) | |
foo.published? |