Skip to content

Instantly share code, notes, and snippets.

View alucky0707's full-sized avatar

Hoshinoma Araki alucky0707

View GitHub Profile
@alucky0707
alucky0707 / TwPost.hs
Created November 18, 2012 04:42
ConduitでTwitterにpostします
module Main where
{-# LANGUAGE OverloadedStrings #-}
import System.IO
import Control.Monad.IO.Class (liftIO)
import Codec.Binary.UTF8.String (encode)
import Data.ByteString
import Data.Conduit
import qualified Data.Conduit.Binary as CB
@alucky0707
alucky0707 / file0.txt
Created February 28, 2013 12:02
obj+""≠obj.toString()≠String(obj)っていう話 ref: http://qiita.com/items/8d80ca107555489710ea
// obj.toString()
str = obj+"";
@alucky0707
alucky0707 / file0.rb
Created April 4, 2013 21:05
RubyとPythonじゃデフォルト引数の値が評価されるタイミングが違うんだぜ ref: http://qiita.com/items/b8677ec1d692f074e66b
#スコープの関係でグローバル変数
$msg = "Hello, Before World!"
def say(str = $msg)
puts str
end
say #=> Hello, Before World!
$msg = "Hello, After World!"
@alucky0707
alucky0707 / slicer.js
Last active December 15, 2015 20:28
Slice like Ruby for JavaScript
(function(exports) {
"use strict";
/**
* arr["1..3"]かarr["1,2,3"]という形式かを判断する
* @private
*/
function sliceInfo(str) {
var
@alucky0707
alucky0707 / file0.txt
Created April 10, 2013 11:36
JavaScriptでRubyのように配列をスライスする ref: http://qiita.com/items/de269eddf2b359c3f490
var
arr = [0,1,2,3,4,5,6,7,8,9], //元となる配列
sli = toSlicer(arr); //配列を拡張
// 範囲代入と取得
sli["1..3"] = [10,11,12];
console.log(sli["0..2"]); //=>0,10,11
//複数代入と取得
sli["4,6,8"] = [13,14,15];
@alucky0707
alucky0707 / MinGW-require-options-using-IUP.md
Created April 10, 2013 12:02
MinGWでIUPを使うときに渡すオプション

MinGWでIUPを使うときに渡すオプション

gcc sample.c -o sample -liup - mwindows -lole32 -lcomctl32 -luuid

@alucky0707
alucky0707 / POJ3627.java
Last active December 16, 2015 09:19
POJ 3627 & POJ 3628
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
final int N = scan.nextInt();
@alucky0707
alucky0707 / aoj109.js
Created April 28, 2013 00:11
AOJ 109
var
input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
input += chunk;
});
process.stdin.on('end', function() {
input = input.split('\n');
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
/**
* @param args
function main() {
function dfs(n,l,r){
if(n.length === 0) return true;
return (n[0] > l[0] && dfs(n.slice(1), [n[0]].concat(l), r)) ||
(n[0] > r[0] && dfs(n.slice(1), l, [n[0]].concat(r)));
}
var
i,
n = parseInt(input[0], 10),
nums = input.slice(1);