Skip to content

Instantly share code, notes, and snippets.

View jj1bdx's full-sized avatar
🏠
Working from home

Kenji Rikitake jj1bdx

🏠
Working from home
View GitHub Profile
@jj1bdx
jj1bdx / sunrise.py
Created October 6, 2009 03:42
PyEphem script to show sunrise and sunset
#!/usr/local/bin/python
# a Python script for PyEphem
# http://rhodesmill.org/pyephem/
# to find out the sunrise and sunset time
# in UTC
# (add more code for the local time by yourself)
# by Kenji Rikitake 6-OCT-2009
from datetime import datetime, timedelta
@jj1bdx
jj1bdx / bignum_root.erl
Created January 26, 2010 05:31
obsolete: see 293169
%% Power function (X ^ Y) and root function (X ^ (1/Y)) for
%% integers in Erlang
%% by Kenji Rikitake <kenji.rikitake@acm.org> 26-JAN-2010
%% Distributed under MIT license at the end of the source code.
-module(bignum_root).
-export([power/2, root/2]).
%% significand digits for float estimation
@jj1bdx
jj1bdx / bignum_sqrt.erl
Created January 26, 2010 07:43
obsolete: see 293169
%% square root function for integers in Erlang
%% by Kenji Rikitake <kenji.rikitake@acm.org> 26-JAN-2010
%% Distributed under MIT license at the end of the source code.
-module(bignum_sqrt).
-export([sqrt/1]).
%% significand digits for float estimation
-define(DIGITS, 10).
@jj1bdx
jj1bdx / bignum_root.erl
Created February 2, 2010 23:28 — forked from pichi/bignum_root.erl
Power function (X ^ Y) and root function (X ^ (1/Y)) for integers in Erlang
%% Power function (X ^ Y) and root function (X ^ (1/Y)) for
%% integers in Erlang
%% by Kenji Rikitake <kenji.rikitake@acm.org> 26-JAN-2010
%% modified by Hynek Vychodil <vychodil.hynek@gmail.com> 2-FEB-2010
%% modified by Kenji Rikitake <kenji.rikitake@acm.org> 3-FEB-2010
%% Distributed under MIT license at the end of the source code.
-module(bignum_root).
-export([power/2, root/2, sqrt/1]).
@jj1bdx
jj1bdx / xorshift-sevenstage.c
Created November 21, 2010 23:34
NOTE: see also https://github.com/jj1bdx/xorshift-sevenstage/ --- A sample code from available from the following journal paper, as the Figure 1: François Panneton and Pierre L'ecuyer. 2005. On the xorshift random number generators. ACM Trans. Model. Comput. Simul. 15, 4 (October 2005), 346-361. DOI=10.1145/1113316.11133
#include <stdio.h>
static unsigned int x[8]; /* Generator's state.*/
/* Advances by one step and returns a number in [0,1).*/
unsigned int xorshift7 (void) {
static int k = 0;
unsigned int y, t;
t = x[(k+7) & 0x7U]; t = t ^ (t<<13); y = t ^ (t<<9);
t = x[(k+4) & 0x7U]; y ^= t ^ (t<<7);
@jj1bdx
jj1bdx / random_wh06.erl
Created November 24, 2010 05:01
Modified version of random module to use Wichmann-Hill algorithm published on 2006 - also included in jj1bdx/sfmt-erlang
%% Modified version of random module
%% to use Wichmann-Hill algorithm published on 2006
%% which succeeds the old AS183 algorithm in 1982.
%% Copyright (c) 2010 Kenji Rikitake All rights reserved.
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
@jj1bdx
jj1bdx / gist:738946
Created December 13, 2010 12:31 — forked from voluntas/gist:737963
Corporations using Erlang/OTP
* Bluetail/Alteon/Nortel (distributed, fault tolerant email system, SSL accelerator)
* Cellpoint (Location-based Mobile Services)
* Corelatus (SS7 monitoring).
* dqdp.net (in Latvian) (Web Services).
* Facebook (Facebook chat backend)
* Finnish Meteorological Institute (Data acquisition and real-time monitoring)
* IDT corp. (Real-time least-cost routing expert systems)
* Kreditor (Electronic payment systems)
* Mobilearts (GSM and UMTS services)
@jj1bdx
jj1bdx / resettimeofday.c
Created December 19, 2010 13:33
An old standalone C code for executing gettimeofday() and settimeofday() system calls for *BSD
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
int main(int argc, char **argv)
{
struct timeval t;
struct timezone tz;
if (-1 == gettimeofday(&t, &tz)) {
{erl_opts, [fail_on_warning, debug_info]}.
{xref_checks, [undefined_function_calls]}.
%% {eunit_opts, [verbose, {report,{eunit_surefire,[{dir,"."}]}}]}.
{cover_enabled, true}.
{clean_files, [".eunit", "ebin/*.beam"]}.
{dialyzer_opts,
[{warnings,
[no_return,
no_unused,
no_improper_lists,
@jj1bdx
jj1bdx / permission-fix.sh
Created August 21, 2011 00:41
When you forget "umask 022" to install FreeBSD ports...
#!/bin/sh
# generic port permission fix script
# when you forget "umask 022"
cd /usr/ports
find . -type d -not -perm -001 | xargs chmod go+rx
find . -type f -and -not -perm -444 | xargs chmod go+r