Skip to content

Instantly share code, notes, and snippets.

View foota's full-sized avatar

Noriyuki Futatsugi foota

View GitHub Profile
@foota
foota / gist:2689028
Created May 13, 2012 15:55
Tetration
def tetration(a, n):
b = 1.0
for i in range(n): b = a**b
return b
@foota
foota / tetration.py
Created May 13, 2012 15:57
Tetration fractal (Python)
#!/usr/bin/env python
import sys, os, math, time
from PIL import Image
def tetration(l, t, w, h, sw, sh, mit):
data = []
for ky in range(sh):
for kx in range(sw):
x = l + w * kx / (sw - 1)
@foota
foota / tetration.cpp
Created May 13, 2012 16:07
Tetration fractal (C++)
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#ifdef _MSC_VER
inline double get_time()
{
@foota
foota / tetration_tbb.cpp
Created May 13, 2012 16:09
Tetration fractal (C++ with TBB)
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <sys/time.h>
#include "tbb/task_scheduler_init.h"
#include "tbb/parallel_for.h"
@foota
foota / image_tetration.py
Created May 13, 2012 16:11
Image file from tetration fractal data
#!/usr/bin/env python
import sys, os
from PIL import Image
def main(args):
if len(args) < 3:
print >>sys.stderr, "Usage: %s datafile imagefile" % os.path.basename(args[0])
sys.exit(1)
@foota
foota / lastone.cpp
Created May 14, 2012 17:17
Last One solver
// Last One solver by nox, 14 Oct. 2011
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
@foota
foota / nodes.dat
Created May 14, 2012 17:20
Route solver
27 273 1 3 6
21 128 0 2
125 23 1 9
117 221 0 4 5 6
141 178 3 7
167 178 3 7
195 178 0 3 7
192 110 4 5 6 8
193 91 7 9
151 41 2 8
@foota
foota / googl.py
Created May 14, 2012 17:27
goo.gl URL shortener
import sys,re
from urllib2 import urlopen as U, Request as R
from json import loads as J
API,URL="https://www.googleapis.com/urlshortener/v1/url",sys.argv[1]
if re.match('http://goo\.gl/.+',URL):print J(U(API+'?shortUrl=%s'%URL).read())['longUrl']
else:print J(U(R(API,'{"longUrl":"%s"}'%URL,{'Content-Type':'application/json'})).read())['id']
exec(r"""%s'''gzga*%%%%,hmkl*ocr*nco`fc"a8ajp*mpf*a+\\0+.p%%%s'kormpv"mq.`cqg469gzga*`cqg46,fgamfgqvpkle*mq,rcvj,`cqglcog*]]dkng]]+Y8/1_++')))%%+++''')))"""%(lambda _:(_,_))("exec(''.join(map(lambda _:chr(ord(_)^2),"))
@foota
foota / mandelbrot.scala
Created May 14, 2012 17:34
Mandelbrot sets (parallel processing)
// mandelbrot.scala with actor by nox, 2011.07.09
import scala.actors._, Actor._
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