View run.rb
This file contains 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 String | |
def multiline_split(max_line_length) | |
self | |
end | |
end | |
puts "foo\nbar\nbaz" == "foo bar baz".multiline_split(3) | |
puts "foo bar\nbaz" == "foo bar baz".multiline_split(9) |
View gist:579623b5d1f98a621cd8
This file contains 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
Chart | |
http://www.cpubenchmark.net/high_end_cpus.html | |
http://products.amd.com/en-us/DesktopCPUResult.aspx | |
http://ark.intel.com/ | |
http://ark.intel.com/compare/80814,80809,80808,80806,80807 | |
http://processors.findthebest.com/d/n/AMD |
View Configure IRB's prompt for a Rails app
This file contains 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
if defined? Rails | |
# Customize the IRB prompt. | |
short_env = case Rails.env | |
when 'development' | |
'dev' | |
when 'production' | |
'prod' | |
else | |
Rails.env |
View gist:3015881
This file contains 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 | |
# Reset the index. | |
curl -X DELETE "localhost:9200/test/?pretty=true" | |
curl -X PUT "localhost:9200/test/?pretty=true" | |
# Create the parent mapping. | |
echo | |
curl -X PUT "localhost:9200/test/user/_mapping?pretty=true" -d '{ | |
"user": { |
View true_false_comparison.rb
This file contains 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
module TrueFalseComparison | |
# Enable TrueClass and FalseClass values to be comparable. | |
# TrueClass values are valued higher than FalseClass values. | |
# | |
# See this article for more info: | |
# http://grosser.it/2010/07/30/ruby-true-false-comparison-with/ | |
# | |
# Yes, this is evil monkey-patching. The alternative is much, much worse: | |
# | |
# [false, true, false].sort {|a, b| a ? (b ? 0 : -1) : (b ? 1 : 0) } |
View output.txt
This file contains 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
The first context | |
Creating Person with name Nick | |
✗ Errored » callback not fired | |
in Create a Person via JavaScript: When a person has a name, | |
in Creating a Person | |
in undefined✗ Errored » 1 errored ∙ 1 dropped |
View gist:2481672
This file contains 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
mysql> show create table numbers\G | |
*************************** 1. row *************************** | |
Table: numbers | |
Create Table: CREATE TABLE `numbers` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`num` int(11) DEFAULT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 | |
1 row in set (0.00 sec) |
View gist:1666614
This file contains 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
# The HTML that should be generated is: | |
# <h3 class="curated_by">Curated by <span>Bob</span></h3> | |
# Please tell me that there's a better way to do this. | |
def curated_by | |
html = '' | |
html += h.content_tag(:h3, :class => 'curated_by') do | |
h.concat h.t('phrases.Curated_by') | |
h.concat ' ' |
View query_with_exclamation.sh
This file contains 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
curl 'localhost:9200/development_products/product/_search?pretty=true' -d ' | |
{ | |
"query" : { | |
"dis_max" : { | |
"queries" : [ | |
{ "field" : {"name" : "Arise!"}}, | |
{ "field" : {"catalog.name" : "Arise!"}} | |
] | |
} | |
} |
View option_1.rb
This file contains 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 User | |
field :username, :type => String | |
validates :username, :format => { :with => /\A[[:print:] ]{3,20}\Z/ } | |
end | |
class ScoreCard | |
belongs_to :user | |
field :username, :type => String |
NewerOlder