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 'google-search' | |
require 'uri' | |
require 'open-uri' | |
require 'fileutils' | |
FileUtils.mkdir("images") | |
Google::Search::Image.new(query: 'High Quality').each do |image| | |
name = File.basename(URI.parse(image.uri).path) | |
path = File.join("images", name) |
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
$ mitmdump -q -s mitm_omniture.py |
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
Shoes.app do | |
download 'http://127.0.0.1:3000', {:headers => {'test' => 'me'}} do |d| | |
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
========== test.rb ========== | |
module MixinModule | |
def say_hello | |
puts "Hello #{CLASS_CONSTANT}" | |
end | |
end | |
class SomeClass | |
CLASS_CONSTANT = 'FOO!' | |
include MixinModule |
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
irb(main):001:0> a = [1, 2, 3, 4, 5] | |
=> [1, 2, 3, 4, 5] | |
irb(main):002:0> a.each_with_index{|elem, index| a[index..a.size].each{|second_elem| p "#{elem}, #{second_elem}"}} | |
"1, 1" | |
"1, 2" | |
"1, 3" | |
"1, 4" | |
"1, 5" | |
"2, 2" | |
"2, 3" |
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 'digest/sha1' | |
class Sha1File | |
attr_reader :path | |
def initialize(sha1, base) | |
@base = base | |
@path = sha1_path sha1, base | |
@dir = File.dirname @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
def block_to_string | |
stack = caller | |
return nil if stack.empty? | |
file_name, line = parse_stack_line stack.shift | |
return nil unless file_name | |
block_from_file file_name, line | |
end | |
def parse_stack_line(where) | |
match = where.match /^(.*):(\d+)/ |
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
#include <stdio.h> | |
enum CHAR_CODE { | |
col_sep = ',', row_sep = '\n', quote_char = '"' | |
}; | |
int get_char(); | |
int put_char(int); | |
void finish_col(); | |
void finish_row(); |
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 IpStrConvert | |
# IPv4 Conversion Methods | |
def ip4_str2bin(s) | |
s.split('.').map{|str| str.to_i}.pack('C4') | |
end | |
def ip4_bin2str(s) | |
s.unpack('C4').join '.' |
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
NameError in Static pagesController#new | |
constant ActionView::Base::Subclasses::StaticPagesController not defined | |
RAILS_ROOT: /home/tim/Documents/test | |
Application Trace | Framework Trace | Full Trace | |
/home/tim/Documents/test/vendor/rails/actionpack/lib/action_view/base.rb:242:in `remove_const' | |
/home/tim/Documents/test/vendor/rails/actionpack/lib/action_view/base.rb:242:in `block (2 levels) in for_controller' | |
/home/tim/Documents/test/vendor/rails/actionpack/lib/action_view/base.rb:241:in `class_eval' |
OlderNewer