Skip to content

Instantly share code, notes, and snippets.

@fukuroder
fukuroder / alsa_filter_test.cpp
Last active August 29, 2015 14:05
Raspberry Piにナノコンつなげてflac再生してフィルタをかける
/*
* alsa_filter_test.cpp
*
* Created by fukuroda (https://github.com/fukuroder)
*/
// g++ alsa_filter_test.cpp -std=c++0x -O3 -lasound -lsndfile
#include<alsa/asoundlib.h> // sudo apt-get install libasound2-dev
#include<sndfile.h> // sudo apt-get install libsndfile1-dev
@fukuroder
fukuroder / ocaml_alsa_test.ml
Last active August 29, 2015 14:08
OCamlでWAVファイル読み込んでALSAで再生するテスト
(*
* ocaml_alsa_test.ml
*
* Created by fukuroda (https://github.com/fukuroder)
*)
(* sudo apt-get install libalsa-ocaml-dev *)
(* ocamlfind ocamlopt -o ocaml_alsa_test ocaml_alsa_test.ml -package alsa -linkpkg *)
@fukuroder
fukuroder / elixir_wav_read_test.exs
Last active August 29, 2015 14:08
ElixirでWAVファイルを読み込む(ヘッダのみ)
#
# elixir_wav_read_test.exs
#
# Created by fukuroda (https://github.com/fukuroder)
#
# >elixir elixir_wav_read_test.exs
use Bitwise
# -*- coding: utf-8 -*-
import scipy.io, numpy as np, numpy.linalg as nl
name = 'hcircuit'
eps = 1.0e-3
# read matrix and vector
print '#A:', scipy.io.mminfo(name + '.mtx.gz')
print '#b:', scipy.io.mminfo(name + '_b.mtx.gz')
A = scipy.io.mmread(name + '.mtx.gz').tocsr()
@fukuroder
fukuroder / lowpass_filter.ps1
Last active March 3, 2017 15:45
Low-pass filter with Windows PowerShell
# create lowpass filter
function create_lowpass_filter(
[double]$samplerate,
[double]$cutoff_freq,
[double]$resonance)
{
# a0 + a1*z^-1 + a2*z^-2
# H(z) = ------------------------
# 1 + b1*z^-1 + b2*z^-2
$s = [Math]::Tan($cutoff_freq*3.14159265/$samplerate)
@fukuroder
fukuroder / xaml.ps1
Last active August 30, 2015 14:00
XAML in Windows PowerShell
Add-Type -AssemblyName presentationframework
[xml]$xaml = @'
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="100" Width="200" ResizeMode="NoResize">
<Grid>
<Button Name="button1" Content="XAML"/>
</Grid>
</Window>
#include "../JuceLibraryCode/JuceHeader.h"
int main ()
{
var json = JSON::parse("{\"a\":[ {\"b\":[1,2,3,4,5]}, {\"c\":[6,7,8,9]} ] }");
std::cout << static_cast<int>(json["a"][0]["b"][4]) << std::endl; // 5
return 0;
}
#include "../JuceLibraryCode/JuceHeader.h"
int main()
{
DynamicObject* obj1 = new DynamicObject();
obj1->setProperty("b", Array<var>{1, 2, 3, 4});
DynamicObject* obj2 = new DynamicObject();
obj2->setProperty("c", Array<var>{6, 7, 8, 9});
DynamicObject* obj3 = new DynamicObject();
obj3->setProperty("a", Array<var>{obj1, obj2});
#include "../JuceLibraryCode/JuceHeader.h"
std::vector<uint32> Encrypt(const std::string& text, const std::string& key)
{
// create Blowfish
BlowFish bf(key.data(), key.length());
// encrypt
std::vector<uint32> result;
auto p = text.begin();
PKG core
PKG alsa
PKG yojson