Skip to content

Instantly share code, notes, and snippets.

@tomo3141592653
tomo3141592653 / now_address.html
Created May 17, 2012 03:10
今いる住所が分かるアプリ
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript">// <![CDATA[
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
//s = position.coords.latitude+","+position.coords.longitude;
//document.getElementById('latlng').innerHTML = s;
var geocoder;
@tomo3141592653
tomo3141592653 / eveeveeve.html
Created May 17, 2012 03:12
今日がクリスマスの何なのか分かるページ
<p id="chiristmas" style="font-size: xx-large;">&nbsp;</p>
<script type="text/javascript">// <![CDATA[
var now =new Date();
var new_year = new Date("Dec 25, 2012 0:0:0");
var num_of_yoi = 1+( new_year.getTime() - now.getTime())/ 86400000;
field= document.getElementById('chiristmas');
var yois = "";
@tomo3141592653
tomo3141592653 / hirata_life.html
Created May 17, 2012 03:14
ひらたともよしの人生がどれくらい終了したか分かるページ
<p id="countdown_death_per" style="font-size: x-large;">&nbsp;</p>
<script type="text/javascript">// <![CDATA[
function tokei_death_per(){
var now =new Date();
var birth_year = new Date("Apr 23, 1980 0:0:0");
var sec = -( birth_year.getTime() - now.getTime())/1000;
var per = sec/31556926/80.37 *100;
@tomo3141592653
tomo3141592653 / twitter_lat.rb
Created May 17, 2012 03:17
タイムラインから位置を表す単語を含むツイートを抽出し緯度経度で表示する。
# -*- encoding: utf-8 -*-
require "MeCab"
require "twitter"
require "open-uri"
require "uri"
require "kconv"
require "ir_b"
list =Twitter.list_timeline("tomo3141592653", "met",:per_page=>300)
@tomo3141592653
tomo3141592653 / 平田朋義の百冊
Last active October 3, 2021 23:38
平田ベスト本百冊
1 ガリヴァー旅行記
2 アイルランドの貧民の子供たちが両親及び国の負担となることを防ぎ、国家社会の有益なる存在たらしめるための穏健なる提案
3 アーサー王宮廷のコネチカット・ヤンキー
4 ファウンデーションシリーズ(アシモフ)
5 トリフィド時代
6 星を継ぐものシリーズ
7 思考の道具箱(ルディーラッカー)
8 人間はどこまでチンパンジーか?/銃 病原菌 鉄/文明崩壊
9 ニンジャスレイヤー
10 精子戦争
@tomo3141592653
tomo3141592653 / get_amazonurl_from_bookname.rb
Last active August 29, 2015 13:58
本の名前を入力するとamazonのurlが表示されるrubyスクリプト
# -*- encoding: utf-8 -*-
require 'rubygems'
require 'mechanize' #gem install mechanize
require 'uri'
def item2url(item)
item = item.split("(").first
item = item.split("/").first
item_escape = URI.escape(item)
@tomo3141592653
tomo3141592653 / xlsx_to_tsv.rb
Last active August 29, 2015 14:02
convert .xlsx file to .tsv file
#! /usr/bin/ruby -Ku
#usage:
#type to terminal "ruby xlsx_to_tsv.rb hoge.xlsx" and then hoge.tsv will be made in the current folder.
#or you can also use wildcard ex "ruby xlsx_to_tsv.rb *.xlsx"
#YOU SHULD NOTE THAT *.tsv in current folder will be overwritten.
#data is assumed to be only in first sheet.
require 'rubygems'
import random
import math
def gcd(a, b):
while b:
a, b = b, a % b
return a
count_coprime = 0
count_all = 0
while(1):
# usage:
# install exiftool from http://www.sno.phy.queensu.ca/~phil/exiftool/
# set folder name as yyyymmdd(ex.20060801)
# and type
# ls | ruby exif_edit.rb
while gets
folder = $_.chomp
date = folder[0..3] +":"+ folder[4..5] + ":" + folder[6..7] + " 12:0:0"
`exiftool -alldates=\'#{date}\' -overwrite_original #{folder}/*.JPG`
p folder
import numpy as np
def get_z(arr):
return (np.median(arr) - arr.mean())/arr.std()
arr = (np.random.rand(101) * 10000).astype("int")
z = get_z(arr)
for ite in range(1000000):
i = int(np.random.rand()*101)