Skip to content

Instantly share code, notes, and snippets.

@phi16
phi16 / main.hs
Created July 8, 2016 10:05
DFA to Regex
{-# LANGUAGE TupleSections #-}
import qualified Data.Map as M
import qualified Data.Set as S
import Data.List
import Data.Function
import System.IO
import Control.Monad
data C = O | I deriving (Eq, Ord, Enum, Show)
@phi16
phi16 / gen.js
Created October 7, 2016 02:55
Reader Monad
function *f(){
var a = yield "Arg1";
var b = yield "Arg2";
return a+b;
}
function *add(g1,g2){
var x = yield* g1;
var y = yield* g2;
return x+y;
@phi16
phi16 / logic_practice.agda
Last active October 20, 2016 00:54
科哲
module logic_practice where
infixr 0 _$_
infixl 10 _⇒_ _⇔_
infixl 20 _∨_ _∧_
infix 30 ¬_
_$_ : {A B : Set} → (A → B) → A → B
_$_ f = f
@phi16
phi16 / main.hs
Created November 7, 2016 14:24
Boehm-Berarducci
{-# LANGUAGE Rank2Types #-}
newtype List a = List (forall r. (a -> r -> r) -> r -> r)
instance Show a => Show (List a) where
show (List xs) = show $ xs (:) []
nil :: List a
nil = List $ \f x -> x
cons :: a -> List a -> List a
@phi16
phi16 / Main.hs
Created November 11, 2016 05:29
sch
import Prelude hiding (lines)
import System.Console.Haskeline
import System.Directory
import System.Process
import Data.List hiding (lines)
import Data.Maybe (fromMaybe)
import Data.Conduit hiding (mapM_)
import Data.Conduit.List (sourceList,consume)
import Data.Conduit.ProcessOld
import Data.ByteString.Char8 (ByteString,pack,unpack,lines)
@phi16
phi16 / index.html
Created November 12, 2016 03:30
Canvas putImageData
<!DOCTYPE html>
<head>
<title>test</title>
<script type="text/javascript">
var cvs2,ctx2;
var cvs,ctx;
var cnt = 0;
function render(){
ctx.fillStyle = "rgb(255,255,255)";
@phi16
phi16 / qr.js
Created December 10, 2017 07:39
// dokka kara totte kita
function dataURItoBlob(dataURI) {
// convert base64/URLEncoded data component to raw binary data held in a string
var byteString;
if (dataURI.split(',')[0].indexOf('base64') >= 0)
byteString = atob(dataURI.split(',')[1]);
else
byteString = unescape(dataURI.split(',')[1]);
// separate out the mime component
Shader "Mochi/Snow"
{
Properties
{
_Color ("Color", Color) = (0.5,0.8,1,1)
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue"="Transparent" "LightMode"="ForwardBase" "DisableBatching"="True" }
LOD 100
@phi16
phi16 / Air.shader
Created August 1, 2020 07:36
original
Shader "Amebient/Air"
{
Properties
{
_Color ("Color", Color) = (0.5,0.8,1,1)
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue"="Transparent-525" "LightMode"="ForwardBase" "DisableBatching"="True" }
LOD 100
@phi16
phi16 / MeshGenerator.cs
Last active August 1, 2020 07:40
don't use this without rewriting the `path`
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Events;
using UnityEditor.Animations;
#endif
public class MeshGenerator : MonoBehaviour {