Skip to content

Instantly share code, notes, and snippets.

View tamamu's full-sized avatar
😇
living

Eddie tamamu

😇
living
View GitHub Profile
@tamamu
tamamu / sga.rs
Created April 1, 2016 07:40
sga.c in Rust
extern crate rand;
use rand::Rng;
const DATANO: usize = 20;
const POOLSIZE: usize = 30;
const LASTG: usize = 200;
const MRATE: f32 = 0.01;
const YES: i32 = 1;
const NO: i32 = 0;
@tamamu
tamamu / p.rs
Created April 4, 2016 08:55
p.c in Rust
#[macro_use]
extern crate text_io;
extern crate rand;
use rand::Rng;
const INPUTNO: usize = 2;
const HIDDENNO: usize = 2;
const ALPHA: f64 = 20.0;
const MAXINPUTNO: usize = 100;
@tamamu
tamamu / Test.scala
Created May 24, 2016 13:35
学習経過
/**
* Created by tamamu on 5/24/16.
*/
object Test {
private def fib(n: Int): Int = {
def f(k: Int): Int = k match {
case 0 => 0
case 1|2 => 1
case _ => f(k - 2) + f(k - 1)
@tamamu
tamamu / iostream.rs
Created July 3, 2016 15:41
std::cout (C++) in Rust
use std::ops::Shl;
struct Rsout;
struct Endl;
impl<'a> Shl<&'a str> for Rsout {
type Output = Rsout;
fn shl(self, _rhs: &'a str) -> Rsout {
print!("{}", _rhs);
@tamamu
tamamu / autoencoder.rs
Created July 12, 2016 13:36
2016 PFI/PFN Summer Internship Assignment in Rust
type Matrix = Vec<Vec<f64>>;
type Vecf = Vec<f64>;
fn outer(x: &Vecf, y: &Vecf) -> Matrix {
let xlen = x.len();
let ylen = y.len();
let mut z: Matrix = Vec::with_capacity(xlen);
for i in 0..xlen {
z.push(Vec::with_capacity(ylen));
// let mut t: Vec<f64> = Vec::new();
@tamamu
tamamu / lifegame.pde
Last active July 17, 2016 13:27
即席ライフゲーム in Processing
import ddf.minim.*;
int TS = 12;
int fw = 80;
int fh = 80;
int cx = 0;
int cy = 0;
@tamamu
tamamu / myalloc.c
Last active July 28, 2016 14:58
My implementation of malloc in C
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
/* align multiple of 4 bytes */
#define align4(x) (((((x)-1)>>2)<<2)+4)
#define BLOCK_SIZE 12
typedef struct s_block *t_block;
@tamamu
tamamu / sort.pde
Created July 30, 2016 08:06
ソートアルゴリズム可視化 in Processing
float[] data = new float[800];
float bw = 0;
float bh = 0;
boolean flag = false;
void setup(){
frameRate(60);
size(800, 600);
strokeWeight(0);
fill(255,255,255);
(require 'asdf)
(require 'cffi)
(require 'cl-opengl)
(require 'cl-glu)
(require 'cl-glut)
(defvar +vs-source+
"#version 130
in vec3 in_Position;
(require 'asdf)
(require 'cffi)
(require 'cl-opengl)
(require 'cl-glu)
(require 'cl-glut)
(defvar +vs-source+ "#version 130
precision mediump float;