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 Photo < ActiveRecord::Base | |
| extend Refile::ActiveRecord::Attachment::IDName | |
| 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
| module MrubyMiniMagick | |
| class Convert | |
| attr_accessor :opts | |
| def initialize(src, dst) | |
| @opts = [] | |
| @src = src | |
| @dst = dst | |
| end | |
| %i(resize define gravity background extent thumbnail).each do |name| | |
| define_method(name) do |value| |
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
| // imagemagick_server | |
| // $ go run imagemagick_server.go -host 127.0.0.1:8088 | |
| // GET http://127.0.0.1:8088/fill/300/300/example.com/path/to/name | |
| package main | |
| import ( | |
| "flag" | |
| "fmt" | |
| "io" | |
| "io/ioutil" |
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
| #! /usr/bin/env ruby | |
| require 'socket' | |
| case ARGV[0] | |
| when 'server' | |
| sockfile = "/tmp/test.sock" | |
| File.unlink(sockfile) if File.exists?(sockfile) | |
| UNIXServer.open(sockfile) do |serv| | |
| File.chmod(0777, sockfile) |
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
| module Base58 | |
| class InvalidCharError < StandardError; end | |
| WORDS = %w( | |
| 1 2 3 4 5 6 7 8 9 | |
| a b c d e f g h i j k m n o p q r s t u v w x y z | |
| A B C D E F G H J K L M N P Q R S T U V W X Y Z | |
| ).freeze | |
| WORD_MAP = WORDS.each_with_index.to_h |
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
| package main | |
| import ( | |
| "flag" | |
| "fmt" | |
| "log" | |
| "net/url" | |
| "strings" | |
| "github.com/aws/aws-sdk-go/aws" |
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
| #! /usr/bin/env ruby | |
| #$ ruby better_select.rb | |
| #=> read2 | |
| #=> end | |
| require 'thread' | |
| def better_select(reads, writes={}, excepts={}, timeout=nil) | |
| rs, ws, es = IO.select(reads.keys, writes.keys, excepts.keys, timeout) |
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
| #! /usr/bin/env ruby | |
| class S3 | |
| def buckets | |
| BucketCollection.new | |
| end | |
| class BucketCollection | |
| def [](name) | |
| Bucket.new(name) |
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 OpenClass | |
| module InternalMethods | |
| refine OpenClass do | |
| def foo | |
| :foo | |
| end | |
| end | |
| end | |
| using InternalMethods | |
| def bar |
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
| #! /usr/bin/env ruby | |
| class KStruct | |
| class NoMemberError < StandardError | |
| end | |
| def self.new(*args) | |
| Class.new do | |
| attr_accessor *args | |
| const_set :MEMBERS, args |