Skip to content

Instantly share code, notes, and snippets.

@nanonanomachine
nanonanomachine / seirekiReplacer.js
Last active August 29, 2015 14:06
西暦変換君
(function() {
function seirekiReplacer(str, p) {
if (p == '1' || p == '1' || p == '元') {
return str + '(西暦1988年)';
} else {
var seireki = Number(p) + 1988;
return str + '(西暦' + seireki + '年)';
}
}
document.body.innerHTML = document.body.innerHTML.replace(/平成\s*(\d{1,2}|元)\s*年/g, seirekiReplacer);
@nanonanomachine
nanonanomachine / zoi.js
Last active August 29, 2015 14:07
がんばるぞいJavascript版
// ref: http://qiita.com/giiko_/items/8c3442e8e7a83cc0b91a
(function() {
var dic = [
["今日", "ぞい"],
["も"],
["1", "ぞい"],
["日", "ぞい"],
["がん", "ぞい"],
["ばる", "ぞい"],
["ぞい!"]
@nanonanomachine
nanonanomachine / 雨の日警告ちゃん.coffee
Last active August 29, 2015 14:16
雨の日警告ちゃん
cron = require('cron').CronJob
request = require 'request'
cities =
"横浜": "140010"
"金沢": "170010"
apiUrl = 'http://weather.livedoor.com/forecast/webservice/json/v1?city='
sendBadForecast = (robot, label, id) ->
@nanonanomachine
nanonanomachine / pickup-recipes.coffee
Created May 4, 2015 19:47
ピックアップレシピ表示してくれるやつ
cron = require('cron').CronJob
client = require 'cheerio-httpcli'
module.exports = (robot) ->
# テスト用
#job = new cron '*/1 * * * *', () =>
job = new cron '00 07 * * * ', () =>
robot.logger.debug "pickup_recipes fetch start"
client.fetch 'http://cookpad.com/pickup_recipes', (err, $, res) ->
robot.send {room: "recipe"}, $('title').text()
@nanonanomachine
nanonanomachine / Program.cs
Created July 31, 2015 11:53
ExchangeをC#で操作するマン
using Microsoft.Exchange.WebServices.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OutlookTest
{
internal class Program
{
@nanonanomachine
nanonanomachine / es6-fizzbuzz.js
Created August 11, 2015 01:46
ES6 Generator FizzBuzz
let fizzbuzz = function*(){
for (var val = 1; val < 100; val++) {
if(val % 15 === 0){
yield "FizzBuzz";
}
else if(val % 3 === 0){
yield "Fizz";
}
else if(val % 5 === 0){
yield "Buzz";
@nanonanomachine
nanonanomachine / fizzbuzz.rb
Created August 11, 2015 01:47
Ruby FizzBuzz
(1..100).each do |n|
p case 0
when n % 15 then "FizzBuzz"
when n % 3 then "Fizz"
when n % 5 then "Buzz"
else n
end
end
@nanonanomachine
nanonanomachine / index_mbox.rb
Created November 23, 2015 10:11
最強に雑なmboxデータelasticsearch取り込み
require "bundler/setup"
require "kconv"
Bundler.require
client = Elasticsearch::Client.new log: true
bulk_requests = Array.new
# mbox
mboxes = Mbox.open("./gmail.mbox")
@nanonanomachine
nanonanomachine / lodash.md
Created January 10, 2016 11:06
lodash個人メモ

lodash

コレクションの操作

filter

条件に一致するコレクションを抽出する

@nanonanomachine
nanonanomachine / cloudvision.rb
Last active April 16, 2016 10:15
Cloud Vision API Test
require 'base64'
require 'json'
require 'net/https'
DIRECTORIES = ['DIR PATH']
API_KEY = 'PASTE YOUR API KEY'
API_URL = "https://vision.googleapis.com/v1/images:annotate?key=#{API_KEY}"
def detect(image_path)