Skip to content

Instantly share code, notes, and snippets.

View jhorikawa's full-sized avatar

Junichiro Horikawa jhorikawa

View GitHub Profile
use_bpm 60
live_loop :pulse do
notes = scale( :e3, :minor_pentatonic).shuffle
with_fx :bitcrusher do
notes.each do |n|
sample :ambi_choir
play n, release: 1
sleep 0.25
end
@jhorikawa
jhorikawa / file0.txt
Created August 31, 2015 20:23
Rhinoceros / Grasshopper / GHPythonで球状グリッドを作ってみる ref: http://qiita.com/jhorikawa/items/ad86e1d3f6fe45a53518
import ghpythonlib.components as ghcomp
import Rhino
import math
objList = []
ptList = []
for i in range(num):
#球状に配列する
y = i * 2 / num - 1 + (1 / num)
r = math.sqrt(1 - y * y)
@jhorikawa
jhorikawa / application_controller.rb
Last active September 5, 2015 18:18
Ruby on RailsをCloud9からHerokuへデプロイするセットアップ覚書 ref: http://qiita.com/jhorikawa/items/84a0f4a7f40f5914ad1a
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def hello
render text: "Hello World"
end
end
@jhorikawa
jhorikawa / file2.txt
Created September 12, 2015 02:28
Grasshopper / Pythonでライノオブジェクトをスクリプトでコントロールするための準備 ref: http://qiita.com/jhorikawa/items/827a83033083507bed91
sc.doc = Rhino.RhinoDoc.ActiveDoc
@jhorikawa
jhorikawa / file0.txt
Created October 31, 2015 06:14
Unity + OpenCVでオプティカルフローを実現してみる ref: http://qiita.com/jhorikawa/items/fafee3373eb3ccef02c8
using System.IO;
using System.Linq;
using Emgu.CV.CvEnum;
using UnityEngine;
using System;
using System.Drawing;
using System.Collections;
using System.Text;
using Emgu.CV;
using Emgu.CV.Structure;
@jhorikawa
jhorikawa / getTrainIcons.py
Last active June 27, 2016 04:42
Download collection of train icons from http://www.trainfrontview.net/.
import urllib
from urllib.request import urlretrieve
from urllib.request import urlopen
from bs4 import BeautifulSoup
import re
import os
baseUrl = "http://www.trainfrontview.net/"
trainUrl = "sozai.htm"
html = urlopen(baseUrl + trainUrl)
@jhorikawa
jhorikawa / SimpleBezier.cs
Created September 18, 2017 13:26
Creating points on simple quadratic bezier curve for Grasshopper C# component.
private void RunScript(List<Point3d> pts, int res, ref object A)
{
List<Point3d> points = new List<Point3d>();
if(pts.Count >= 3){
for(int i = 0; i < pts.Count - 2; i++){
Point3d pt1, pt2, pt3 = new Point3d();
if(pts.Count == 3){
@jhorikawa
jhorikawa / DetectDeviceOrientation.cs
Created October 6, 2017 14:05
Detect device orientation detection for Unity. It works even if the device rotation is locked.
public void DetectDeviceRotation(){
Vector3 acc = Input.acceleration;
if(Mathf.Abs(acc.x) > Mathf.Abs(acc.y)){
if(acc.x < 0){
Debug.Log("Landscape Left");
}else{
Debug.Log("Landscape Right");
}
}else{
@jhorikawa
jhorikawa / textCounter.js
Created November 13, 2017 23:24
After Effect expression for text to create a text counter using time value.
var startFrame = 60.0;
var totalFrame = 240.0;
var totalTime = 10.0;
var t = Math.round((timeToFrames(time)-startFrame)/totalFrame*totalTime);
if(t <0){
"0 時間"
}else if(t <= totalTime){
t + " 時間"
}else{
Math.round(totalTime) + " 時間"
@jhorikawa
jhorikawa / PDFTest.cs
Last active December 12, 2017 08:38
UnityでiTextSharpを使ってPDFを作成する ref: https://qiita.com/jhorikawa_err/items/c50eb9d334f6f4252faf
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using iTextSharp;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
using System;
public class PDFTest : MonoBehaviour {