Skip to content

Instantly share code, notes, and snippets.

View kikuchy's full-sized avatar

Hiroshi Kikuchi kikuchy

View GitHub Profile
@kikuchy
kikuchy / ring.go
Last active August 29, 2015 14:23
Ring Zeroが届いたので、Open URI用のサーバをgolangで書いてみた。完全に自分用。Android StudioとChromeをスイッチする。
package main
import (
"net/http"
"os/exec"
"log"
)
func execOSAScript(osaScript string) {
err := exec.Command("osascript", "-e", osaScript).Start()
@kikuchy
kikuchy / objToOptionString.js
Created December 9, 2011 09:05
オブジェクトの内容を、"aaa=bbb,ccc=ddd,...."という形式に並び替えるのに便利なコード
function(o){
var a = [];
for(var b in o){a.push(b+"="+o[b]);}
return a.join(',');
};
@kikuchy
kikuchy / gist:1471552
Created December 13, 2011 10:20
Javascriptでprivateなクラス変数を実現する方法
var SomeClass = (function(){
var _private = "this is private";
var constructor = function(){
this.public = "this is public";
};
constructor.prototype.say = function(){
console.log(this.public);
console.log(_private);
};
return constructor;
@kikuchy
kikuchy / gist:2559432
Created April 30, 2012 15:43
Application.Resourcesの使い方 : Metro Style App Tips(のようなもの)
Application.Resourcesの使い方
アプリケーション全体で使いたい定数などがある時に非常に便利です。
この方法だと、数値や文字列などだけではなく、
自作のオブジェクトもインスタンス化して保持しておくことができます。
アプリケーションをテンプレートから作成した時に自動的に作成されている App.xaml を開いてみると、
Application.Resources 中に
<Application.Resources>
@kikuchy
kikuchy / 引用元.txt
Created July 2, 2012 04:06
平面幾何問題
ICPCのための平面幾何問題について学んだこと
基本は「点」。点はx座標y座標がわかればよい。
また、点があればベクトルを考えられる。ベクトルは原点からある点までの有向線分なので、点が一つあればベクトルを表現できる。
円は点と半径がわかればいい。
線分や直線は、それを通る点の対で表す。ただ、pairを使うのでなく、vectorを使った方が良いらしい。for文で端点をすべて回れたり、辞書準比較の演算子が最初からあるためらしい。
単純多角形はvectorで表現。ただ、その多角形が反時計回りなのか時計回りなのかか決めておかないといけない。
ベクトル計算のためには、ベクトルの加減算、スカラー倍、内積、外積が計算できると便利。
自分でstruct pointとか定義してメソッド定義するんでも良いけれど、複素数クラスで加減算とスカラー倍まではデフォルトでできるので、それで代用する。
@kikuchy
kikuchy / A.cpp
Created July 6, 2012 11:20
ICPC2012
#include <iostream>
#define REP(i,n) for(int i = 0; i < (n); i++)
using namespace std;
const int YMAX = 1000;
const int MMAX = 10;
const int CMAX = 20;
int n;
class PixivAppSetting
attr_accessor :login_userid
attr_accessor :login_password
def initialize
@login_userid = ""
@login_password = ""
end
end
class PixivItemBase
attr_reader :title
attr_reader :creator
attr_reader :posted_date
attr_reader :caption
attr_reader :number_of_viewed
attr_reader :number_of_voted
attr_reader :score
attr_reader :tags
attr_reader :thumbnail_128
@kikuchy
kikuchy / anemone_sample.rb
Created January 17, 2013 06:07
anemoneを使ってみたくて
require 'rubygems'
require 'anemone'
opts = {
:skip_query_strings => true,
:depth_limit => 5,
}
Anemone.crawl("http://example.com/", opts) do |anemone|
anemone.on_every_page do |page|
@kikuchy
kikuchy / stdint.h
Created January 30, 2013 09:41
WinRT用にC++/CXで書いたstdint.hが欲しくて
typedef int8 int8_t;
typedef int16 int16_t;
typedef int32 int32_t;
typedef int64 int364_t;
typedef uint8 uint8_t;
typedef uint16 uint16_t;
typedef uint32 uint32_t;
typedef uint64 uint64_t;
typedef int8_t int_least8_t;