Skip to content

Instantly share code, notes, and snippets.

@naosim
naosim / release_check.py
Created October 28, 2015 04:21
Androidアプリがリリースされたかをチェックするスクリプト
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib
import urllib2
from urllib2 import Request, urlopen, URLError, HTTPError
import sys
# http request
def request(url, getParams={}, proxy=False):
if proxy != False:
@naosim
naosim / chatworkhelper.py
Last active January 27, 2017 09:04
チャットワーク用ヘルパー
# -*- coding: utf-8 -*-
import urllib
import urllib2
from datetime import datetime
# -------------------------
# チャットワーク関連
# -------------------------
# チャットワークに送信する
@naosim
naosim / SwitchCreator.java
Created November 4, 2015 11:38
SwitchCreator.java
public class SwitchCreator {
private final SwitchType switchType;
public SwitchCreator(SwitchType switchType) {
this.switchType = switchType;
}
public <T, R> R create(
T arg,
Predicate<T> leftFilter, Function<T, R> leftAction,
Predicate<T> rightFilter, Function<T, R> rightAction,
@naosim
naosim / Optional.js
Last active April 4, 2016 18:54
javascriptでOptional
var Optional = (value) => {
var isNull = value === null || value === undefined;
return {
filter:(action) => (isNull || !action(value)) ? Optional() : Optional(value),
map:(action) => isNull ? Optional() : Optional(action(value)),
isPresent:() => !isNull,
ifPresent:(action) => {
if(!isNull) action(value);
},
get:() => isNull ? null : value,
@naosim
naosim / main.py
Created December 16, 2015 22:38
pythonで標準入力
from readutil import *
inputData = readInput([
InputData('name'),
InputData('age', 'age(number)?')
])
@naosim
naosim / index.html
Created February 28, 2016 12:29
テキスト画像作成
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>メニューテキストメーカー</title>
<style>
@import url(https://fonts.googleapis.com/css?family=Lobster);
html, body, h2 {
padding: 0px;
@naosim
naosim / getwild.html
Created March 29, 2016 14:19
[FireFox]部屋の灯りが消えたら自動でGet Wild
<!DOCTYPE html>
<audio id="audio" src="getwild.mp4" controls>
<script>
var isPlaying = false;
window.addEventListener('devicelight', function(event) {
console.log(event.value + 'lux');
if(isPlaying) {
return;
}
@naosim
naosim / run_casper.sh
Created April 28, 2016 03:39
casperを実行するシェル
#!/bin/sh
cd `dirname $0`
PHANTOMJS_EXECUTABLE=node_modules/phantomjs/bin/phantomjs node_modules/casperjs/bin/casperjs index.js
@naosim
naosim / index.js
Created April 28, 2016 03:41
webサイトをcasperでキャプチャする
// カレンダーを表示する
(function() {
var url = 'http://google.com';
var width = 1000;
var height = 400;
var casper = require('casper').create();
casper.start(url);
casper.viewport(width, height);
@naosim
naosim / requiree.rb
Created June 8, 2016 19:10
Rubyのrequireをファイル名だけ書けばOKにする
$ruby_file_list = `find -name "**.rb"`.split("\n")
def requiree(filename)
result_list = $ruby_file_list.select {|line| line.include?(filename)}
if result_list.length == 0 then
throw "file not found: #{filename}", 1
end
require(result_list[0])
end