Skip to content

Instantly share code, notes, and snippets.

@sanofc
sanofc / file0.txt
Last active August 14, 2017 16:59
OpenShift Originのインストール(Windows10+VirtualBox) ref: http://qiita.com/sanofc/items/b5a40f7100c5bf15024e
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@sanofc
sanofc / perlin.cpp
Created January 14, 2016 14:13
perlin noise c++ ver
#include "perlin.h"
perlin::perlin(){
int permutation[] = { 151,160,137,91,90,15,
131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,
190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,
88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166,
77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,
102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196,
135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123,
@sanofc
sanofc / heat2.py
Created December 30, 2015 18:03
熱伝導を割と簡単に解くで
#coding: utf-8
L=0.1 #長さ
M=10 #分割数
dx=L/M #空間刻み
dt=1.0 #時間刻み
N=100 #時間ステップ数
alpha=80.2/(7874.0*440.0) #熱伝導率
gamma=dt/dx**2
a=alpha*gamma
@sanofc
sanofc / heat.py
Last active December 30, 2015 18:00
熱伝導を陰解法で解くで
#coding: utf-8
L=0.1 #長さ
M=10 #分割数
dx=L/M #空間刻み
dt=1.0 #時間刻み
N=100 #時間ステップ数
alpha=80.2/(7874.0*440.0) #熱伝導率
gamma=dt/dx**2
a=alpha*gamma
@sanofc
sanofc / perlin.c
Created October 31, 2015 14:00
パーリンノイズ
#include <stdio.h>
#include <math.h>
int p[512];
void init(){
int permutation[] = { 151,160,137,91,90,15,
131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,
190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,
@sanofc
sanofc / montihall.cpp
Last active October 19, 2015 10:15
モンティホール問題をシミュレーションする ref: http://qiita.com/sanofc/items/954e678e3220e7f27104
#include <iostream>
#include <random>
#include <sstream>
#include <memory>
using namespace std;
struct Door{
bool state[3]; //goat(false) or prize(true)
int player;
@sanofc
sanofc / factrial.swift
Last active October 10, 2015 13:06
不動点コンビネータで階乗計算
func recursiveClosure(factorialImp: (UInt->UInt, UInt) -> UInt) -> (UInt->UInt) {
var closure:(UInt->UInt)!
closure = { (value:UInt) -> UInt in
return factorialImp(closure, value)
}
return closure
}
let factrial = recursiveClosure{(closure:UInt->UInt,value:UInt) -> UInt in
return value == 0 ? 1 : value * closure(value-1)
@sanofc
sanofc / MultiArray.swift
Last active October 10, 2015 02:59
Swiftのサブスクリプトで割と汎用的な多次元配列を作る ref: http://qiita.com/sanofc/items/d6195c3e99809ac64de7
class MultiArray<T>{
var size:[Int]
var data: [T?]
init(size:Int...){
self.size = size
let multiply = { (a:Int, b:Int) -> Int in a * b}
data = [T?](count: size.reduce(1,combine: multiply), repeatedValue: nil)
}
@sanofc
sanofc / GameViewController.swift
Last active October 4, 2015 18:27
とりあえずSwiftでOpenGL ESの一枚四角を描く ref: http://qiita.com/sanofc/items/e69ab6dcc6d9266d605b
import GLKit
import OpenGLES
let gVertices: [GLfloat] = [
-0.5, -0.5, 0.0,
-0.5, 0.5, 0.0,
0.5, -0.5, 0.0,
0.5, 0.5, 0.0,
]
@sanofc
sanofc / Content.swift
Last active September 29, 2015 00:11
SwiftのPlaygroundでマンデルブロ集合 ref: http://qiita.com/sanofc/items/41dffd068f1af6d84997
//: ## Mandelbrot Set
let result = calc()
draw(result)