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
:vimgrep /pattern/ path/** | |
:cope #to open quickfix list |
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
(defn | |
^{:doc "Action that shows the help and about page." | |
:path "/help" | |
:http_method :get} | |
action-show | |
[account member] | |
(normal-layout account | |
[:div | |
[:h1 "Title"] | |
[:p "lorem") |
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
A little tutorial on mapreduce. | |
This is a short tutorial on what mapreduce is. It'll do a process first sequentially and then with multiple mapper jobs As a silly example we will try to get a list of prime numbers in a big corpus of random numbers. Let's first start out with creating some test data that has good behaviour. We'll do this in the a terminal shell using ruby. | |
$ruby -e "(1..100).each { |x| puts x }" > data_1..100.txt | |
Look at the file with the "cat" utility: | |
$ cat data_1..100.txt | |
1 |
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
# encoding: utf-8 | |
class SocialSecurityNumber | |
def initialize str | |
if str =~ /(\d{2})(\d{2})(\d{2})(\d{4})/ | |
@str = str | |
@year,@month,@day,@last_four = $1,$2,$3,$4 | |
current_year = Time.now.year % 100 | |
century = @year.to_i > current_year ? "19" : "20" | |
@full_year = "#{century}#{@year}" |
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
min_messages: WARNING |
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 Paperclip::Attachment | |
def save | |
flush_deletes | |
oldpath = @path | |
@path = '/:attachment/:id/:style/:filename' | |
puts 'patching the path...' | |
flush_writes | |
@path = oldpath | |
@dirty = false |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> | |
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> | |
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" /> | |
<script src="http://code.jquery.com/jquery-1.5.min.js"></script> | |
<script src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script> | |
<title>Search Input Issue</title> | |
</head> |
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
puts [1,2,3].map {|x|x+1}.inspect | |
#[2, 3, 4] | |
puts [1,2,3].map do |x|x+1 end.inspect | |
#<Enumerator:0x00000100868110> |
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
require 'rubygems' | |
require 'nokogiri' | |
require 'pp' | |
class XMLToArr < Nokogiri::XML::SAX::Document | |
def XMLToArr.parse str, hsh | |
[].tap do |returning| | |
Nokogiri::XML::SAX::Parser.new(self.new(returning, hsh)).parse(str) | |
end |
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
desc "Start a console" | |
task :console do | |
require 'irb' | |
ARGV.clear | |
IRB.start | |
end |
NewerOlder