Skip to content

Instantly share code, notes, and snippets.

@sambaiz
sambaiz / rails_test_gem
Created December 12, 2014 06:33
rails_test_gem
group :development, :test do
gem 'rspec-rails', '~> 3.1.0'
gem "shoulda-matchers"
gem 'factory_girl_rails', '~> 4.4.1'
gem 'faker', '~> 1.4.3'
gem 'capybara', '~> 2.4.3'
gem 'poltergeist'
gem 'database_cleaner', '~> 1.3.0'
end
@sambaiz
sambaiz / wn.py
Last active August 29, 2015 14:10 — forked from mugenen/wn.py
A Python3 frontend of WordNet-Ja database file (sqlite3 format) which is available on http://nlpwww.nict.go.jp/wn-ja/
#!/usr/bin/env python
# encoding: utf-8
import sys
import sqlite3
from collections import namedtuple
conn = sqlite3.connect("wnjpn.db")
Word = namedtuple('Word', 'wordid lang lemma pron pos')
@sambaiz
sambaiz / rensyu.go
Created July 17, 2014 02:24
Golangコマンドライン引数とfor
package main
import (
"fmt"
"flag"
"os"
)
func main() {
flag.Parse()
@sambaiz
sambaiz / MyPlayground.swift
Last active August 29, 2015 14:04
Swift Tour
// Playground - noun: a place where people can play
//can run beta3
//Hello world
println("Hello world")
//変数と定数
var myVariable = 42
let myConstant = 42
@sambaiz
sambaiz / base64_decode.rb
Created May 26, 2014 11:34
Decode Base64 and Write binary
require 'Base64'
File.open(ARGV[1], 'wb') do|f|
f.write(Base64.decode64(ARGV[0]))
end
@sambaiz
sambaiz / regular_expression.rb
Last active August 29, 2015 14:01
正規表現ruby
data = "data:audio/amr;base64,AAAA"
/data:(.*);(.*),(.*)/ =~ data
p $1 # => audio/amr
@sambaiz
sambaiz / memo.kt
Created April 26, 2014 16:58
Kotlin's ? and !!
val hello : String? = "hello"
var bye : String? = "bye"
//(hello or bye).length is error (need ? or !!)
hello!!
hello.length //ok
bye!!
//bye.length is error (need ? or !!)
bye?.length // if bye == null, return null
@sambaiz
sambaiz / button.kt
Last active December 2, 2018 21:57
Kotlin Android
val button: Button = findViewById(R.id.Button02) as Button
button setOnClickListener (object: View.OnClickListener {
public override fun onClick(view: View): Unit {
}
})
@sambaiz
sambaiz / brute\force_mini.rb
Created April 24, 2014 02:48
てきとう
max_length = 5
password = 'poor'
chars = ('a'..'z').to_a
searches = Array.new
searches << ""
length = 0
while true
new_searches = Array.new
length += 1
@sambaiz
sambaiz / setup.py
Created March 19, 2014 07:54
cocos2d-xのsetup.py fish対応版
#!/usr/bin/python
#coding=utf-8
"""****************************************************************************
Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights