List items:
-
List item 1
def load_value(value) loader = Loader.new loader.load(value) end
#! /usr/bin/env ruby | |
# Save this file to somewhere in your PATH, like ~/bin/gfr, and chmod it with: chmod u+x gfr | |
require 'rubygems' | |
require "highline/system_extensions" | |
require 'colorize' | |
require 'optparse' | |
require 'ostruct' | |
include HighLine::SystemExtensions |
/* | |
* CSS Critique - How many issues can you find in this stylesheet? | |
*/ | |
.blue-black-select { | |
background-color: white; | |
} | |
#background { | |
width:100%; |
module Enumerable | |
def map_hash(memo = nil, &block) | |
i = 0 | |
inject(memo || {}) do |hash, item| | |
if kind_of?(Hash) | |
key = item.first | |
value = item.last | |
else | |
key = i | |
value = item |
class MyClass | |
def value | |
"VALUE!" | |
end | |
def do_something | |
puts value # Outputs "VALUE!" | |
if false | |
value = nil # Should not execute | |
end |
# To test, create a text file called test.txt in the current directory with the following content: | |
# | |
# Hello foo... | |
# | |
# Then run: ruby file_string_replacer.rb | |
# It will output send the modified version of the file contents to STDOUT | |
class FileStringReplacer | |
attr_accessor :file_path, :char |
def validate_colors | |
colors = %w(color_title color_title2 color_title3 color_title4) | |
as_str = colors.map {|c| send(c).present? : 'p' : ' '} | |
trimmed = as_str.trim | |
if trimmed =~ / / | |
errors[:base] << "Blank color found before non-black color" | |
end | |
end |
# Convert Ruby data to formatted Lua code | |
# irb(main):001:0> load 'to_lua.rb'; puts ToLua.format(['what', "she's", nil, false, true, ['yep'], [], {}, {foo: 'foo'}, {'bar' => 'bar'}, {0 => 'zero'}]) | |
# {'what', 'she\'s', nil, false, true, {'yep'}, {}, {}, {foo = 'foo'}, {['bar'] = 'bar'}, {[0] = 'zero'}} | |
module ToLua | |
extend self | |
# Format value | |
def format(v) | |
if v.kind_of?(Array) | |
format_array(v) |
#!/usr/bin/env ruby | |
# Open Pull Request for current branch | |
# Works in OS X | |
require 'ostruct' | |
branch=`git branch | grep '\*' | sed 's/\* //'` | |
remote_rows = `git remote -v | grep push`.split("\n").map do |line| | |
match = line.match(/^([^\s]+)\s+([^\s]+)/) |
List items:
List item 1
def load_value(value)
loader = Loader.new
loader.load(value)
end