Skip to content

Instantly share code, notes, and snippets.

@kinoh
kinoh / linear.js
Created April 1, 2014 17:03
math.js extension for linear algebra
function mathjsEx()
{
var math = mathjs()
math.EPSILON = 1E-15
dot = function (x, y) { return math.subset(math.multiply(math.transpose(x), y), math.index(0, 0)) }
norm = function (x) { return math.sqrt(dot(math.conj(x), x)) }
diagBlock = function (A, B)
{
This file has been truncated, but you can view the full file.
1 1 0000->0001
2 2 0000->0001->0002
3 3 0000->0001->0002->0003
4 4 0000->0001->0002->0003->0004
5 5 0000->0001->0002->0003->0004->0005
6 6 0000->0001->0002->0003->0004->0005->0006
7 7 0000->0001->0002->0003->0004->0005->0006->0007
8 8 0000->0001->0002->0003->0004->0005->0006->0007->0008
9 9 0000->0001->0002->0003->0004->0005->0006->0007->0008->0009
10 10 0000->0001->0002->0003->0004->0005->0006->0007->0008->0009->0010
@kinoh
kinoh / IronySample.cs
Last active August 29, 2015 13:57
.NET Irony sample code
using System;
using System.Collections.Generic;
using System.Linq;
using Irony.Parsing;
namespace IronySample
{
public class MyGrammar : Grammar
{
public MyGrammar()
@kinoh
kinoh / PortAudioEx.cs
Last active August 29, 2015 13:56
PortAudioSharp Extension
using System;
using System.Runtime.InteropServices;
namespace PortAudioSharp
{
class PortAudioException : Exception
{
public PortAudioException(PaError err)
: base(PortAudioAPI.Pa_GetErrorText(err))
{
@kinoh
kinoh / set
Created January 21, 2014 14:39
Set theory
Parameter set: Type.
Parameter uniqueObject: (set -> Prop) -> set.
Axiom UniqueObject: forall P, (exists! x, P x) -> P (uniqueObject P).
Parameter in_: set -> set -> Prop.
Axiom ZF_Ext: forall X Y, (forall z, in_ z X <-> in_ z Y) -> X = Y.
Axiom ZF_Pair: forall x y, exists Z, in_ x Z /\ in_ y Z.
Axiom ZF_Sep: forall P: set -> Prop, forall X,
@kinoh
kinoh / waitAny.fs
Created October 21, 2013 14:18
Wait for any succeeded task.
module Test
open System.IO
open System.Threading
open System.Threading.Tasks
let R = System.Random()
let _work (n : int) : int option =
Thread.Sleep (n * 1000)
if R.Next() % 3 = 0
@kinoh
kinoh / TypeCast.cs
Created October 9, 2013 16:52
Cast an object variable array to the array of the type specified by a Type variable in C#.
using System;
using System.Collections;
using System.Linq;
public class Test
{
public static T[] ConvArray<T>(object[] array)
{
return array.Cast<T>().ToArray();
}
@kinoh
kinoh / ISBNReader.cs
Created October 8, 2013 02:16
Simple ISBN bar code reader with OpenCVSharp and ZXing.Net.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;
using OpenCvSharp;
using ZXing;
namespace ISBNReader
{
static class Program
@kinoh
kinoh / twitter.cs
Last active December 24, 2015 01:29
UserStrem with LINQ to Twitter.
using System;
using System.Collections.Generic;
using System.Linq;
using LinqToTwitter;
using LitJson;
namespace TwitterConsole
{
class Program
{
@kinoh
kinoh / wavwriter.c
Created July 6, 2013 16:19
Convert gnuplot-like text data to wave format.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ROW_SIZE 1024
char header[44] = {
'R', 'I', 'F', 'F',
0, 0, 0, 0,
'W', 'A', 'V', 'E',