Skip to content

Instantly share code, notes, and snippets.

View rinx's full-sized avatar
🍵
Drinking sencha all the time

Rintaro Okamura rinx

🍵
Drinking sencha all the time
View GitHub Profile
@rinx
rinx / upload_to_gdrive.lua
Created February 6, 2016 03:45
flashair to google drive
local cjson = require "cjson"
-- Basic account info
local client_id = ""
local client_secret = ""
local refresh_token = ""
local function getAuth()
local mes="client_id="..client_id
mes=mes.."&client_secret="..client_secret
@rinx
rinx / fibo.f90
Created November 18, 2015 03:21
An example of recursive function on fortran.
program main
print *, fib(30)
contains
recursive function fib(n) result(res)
integer :: n
integer :: res
if (n <= 2) then
@rinx
rinx / mandelbrot.hs
Created November 15, 2015 12:45
draw mandelbrot set as ascii art
import Data.Complex
maxIter :: Int
maxIter = 127
magnification :: Double
magnification = 10.0
xrange :: [Int]
xrange = [-30..30]
@rinx
rinx / mc.hs
Created September 24, 2015 02:02
monte carlo with haskell
{-# LANGUAGE ExtendedDefaultRules, NoMonomorphismRestriction #-}
import Conduit
main :: IO ()
main = do
let cnt = 100000000
successes <- sourceRandomN cnt $$ lengthIfC (\(x, y) -> x*x + y*y < 1)
print $ successes / cnt * 4
-- https://www.fpcomplete.com/blog/2014/03/monte-carlo-haskell
@rinx
rinx / bmc_1d_rad_trans.rb
Created August 21, 2015 04:36
backward monte carlo simulator of one dimensional radiative transfer
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# backward monte carlo simulator of one dimensional radiative transfer
# detector location is the top of atmosphere
np = 10000 # number of photon
tau = 1.0 # optical thickness
alb = 0.5 # surface albedo
omg = 0.5 # single scattering albedo
@rinx
rinx / mc_1d_rad_trans.rb
Last active August 29, 2015 14:17
monte carlo simulation of one dimensional radiative transfer
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# monte carlo simulation of one dimensional radiative transfer
#
# The original code written in Fortran 77
# "Modeling of radiative transfer in cloudy atmospheres
# and plant canopies using Monte Carlo methods", Tech. rep FTR, 7
@rinx
rinx / grshark.rb
Created March 18, 2015 14:03
A sample script of grooveshark gem.
# -*- coding: utf-8 -*-
require 'grooveshark'
client = Grooveshark::Client.new
songs = client.search_songs('素晴らしい世界 FLOWER FLOWER')
songs.each do |s|
puts "#{s.name} - #{s.artist}"
@rinx
rinx / sortpairs.rb
Created February 6, 2015 17:18
sort num and values
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
=begin
if input is below...
>>>
AAAA
30.3
BBBB
502.0
@rinx
rinx / flighttrack_json_parse.rb
Created December 11, 2014 05:59
Get and parse flight track from flightrader24.com
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'net/http'
require 'uri'
require 'json'
flightIds=ARGV
api_url='mobile.api.fr24.com/common/v1/flight-playback.json'
@rinx
rinx / dl_flighttrack_json.sh
Created December 9, 2014 08:33
Get json data from flightrader24.com
#!/bin/sh
CMDNAME=`basename $0`
if [ ! $# -eq 2 ]; then
echo "Usage: $CMDNAME output flightId" 1>&2
exit 1
fi
output=$1