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
/* | |
PC Emulator | |
Copyright (c) 2011 Fabrice Bellard | |
Redistribution or commercial use is prohibited without the author's | |
permission. | |
*/ | |
"use strict"; | |
var aa = [1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1]; |
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
[08:35 PM] epi@yew :: ~/code/pry $ pry | |
Loading gems... | |
|_ epitools | |
|_ coderay | |
|_ awesome_print | |
|_ print_members | |
[1] pry(main)> whee! |
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 CodeWriter | |
VALID_OPTIONS = %w[ | |
q | |
r | |
s | |
t | |
u | |
v | |
w | |
x |
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 Numeric | |
SIZE_TABLE = { | |
# power # units | |
0 => "", | |
1 => "KB", | |
2 => "MB", | |
3 => "GB", | |
4 => "TB", | |
5 => "PB", |
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
<%= easy_table(items, :class=>"table-style1", :tbody_id=>@table_id) do | |
col("Name") {|o| o.drug_price.name} | |
col("Qty", :quantity) | |
col("Price") {|o| number_to_currency(o.price) } | |
col("Actions") do |o| | |
link_to image_tag('small/delete.png'), | |
:action => "return_package_item", | |
:package_item => o.id, |
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 'spork' | |
Spork.prefork do | |
require 'rspec' | |
require 'pry' | |
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration | |
RSpec.configure do |config| | |
config.treat_symbols_as_metadata_keys_with_true_values = true | |
config.run_all_when_everything_filtered = true |
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
echo -n "with: " | |
time ruby -I. -rfast-require -e 'require "epitools"' | |
echo -n "without: " | |
time ruby -e 'require "epitools"' |
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
Pry.commands.command "ri", "RI it up!" do |*names| | |
# lazy loading | |
require 'rdoc/ri/driver' | |
unless RDoc::RI::Driver.responds_to? :monkeypatched? | |
class RDoc::RI::Driver | |
def page | |
lesspipe {|less| yield less} | |
end |
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
Pry.commands.command(/^wtf([?!]*)/, "show backtrace") do |arg| | |
raise Pry::CommandError, "No most-recent exception" unless _pry_.last_exception | |
output.puts _pry_.last_exception | |
output.puts _pry_.last_exception.backtrace.first([arg.size, 0.5].max * 10) | |
end |
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 'epitools' | |
require 'redcarpet' | |
require 'coderay' | |
def indented?(text) | |
indent_sizes = text.lines.map{ |line| if line =~ /^(\s+)/ then $1 else '' end }.map(&:size) | |
indent_sizes.all? {|dent| dent > 0 } | |
end | |
def unwrap(text) |