Skip to content

Instantly share code, notes, and snippets.

@hackugyo
hackugyo / duck.coffee
Created August 6, 2012 04:08
Private Method accessing to static property in CoffeeScript
# http://d.hatena.ne.jp/keyesberry/20110908/p1
# 上でプライベートメソッドがうまく定義できなかった理由を,
# http://d.hatena.ne.jp/yogit/20110921/1316592709
# から探る
# あと,こちらも
# http://sucrose.hatenablog.com/entry/20120229/p1
class Duck
constructor: (@name, @age) ->
# 今回の結論.
@hackugyo
hackugyo / file0.txt
Created November 8, 2012 09:47
Androidアプリをビルドして起動するスクリプト(複数実機対応) ref: http://qiita.com/items/3942bb6b1d6eb8a7da46
MY_DIRNAME=$(dirname $0)
cd $MY_DIRNAME
cd YOUR_APP_DIR
echo "インストール先を選んでください"
# sedで余計な文字列を削除し,selectでANSに選ばれた選択肢を入れる
select ANS in `adb devices | sed -e "s/List of devices attached//" | sed -e "s/device//"`
# 入力値が適切な値かどうかチェック
do
if [ -z "$ANS" ]; then
max_y = 0
max_z = 0
for a in 0..252 do
for b in 0..252 do
x = (((95*2 + 31 + a / 4.0) * 0.5) + 60).truncate
y = (((80*2 + 31 + b / 4.0) * 0.5 + 5)).truncate
next if (506 - a - b > 252)
for c in 0..(506-a-b) do
z = (((80 * 2 + 31 + c / 4.0) * 0.5 + 5)*1.1).truncate
@hackugyo
hackugyo / tips_misc.rst
Last active April 24, 2022 20:32
My miscellaneous tips
javascript:
(function(){
if(document.URL.indexOf('amazon.co.jp') == -1){
prompt('コピーしてください','`'+document.title+'%20'+'<'+document.URL+'>`_');
}
else {
var title = document.getElementById('btAsinTitle').textContent;
var b = document.getElementsByTagName('b');
var r;
for(i=0;i<b.length;i++)if(/ISBN-13/i.test(b[i].innerHTML))r=b[i].parentNode.innerHTML.match(/(\d{3})-(\d+)/);
# coding: utf-8
require 'yaml'
# ruby2.0.0に組み込み
require 'nokogiri'
require 'open-uri'
require 'term/ansicolor'
# gem install term-ansicolor
include Term::ANSIColor
public void testMockCreating() {
try {
PublicClass instance = mock(PublicClass.class);
} catch (IllegalAccessError e) {
fail();
}
try {
PublicButInheritedStaticPackageProtectedClass instance;
instance = mock(PublicButInheritedStaticPackageProtectedClass.class);
@hackugyo
hackugyo / xml_parsing
Last active December 28, 2015 07:19
JSONICを使って,Android上でXMLをJSONに変換する
/**
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import net.arnx.jsonic.JSON;
import org.w3c.dom.Document;
@hackugyo
hackugyo / 0_reuse_code.js
Created February 18, 2014 01:02
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@hackugyo
hackugyo / websites.rst
Created July 2, 2014 01:30
Websites I don't try yet

今日見られなかったサイト

  • URL + タイトルをコピーする

    javascript:prompt('Title%20+%20URL','`'+document.title+'%20<'+location.href+'>`_')();