Skip to content

Instantly share code, notes, and snippets.

View odiak's full-sized avatar

Kaido Iwamoto odiak

View GitHub Profile
@odiak
odiak / dev-server.js
Created February 23, 2016 08:18
フロントエンド開発時の静的ファイル用サーバー
'use strict';
const http = require('http');
const fs = require('fs');
function respond(req, res, contentType, body) {
let d = new Date();
console.log(`[${d}] ${req.url}`);
res.writeHead(200, {
@odiak
odiak / svg2png-for-android.rb
Created February 5, 2016 01:55
convert SVG to PNG for Android's resource
DPIS = {
mdpi: 100,
hdpi: 150,
xhdpi: 200,
xxhdpi: 300,
xxxhdpi: 400,
}
bw = ENV['W'].to_i
bh = ENV['H'].to_i
require 'uri'
require 'net/http'
require 'json'
API_KEY = 'xxxxx'
URL_BASE = 'https://yyyyy.backlog.jp/api/v2/'
module Backlog
class << self
def request(method, path, params = nil, data = nil)

Android の開発を始めた話

(2015年久留米高専プロラボ部のアドベントカレンダーの8日目の記事です)

こんにちは。
僕のことを知らないプロラボ部関係者のために簡単に自己紹介をしておきます。

岩本海童です。
2014年3月くらいに久留米高専の制御情報工学科を4年の途中で退学して、現在はカラクルという会社で働いています。
高専時代には、2013年の高専プロコンで「避難Routing」という作品を作ったりしました。(懐かしや)

import java.lang.reflect.Field;
import java.lang.annotation.Annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
class FunWithReflections {
@Retention(RetentionPolicy.RUNTIME)
public @interface Foo {
int value() default 1;
}
function flatten (array) {
var newArray = [];
var locals = {
i: 0,
len: array.length,
array: array,
};
var stack = [];
var elem;
@odiak
odiak / uniq.js
Created October 20, 2015 07:36
配列内の要素の重複をなくす(破壊的に)
function uniq (array) {
var i, j, length = array.length;
for (i = 0; i < length; i++) {
for (j = i + 1; j < length; ) {
if (array[i] === array[j]) {
array.splice(j, 1);
length--;
} else {
j++;
}
@odiak
odiak / carrierwave_test_storage.rb
Created August 1, 2015 12:01
Fake storage engine for testing
module CarrierWave
module Storage
class Test < Abstract
def store!(file)
# do nothing
file
end
def retrieve!(identifier)
path = ::File.expand_path(uploader.store_path(identifier), uploader.root)
@odiak
odiak / playing_with_context.rb
Created July 27, 2015 13:03
Squeel で使われていたコンテキストをすりかえたり戻したりする手法
class Foo
def self.do_something(&block)
new(block.binding.eval('self')).instance_eval(&block)
end
def initialize(context)
@context = context
end
def my(&block)
@odiak
odiak / prime.sql
Last active August 29, 2015 14:25
-- select prime numbers smaller than 100
with recursive
num(n, sq) as (
select 2, sqrt(2) union select n + 1, sqrt(n + 1) from num where n < 100
)
select n from num
where not exists (
select n from num num2