Skip to content

Instantly share code, notes, and snippets.

View foota's full-sized avatar

Noriyuki Futatsugi foota

View GitHub Profile
@foota
foota / mandelbrot.scala
Created May 14, 2012 17:35
Mandelbrot sets (serial processing)
// mandelbrot.scala without actor by nox, 2011.07.09
import scala.annotation.tailrec
import java.io.FileOutputStream
import java.awt.image.BufferedImage
import java.awt.Color
import javax.imageio.ImageIO
import scala.testing.Benchmark
/**
@foota
foota / mandelbrot_multigpu.cu
Created May 14, 2012 17:37
Madelbrot sets using multi GPU devices
// madelbrot using multi GPU devices by nox, 2011.06.06
// nvcc -lcutil_x86_64 -arch sm_13 -use_fast_math -prec-sqrt=false -keep -L ~/NVIDIA_GPU_Computing_SDK/C/lib -I ~/NVIDIA_GPU_Computing_SDK/C/common/inc -g mandelbrot_multigpu.cu -o mandelbrot_multigpu
#include <iostream>
#include <fstream>
#include "cutil_inline.h"
using namespace std;
@foota
foota / base64.cpp
Created May 14, 2012 17:39
Base64 encoder/decoder
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <cstring>
using namespace std;
int base64encode(const char* p, char* buf)
{
@foota
foota / matching_residue.cpp
Created May 14, 2012 17:41
Subgraph isomorphism problem for amino acids in proteins
// matching_residue.cpp by nox, 2011.04.18
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
@foota
foota / Place.pde
Created May 14, 2012 17:46
Great East Japan Earthquake visualizer
class Place {
int mins;
int mon, d, h, m;
float x, y;
float magnitude;
float depth;
String name;
public Place(int mins, int mon, int d, int h, int m, float x, float y, float magnitude, float depth, String name) {
this.mins = mins;
@foota
foota / mandelbrot_thread.cu
Created May 14, 2012 17:49
Mandelbrot sets using 2 GPU devices
// Mandelbrot set using GPGPU by nox, 2011.02.12
// nvcc -lcutil_x86_64 -arch sm_13 -use_fast_math -prec-sqrt=false -keep -L ~/NVIDIA_GPU_Computing_SDK/C/lib -I ~/NVIDIA_GPU_Computing_SDK/C/common/inc -g mandelbrot_thread.cu -o mandelbrot_thread
#include <iostream>
#include <fstream>
#include <cutil_inline.h>
#include <multithreading.h>
using namespace std;
@foota
foota / weights.cpp
Created May 14, 2012 17:53
Combinations of weights
// 指定した重さを量るのに使う錘の組み合わせの数を求めるプログラム.
// 錘は 1g, 5g, 10g, 50g, 100g, 500g の6種類.
// 重さ 700,000g 程度までなら桁あふれせずに計算できる.
#include <iostream>
#include <map>
#include <algorithm>
#include <cstdlib>
using namespace std;
@foota
foota / translator.py
Created May 14, 2012 17:56
Automatic translator
# -*- coding: utf-8 -*-
import android,urllib,urllib2,simplejson
def translator(text,from_lang,to_lang):
url='http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=%s&langpair=%s%%7C%s'%(urllib.quote(text.encode('utf-8')),from_lang,to_lang)
data=simplejson.loads(urllib2.urlopen(url).read())
return data['responseData']['translatedText']
droid=android.Android()
@foota
foota / fake_japanese.py
Created May 14, 2012 18:00
SL4A speaks in Japanese
# -*- coding: utf-8 -*-
import android
import sys,os,urllib,urllib2,simplejson
from BeautifulSoup import BeautifulSoup
YAHOO_APP_ID='Yahoo!デベロッパーネットワークのアプリケーションID'
KEITAISO_API='http://jlp.yahooapis.jp/MAService/V1/parse?appid=%s&results=ma&sentence=%s'
KANA=[u'きゃ',u'きぃ',u'きゅ',u'きぇ',u'きょ',
@foota
foota / android_bbs.py
Created May 14, 2012 18:02
BBS on Android devices (SL4A)
# -*- coding: utf-8 -*-
import cgi,sqlite3,datetime
from wsgiref.simple_server import make_server
LIMIT=50 # 最大表示記事数.
DB_FILE='/sdcard/bbs.sqlite'
con=sqlite3.connect(DB_FILE)
cur=con.cursor()