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 Array | |
def diagonals | |
[self, self.map(&:reverse)].inject([]) do |all_diags, matrix| | |
((-matrix.count + 1)..matrix.first.count).each do |offet_index| | |
diagonal = [] | |
(matrix.count).times do |row_index| | |
col_index = offet_index + row_index | |
diagonal << matrix[row_index][col_index] if col_index >= 0 | |
end | |
all_diags << diagonal.compact if diagonal.compact.count > 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
%w[sinatra watir-webdriver].each { |gem| require gem } | |
class MyApp < Sinatra::Base | |
get('/') { "hello world" } | |
end | |
class AppRunner | |
def initialize |
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 'sinatra' | |
require 'jimson' | |
class Api | |
extend Jimson::Handler | |
def get_data | |
{'foo' => 'bar'} | |
end | |
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
require 'mini_magick' | |
class ImageResizer | |
attr_accessor :height, :width, :padding, :stretch, :grayscale | |
def initialize(path) | |
@image = MiniMagick::Image.open(path) | |
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
require 'sinatra' | |
require 'haml' | |
require 'json' | |
enable :sessions | |
get '/' do | |
session[:answer] = %w[A B C D].sample | |
haml :index | |
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
require 'json' | |
require 'haml' | |
require 'sinatra' | |
get '/' do | |
haml :view | |
end | |
get '/request' do | |
content_type :json |
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
source ~/git-prompt.sh | |
source ~/git-completion.bash | |
PS1='\u:\w\[\033[32m\]$(__git_ps1)\[\033[0m\]$ ' |
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
[user] | |
email = <YOUR EMAIL> | |
name = <YOUR NAME> | |
[color] | |
diff = auto | |
status = auto | |
branch = auto | |
interactive = auto | |
ui = true |
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 'treetop' | |
module Mine | |
class IntegerLiteral < Treetop::Runtime::SyntaxNode | |
def to_i | |
text_value.to_i | |
end | |
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
#!/bin/sh | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" | |
"$DIR/node_modules/.bin/forever" start \ | |
--watch --watchDirectory ${DIR} \ | |
--watchIgnore "$DIR/.*/*" \ | |
--watchIgnore "$DIR/public/*" \ | |
--watchIgnore "$DIR/logs/*" \ | |
--append -l "$DIR/logs/app.log" \ | |
--minUptime 1000 \ | |
--spinSleepTime 1000 \ |
OlderNewer