Skip to content

Instantly share code, notes, and snippets.

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

Shingo Inoue Leko

🏠
Working from home
View GitHub Profile
@Leko
Leko / new_bp_template.js
Created July 19, 2013 18:17
New battle programming template in JavaScript
var puts = console.log,
p = require("util").print,
cin = parseInput();
// ここに処理を記述
function parseInput(useSplitSpace) {
var index = 0,
ret = [],
input = require("fs").readFileSync("/dev/stdin", "utf8"),
@Leko
Leko / parseInput.js
Created July 19, 2013 18:17
parse inputs method in JavaScript
/**
* 標準入力のパースと汎用関数を提供する
* @method parseInput
* @param {Boolean} [useSplitSpace] スペースを区切り文字として利用する
* @default true
*/
function parseInput(useSplitSpace) {
var index = 0,
ret = [],
@Leko
Leko / maps.js
Created July 21, 2013 17:10
Object-oriented technology 2013
(function(window, undefined) {
"use strict";
var map;
var domUtil = {
byId: function(id, context) {
context = context || document;
return context.getElementById(id);
},
@Leko
Leko / parse-priority-operator.js
Created July 23, 2013 06:58
演算子順位解析(js)
function parse(str) {
/**
演算子順位解析
http://fujimura2.fiw-web.net/java/mutter/operator-precedence/index.html
-1: x(パースエラー)
0: shift
1: reduce
2: pop
3: end
@Leko
Leko / codeIQ_q381.js
Last active December 20, 2015 07:08
JS:島の多いエーゲ海(転職する気ないから提出できないのでここに)
/**
JS:島の多いエーゲ海
https://codeiq.jp/challenge.php?challenge_id=381
*/
(function(global, undefined) {
"use strict";
// 縦か横に隣接する島をすべて沈める(0にする)
// 沈められる島が無くなったら終了
function sink(field, x, y) {
@Leko
Leko / autoUpdate.php
Last active December 20, 2015 08:09
Puppetfileを自動更新するスクリプト
<?php
define("READ_START_SYMBOL", "# ---auto update---");
define("READ_END_SYMBOL", "# ---/auto update---");
//
function notify_update($name, $from, $to) {
echo "updated '".$name."' from ".$from." to ".$to."\n";
}
@Leko
Leko / CodeIQ_q391.rb
Created July 31, 2013 12:21
https://codeiq.jp/ace/fshin2000/q391 このお店とこのお店は同じ店?!
# encoding: utf-8
# このお店とこのお店は同じ店?!
# https://codeiq.jp/ace/fshin2000/q391
searches = [
"中目黒いぐち",
"まるかつ水産 東京ミッドタウン店",
"寿司寿"
]
@Leko
Leko / bals.rb
Last active December 20, 2015 13:38
バルス!!!!!!
# encoding: utf-8
require "twitter"
Twitter.configure{ |conf|
conf.consumer_key = CONSUMER_KEY
conf.consumer_secret = CONSUMER_SECRET
conf.oauth_token = OAUTH_TOKEN
conf.oauth_token_secret = OAUTH_TOKEN_SECRET
}
@Leko
Leko / js_template.js
Last active December 20, 2015 14:29
競技プログラミングのテンプレートです。
/**
#############
webテンプレ
#############
1. undefinedは値ではなくグローバル変数なため書き換えができる
=> 確実にundefinedとなる書き方
2. 他のファイルに影響する可能性がある
=> 無闇にグローバルを汚染しないために即時関数で囲う
=> 関数内のみ適用されるstrictモードを使用
=> グローバルstrictは他の非strictコードに影響を与えてしまう
(function(global, undefined) {
"use strict";
var Pocket = (function() {
var https = require("https");
function Pocket(opt) {
this.consumer_key = opt.consumer_key;
this.access_token = opt.access_token;
}