Skip to content

Instantly share code, notes, and snippets.

var gamepad = null;
var timer = null;
window.addEventListener("gamepadconnected", function(e) {
if (!gamepad) {
gamepad = e.gamepad;
timer = setInterval('updateStatus()', 100);
}
});
@hnaohiro
hnaohiro / .vimrc
Created April 1, 2014 09:30
simple vimrc
set nowritebackup
set nobackup
set noswapfile
set clipboard+=unnamed
set nrformats-=octal
set timeoutlen=3500
set hidden
set history=50
set formatoptions+=mM
@hnaohiro
hnaohiro / python-smtp
Created January 19, 2013 10:47
Gmailでメール送信をPythonで
#!/usr/bin/env python
import sys
from optparse import OptionParser
import smtplib
from email.MIMEText import MIMEText
from email.Header import Header
from email.Utils import formatdate
@hnaohiro
hnaohiro / java-googlechart
Last active December 11, 2015 08:19
JavaでGoogle Char APIから図を作成するサンプル
import java.io.*;
import java.net.*;
import java.util.*;
import javax.swing.*;
public class GoogleChart {
/** Googleから画像を取得 */
public ImageIcon get(Map<String, String> params) throws IOException {
Object[] keys = params.keySet().toArray();
@hnaohiro
hnaohiro / go-iconv
Created January 19, 2013 13:51
Golangでincovを使うサンプル
package main
/*
#include <stdlib.h>
#include <iconv.h>
#cgo LDFLAGS: -liconv
*/
import "C"
import (
"unsafe"
@hnaohiro
hnaohiro / go-http
Last active December 11, 2015 08:28
Golangでcookie機能付きhttpclient
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
)
type Jar struct {
@hnaohiro
hnaohiro / ruby-userstream
Created January 20, 2013 22:09
RubyでUserStreamsを使うサンプル
require 'tweetstream'
TweetStream.configure do |config|
config.consumer_key = '********'
config.consumer_secret = '********'
config.oauth_token = '********'
config.oauth_token_secret = '********'
config.auth_method = :oauth
end
@hnaohiro
hnaohiro / autopost-hatenablog
Created January 23, 2013 21:01
はてなブログへの投稿プログラム
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'mechanize'
username = '****'
password = '****'
agent = Mechanize.new
@hnaohiro
hnaohiro / struct2map.go
Created January 24, 2013 21:35
Golangでreflectを使ってstructからmapへ変換
package main
import (
"fmt"
"reflect"
)
func StructToMap(data interface{}) map[string]interface{} {
result := make(map[string]interface{})
elem := reflect.ValueOf(data).Elem()
@hnaohiro
hnaohiro / mongo2redis.rb
Last active December 12, 2015 09:59
MongoのデータをRedisに移して検索する
# encoding: utf-8
require 'redis'
require 'mongo'
def mongo2redis
redis = Redis.new
redis.flushall
connection = Mongo::Connection.new