Skip to content

Instantly share code, notes, and snippets.

View hirokazumiyaji's full-sized avatar

Hirokazu Miyaji hirokazumiyaji

View GitHub Profile
@hirokazumiyaji
hirokazumiyaji / docomo.coffee
Last active January 10, 2016 13:31
docomo bot
class Docomo
API_PREFIX = "https://api.apigw.smt.docomo.ne.jp"
constructor: (apiKey) ->
@apiKey = apiKey
@dialogueStatus = {}
@dialogue: (request, username, message, t = null) ->
url = "#{API_PREFIX}/dialogue/v1/dialogue?APIKEY=#{@apiKey}"
@hirokazumiyaji
hirokazumiyaji / default.rb
Created January 6, 2016 22:44
itamae recipe apache small light
execute "apt-get update"
execute "download libjpeg-turbo.deb" do
command "wget http://sourceforge.net/projects/libjpeg-turbo/files/#{node[:libjpegturbo][:version]}/libjpeg-turbo-official_#{node[:libjpegturbo][:version]}_amd64.deb"
cwd "/tmp"
not_if "test -d /opt/libjpeg-turbo"
end
execute "install libjpeg-turbo" do
command "dpkg -i libjpeg-turbo-official_#{node[:libjpegturbo][:version]}_amd64.deb"
@hirokazumiyaji
hirokazumiyaji / rails-api-new
Last active January 10, 2016 13:30
Rails API New Project
#!/bin/sh
rails new --api <project name> -T --skip-bundle --skip-test-unit -d mysql
@hirokazumiyaji
hirokazumiyaji / default.rb
Last active December 30, 2017 14:32
itamae nginx small light recipe
execute "apt-get update"
execute "download libjpeg-turbo.deb" do
command "wget http://sourceforge.net/projects/libjpeg-turbo/files/#{node[:libjpegturbo][:version]}/libjpeg-turbo-official_#{node[:libjpegturbo][:version]}_amd64.deb"
cwd "/tmp"
not_if "test -d /opt/libjpeg-turbo"
end
execute "install libjpeg-turbo" do
command "dpkg -i libjpeg-turbo-official_#{node[:libjpegturbo][:version]}_amd64.deb"
"use strict";
function timediff(datetime, check_time=null, with_time=false) {
check_time = check_time || Math.floor(new Date().getTime() / 1000);
let timediff = check_time - datetime;
if (timediff === 0) {
return "now";
}
if (timediff < 60) {
return "";
@hirokazumiyaji
hirokazumiyaji / playerunit.py
Last active October 25, 2015 09:19
Techlunch
# coding: utf-8
from collections import defaultdict
from django.db import models
from django.utils.functional import cached_property
class PlayerUnit(models.Model):
id = models.UUIDField(primary_key=True)
player_id = models.UUIDField(db_index=True)
function quoteReply(tweetId) {
var tweetText = document.getElementById("#" + tweetId).innerText;
var textarea = document.getElementById("#form-textarea");
textarea.value = ">" + tweetText + "¥n";
textarea.forcus();
}
@hirokazumiyaji
hirokazumiyaji / remove.sh
Created October 9, 2015 02:03
git remote branch remove(branch hit feature)
for b in `git bra --merged | grep feature | sed -e 's/remotes\/origin\///g' | head -n 10`; do git push origin :$b; sleep 1; done
<!DOCTYPE html>
<html>
<head>
<title>Timeline</title>
</head>
<body>
<div>
<ul>
<li>
message1
import Foundation
public class GithubAPI {
public init() {
}
public func request<Endpoint: APIEndpoint>(endpoint: Endpoint, handler: (data, response, error) -> Void) {
let url = NSURL(string: "https://api.github.com/search/repositories?q=Hatena&page=1")!
let request = NSMutableURLRequest(URL: url)
request.SetValue("application/vnd.github.v3+json", forHTTPHeaderField: "Accept")