Skip to content

Instantly share code, notes, and snippets.

View katoy's full-sized avatar

revers katoy

  • japan/tokyo
View GitHub Profile
@katoy
katoy / run.rb
Created October 10, 2013 12:43
ruby で外部プログラムを実行する例
# See http://refm.rubicle.net/sp/1.9.3/class/Open3
require 'open3'
puts "====== system ======"
ret = system('ps > /tmp/1')
puts ret
puts File.read('/tmp/1')
puts "====== Open3.capture3 ======"
@katoy
katoy / 1.rb
Created October 8, 2013 15:10
erb の利用例
# -*- coding: utf-8 -*-
require 'erb'
require 'time'
def make_body(template, name, time, params)
erb = ERB.new(template)
result = erb.result(binding)
end
@katoy
katoy / gist:6809787
Created October 3, 2013 13:25
ruby の Net::SCP でプログレスバーを出す。 See https://gist.github.com/drfeelngood/3784077
require 'rubygems'
require 'net/scp'
host = "xxxxxxx.ne.jp"
user = "youichikato"
src_path = "/tmp/1"
dest_path = "/tmp/2"
opts = {:password => "xxxxxxxx"}
Net::SCP.start(host, user, opts){|scp|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Leaflet Quick Start Guide Example</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5/leaflet.css" />
<!--[if lte IE 8]>
@katoy
katoy / client.coffee
Last active December 15, 2015 16:59
Sample for pillion ( https://github.com/deoxxa/pillion )
et = require 'net'
burro = require 'burro'
pillion = require 'pillion'
port = 3000
socket = burro.wrap(net.connect(port))
rpc = new pillion(socket)
rpc.callRemote "greet"
@katoy
katoy / app.js
Last active December 15, 2015 04:20
simple calc using pegjs.
//
// arithmetics.js の生成方法
//========================
// $ npm nstall pegjs -g
// $ pegjs -e arithmetics arithmetics.pegjs
//
$(function() {
$("#inp_text").keypress(function(ev) {
@katoy
katoy / client-async.coffee
Last active December 14, 2015 09:29
Sample for dnode ans async.
async = require("async")
dnode = require("dnode")
util = require("util")
port = 7070
remote = null
conn = null
tasks = []
tasks.push (callback) ->
@katoy
katoy / express_and_lactate.coffee
Created January 26, 2013 07:57
Samples using lactate.
actate = require 'lactate'
express = require 'express'
root_dir = __dirname
port = 8080
options = debug: true
app = express()
app.use lactate.static(root_dir)
@katoy
katoy / data.txt
Created January 16, 2013 09:32
sample using domain API.
これはテストデータです。
@katoy
katoy / unzip.coffee
Last active December 10, 2015 22:58
unzip command using node.js. It works on windows and Mac.
# ファイル解凍するコマンドラインアプリケーション。
unzip = require 'unzip'
fs = require 'fs'
fstream = require 'fstream'
mkdirp = require 'mkdirp'
usage = 'usage: $ coffee unzip.coffee zipfile [out_dir]'
file = null