Skip to content

Instantly share code, notes, and snippets.

@hitode909
hitode909 / hamuo
Created May 14, 2014 10:27
はむお
#!/usr/bin/env ruby
puts "🐹 < #{ ARGV.empty? ? ARGF.read : ARGV.join(' ') }"
@hitode909
hitode909 / mosikasite.pl
Created May 13, 2014 10:11
メソッドが呼ばれたときに同名のフィールドがあったらもしかしてって言いながら死ぬやつ
package Mosikasite {
sub new {
my ($class) = @_;
bless {}, $class;
}
sub AUTOLOAD {
my ($self) = @_;
my $method = (split '::', $AUTOLOAD)[-1];
@hitode909
hitode909 / commit-dates-for-word-of-repository.rb
Created January 4, 2014 09:31
リポジトリ内で指定した単語が書かれた時期を調べる
require 'shellwords'
class AnnotateLine
attr_reader :content, :meta
def initialize
@meta = {}
@content = nil
end
def add_line line
@hitode909
hitode909 / wifi_to_internet.rb
Created November 25, 2013 00:13
接続中のWiFiのSSIDからインターネットにチェックインするやつ
#! /usr/bin/env ruby
# -*- coding: utf-8 -*-
# 接続中のWiFiのSSIDからインターネットにチェックインするやつ
ssid = `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I`.split(/\n/).find{|line| line =~ /\bSSID/ }.scan(/SSID: (.+)$/).flatten.first
system "open 'http://t.heinter.net/#{ ssid }'"
@hitode909
hitode909 / ssid.rb
Created November 24, 2013 23:57
接続中のWiFiのSSIDを表示するやつ
#! /usr/bin/env ruby
puts `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I`.split(/\n/).find{|line| line =~ /\bSSID/ }.scan(/SSID: (.+)$/).flatten.first
package main
import "fmt"
func Cbrt(x complex128) func() complex128 {
z := complex128(1)
return func() complex128 {
z=z-(z*z*z-x)/(3*z*z)
return z
}
@hitode909
hitode909 / 43.go
Created November 20, 2013 11:41
package main
import "fmt"
func mynumber() map[string]func(int) int {
sum := 0
result := make(map[string]func(int)int)
result["add"] = func(x int) int {
sum += x
return sum
package main
import "math"
import "code.google.com/p/go-tour/pic"
func Pic(dx, dy int) [][]uint8 {
pic := make([][]uint8, dy)
for y := range pic {
line := make([]uint8, dx)
pic[y] = line
@hitode909
hitode909 / 24.go
Created November 7, 2013 11:55
ニュートン法 http://tour.golang.org/#24
package main
import (
"fmt"
)
func Sqrt(x float64) float64 {
return _sqrt(x, 0, 10);
}
@hitode909
hitode909 / lowercase_to_camelcase.rb
Last active December 27, 2015 01:29
lookコマンドを使ってlower caseをcamel caseにするやつ
#! /usr/bin/env ruby
source = ARGV.first
dest = ''
def extract(word)
if `look #{word}`.split(/\n/).include? word
return word
end