Skip to content

Instantly share code, notes, and snippets.

View STAR-ZERO's full-sized avatar

Kenji Abe STAR-ZERO

View GitHub Profile
@STAR-ZERO
STAR-ZERO / first_coding_2012.js
Created January 1, 2012 14:59
first coding 2012
function happyNewYear() {
alert('A Happy New Year');
}
@STAR-ZERO
STAR-ZERO / cat.rb
Created January 25, 2012 04:39
Ruby first
class Cat
def initialize
@word = 'にゃんにゃん'
end
def nyan
print @word
print "\n"
end
end
@STAR-ZERO
STAR-ZERO / about.md
Created March 1, 2012 07:23
要素内の文字の行数を取得する

要素内の文字の行数を取得する

テキトーに書いた。 Chromeでしか確認してない。

@STAR-ZERO
STAR-ZERO / fizzbuzz.rb
Created April 12, 2012 11:27
RubyでFizzBuzz
(1..100).each {|i|
if i % 15 == 0 then
p "Fizz Buzz"
elsif i % 5 == 0 then
p "Buzz"
elsif i % 3 == 0 then
p "Fizz"
else
p i
end
@STAR-ZERO
STAR-ZERO / tweet.rb
Created April 19, 2012 06:36
Rubyでツイートするよ
# -*- encoding: utf-8 -*-
#
# $ ruby tweet.rb hogehoge で投稿するよ
#
require "oauth"
require "twitter"
require "pp"
require "json"
@STAR-ZERO
STAR-ZERO / gist:2779365
Created May 24, 2012 04:08
スーパークラスも含めてフィールド値をデバッグするtoString
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append(this.getClass().getSimpleName() + "[");
Class<?> clazz = this.getClass();
while (clazz != null) {
Field[] fields = clazz.getDeclaredFields();
for (Field field: fields) {
try {
@STAR-ZERO
STAR-ZERO / gist:2894491
Created June 8, 2012 08:35
【Android】SQLiteのCursorをデバッグ
private void debugCursor(Cursor c) {
if (c.moveToFirst()) {
do {
StringBuffer sb = new StringBuffer();
sb.append("[");
for (int i = 0; i < c.getColumnCount(); i++) {
sb.append(c.getColumnName(i));
@STAR-ZERO
STAR-ZERO / gist:2894745
Created June 8, 2012 09:43
全角・半角、左右trim
/**
* 文字列処理クラス
*
*/
public class StringUtil {
/** 半角スペース */
private static final char SPACE_CHAR_HALF = ' ';
/** 全角スペース */
@STAR-ZERO
STAR-ZERO / .zshrc
Created June 9, 2012 15:31
PROMPTに顔文字(oh-my-zshのrobbyrussellテーマに追加)
#顔文字固定で色ランダム
PROMPT=$'%{\e[$[32+$RANDOM % 5]m%}(。◕‿◕。)%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
#顔文字も色もランダム
FACE_CHAR=("(。◕‿◕。) " "(・∀・)ノ " "( ゚Д゚) " "(。╹ω╹。)" "♡♡♡♡" "☆☆☆☆")
PROMPT=$'%{\e[$[32+$RANDOM % 5]m%}$FACE_CHAR[$[$RANDOM % ${#FACE_CHAR[@]} + 1]]%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
@STAR-ZERO
STAR-ZERO / gist:2917491
Created June 12, 2012 13:24
【HTML5】ドラッグ&ドロップで画像表示
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$('#target').bind('drop', function(e) {
// ドロップ