Skip to content

Instantly share code, notes, and snippets.

View TomckySan's full-sized avatar
🏠
Working from home

tomcky TomckySan

🏠
Working from home
View GitHub Profile
@TomckySan
TomckySan / RandomListSample.java
Created August 24, 2013 11:12
Collections#shuffleメソッド
import java.util.ArrayList;
import java.util.Collections;
public class RandomListSample {
public static void main(String[] args) {
RandomList taskList = new RandomList(
new RandomList("a", "b", "c"),
new RandomList(1, 2, 3, 4, 5),
new RandomList("太郎", "次郎")
);
@TomckySan
TomckySan / MainActivity.java
Last active December 21, 2015 16:29
AndroidSQLiteSample
package com.example.sqltest;
import android.app.Activity;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Bundle;
import android.util.Log;
@TomckySan
TomckySan / CustomAdapter.java
Created August 30, 2013 16:28
ListFragmentを使ったチェックボックス付きアイテムリスト
package com.example.customlist;
import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
@TomckySan
TomckySan / sample.html
Last active December 1, 2017 08:05
【jQuery】セレクトボックスの選択要素を抽出 ref: http://qiita.com/tomcky/items/8f1868f1fb963732de39
<select name='alphabet' multiple='multiple'>
<option value='ABC'>えーびーしー</option>
<option value='DEF'>でーいーえふ</option>
<option value='GHI'>じーえいちあい</option>
<option value='JKL'>じぇーけーえる</option>
</select>
var adjustAspectRatio = function (rectObj, wRetio, hRetio) {
if ((typeof rectObj.width === 'undefined' || rectObj.width === null)
|| (typeof rectObj.height === 'undefined' || rectObj.height === null)) {
console.error('Error : Object is not rect!');
return;
}
if (rectObj.width > rectObj.height * wRetio / hRetio) {
rectObj.width = rectObj.height * wRetio / hRetio;
}
else if (rectObj.height > rectObj.width * hRetio / wRetio) {
@TomckySan
TomckySan / twilio-client.js
Created May 20, 2014 14:21
twilio-nodeでワン切りするサンプルコード
// twilio-node sample code "One-ring Call"
var twilio = require('twilio');
var client = twilio('1234567890', '0987654321');
client.calls.create({
to: '+81xxxxxxxxxx',
from: '+81zzzzzzzzzz',
url: 'http://twilio-sample.com'
}, function (err, call) {
if(err) {
console.log(err);
@TomckySan
TomckySan / kana-converter.js
Last active August 29, 2015 14:02
半全角カナ変換モジュール
/**
* 半全角カナ変換モジュール
* @return {[type]} [description]
*/
var kanaConverter = (function() {
// マップ作成用関数
var createKanaMap = function(properties, values) {
var kanaMap = {};
// 念のため文字数が同じかどうかをチェックする(ちゃんとマッピングできるか)
@TomckySan
TomckySan / vimrc
Last active August 29, 2015 14:16
" Note: Skip initialization for vim-tiny or vim-small.
if !1 | finish | endif
if has('vim_starting')
if &compatible
set nocompatible " Be iMproved
endif
" Required:
set runtimepath+=~/.vim/bundle/neobundle.vim/
var arr = [
{
name: 'たなか',
sex: '男',
age: 15
},
{
name: 'さとう',
sex: '女',
age: 20
@TomckySan
TomckySan / grep_recursively.sh
Last active August 29, 2015 14:22
Grep recursively
# Ex.1
find ./ -type f -print | xargs grep 'foo' *
# Ex.2
grep -r 'foo' .