Skip to content

Instantly share code, notes, and snippets.

@maripiyoko
maripiyoko / SushiParty.java
Last active August 29, 2015 14:07
Blog post Java reference example
/**
* すしパーティを始めます。
* 引数で与えられたメンバーの数だけ大将のお任せ寿司を用意するよ。
*/
public void startSushiParty(int numMember) {
List<Sushi> dishes = new ArrayList<Sushi>();
for(int i=0; i < numMember; i++) {
Sushi sushi = new Sushi(); // 勝手にランダムな寿司が出来上がるものとする
dishes.add(sushi);
}

rbenvとruby-buildでRuby環境を最新に保つのんなー

更新日:2014/2/25

rbenv, ruby-buildを更新

$ cd ~/.rbenv
$ git pull origin master
$ cd ~/.rbenv/plugins/ruby-build
$ git pull origin master
# ----- PROMPT -----
## PROMPT
PROMPT=$'[%*] → '
## RPROMPT
RPROMPT=$'`branch-status-check` %~' # %~はpwd
setopt prompt_subst #表示毎にPROMPTで設定されている文字列を評価する
# {{{ methods for RPROMPT
# fg[color]表記と$reset_colorを使いたい
# @see https://wiki.archlinux.org/index.php/zsh
@maripiyoko
maripiyoko / find_target_fruits.rb
Last active August 29, 2015 14:04
Ruby RegEx Practice.
input = "(apple banana) [()mellon orange {banana}] (apple apple {mellon orange})"
# split input text by (), {}, []
re_matchers = [ /\(.*?\)/, /\{.*?\}/, /\[.*?\]/ ]
results = []
re_matchers.each do |re|
results.concat(input.scan(re))
end
# count target occurrence
<source>
type tail
path /home/jacopen/minecraft/data/vanilla/logs/latest.log
format /^\[.*\]\s\[.*\]:\s(?<log>.*)$/
time_format %d/%b/%Y:%H:%M:%S %z
tag minecraft.log
pos_file /var/log/td-agent/minecraft.pos
</source>
<match minecraft.log>
import java.io.PrintWriter;
import java.io.Writer;
import java.util.List;
import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;
import org.slim3.datastore.Datastore;
import org.slim3.repackaged.org.json.JSONObject;
import org.slim3.util.StringUtil;
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')