Skip to content

Instantly share code, notes, and snippets.

module Helper
def smash_whitespaces(&block)
capture(&block).lines.lazy.map(&:strip).reduce(StringIO.new, :<<).string
end
end
#!/usr/bin/env escript
%% -*- erlang -*-
main([]) ->
main([100]);
main([Limit|_]) when is_list(Limit) ->
main([list_to_integer(Limit)]);
main([Limit|_]) ->
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
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)
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] {
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) {
});
package main
import (
"fmt"
"strconv"
"strings"
"time"
)
func main() {
#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
require 'optparse'
require 'stringio'
require 'rubygems'
require 'twitter'
module Twsh
class Logout < StandardError; end
class TwshError < StandardError; end
class Shell
#!/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};