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 Helper | |
def smash_whitespaces(&block) | |
capture(&block).lines.lazy.map(&:strip).reduce(StringIO.new, :<<).string | |
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
#!/usr/bin/env escript | |
%% -*- erlang -*- | |
main([]) -> | |
main([100]); | |
main([Limit|_]) when is_list(Limit) -> | |
main([list_to_integer(Limit)]); | |
main([Limit|_]) -> |
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 Paperclip | |
module Model | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def has_attached_file(name) | |
{ | |
file_name: :original_filename, | |
content_type: :content_type, | |
file_size: :size |
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 Submodule | |
def subset(&pred) | |
mod = self | |
Module.new do | |
include mod | |
public_instance_methods.each do |method_name| | |
method = instance_method(method_name) | |
undef_method method_name unless pred.call(method) |
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
trait FlipFlap[A, B] { | |
def doFlipFlap(x: A): B | |
} | |
class FlipFlapOps[A, B](v: A, f: FlipFlap[A, B]) { | |
def flipFlap = f.doFlipFlap(v) | |
} | |
object Main { | |
implicit def intFlipFlap = new FlipFlap[Int, Int] { |
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(['file-chunk'], function(FileChunk) { | |
var file = pickupFile(); | |
var fileChunk = new FileChunk(file); | |
var chunks = fileChunk.chop(4096); | |
// each: 各チャンクのpromiseのdoneを設定する | |
chunks.each(function(chunk) { | |
}); | |
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
package main | |
import ( | |
"fmt" | |
"strconv" | |
"strings" | |
"time" | |
) | |
func main() { |
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> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <mecab.h> | |
#include "erl_driver.h" | |
#include "ei.h" | |
#include "erl_interface.h" | |
#define OP_BEGIN_PARSING 1 | |
#define OP_GET_VERSION 2 |
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 'optparse' | |
require 'stringio' | |
require 'rubygems' | |
require 'twitter' | |
module Twsh | |
class Logout < StandardError; end | |
class TwshError < StandardError; end | |
class Shell |
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
#!/usr/bin/env escript | |
%% -*- erlang -*- | |
main(_) -> | |
io:format("~p~n", [hex_to_binary("180ff")]), | |
io:format("~p~n", [integer_to_binary(16#180ff)]). | |
hex_to_binary(Hex) -> | |
fold(fun | |
([L, U|H]) -> {char_to_integer(U) bsl 4 bor char_to_integer(L), H}; |
OlderNewer