Skip to content

Instantly share code, notes, and snippets.

@yoggy
yoggy / midi_in_sample.cpp
Created December 16, 2011 08:46
MIDI-in sample program for Win32 (using winmm.lib)
#include <SDKDDKVer.h>
#include <Windows.h>
#include <stdio.h>
#include <conio.h>
#include <mmsystem.h>
#pragma comment(lib, "winmm.lib")
void PrintMidiDevices()
@mmagm
mmagm / heap-sort.hs
Last active February 2, 2018 07:21
haskell heap sort
import Data.List
swap :: Int -> Int -> [a] -> [a]
swap i j xs | i == j = xs
swap i j xs | otherwise = initial ++ (xs !! b) : middle ++ (xs !! a) : end
where [a,b] = sort [i,j]
initial = take a xs
middle = take (b-a-1) (drop (a+1) xs)
end = drop (b+1) xs
@cespare
cespare / main.go
Created February 20, 2013 03:05
Example of testing Go HTTP servers using httptest.Server.
package main
import (
"log"
"myserver"
"net/http"
)
const addr = "localhost:12345"
@okapies
okapies / promises-are-functional.md
Last active August 14, 2023 11:44
翻訳: ”命令型のコールバック、関数型のプロミス: Node が逸した最大の機会” by James Coglan

命令型のコールバック、関数型のプロミス: Node が逸した最大の機会

Original: "Callbacks are imperative, promises are functional: Node's biggest missed opportunity" by James Coglan

Translated by Yuta Okamoto (@okapies)

Note

  • 訳者は JavaScript や Node.js に関する専門知識がほとんどありません。識者のツッコミをお待ちしております。「◯◯が分からない」等も歓迎です。
  • 元記事から構成を一部変更しています。また、関数型プログラミングに関する記述のうち、議論の骨子に絡まないものは省略しています。
@staltz
staltz / introrx.md
Last active November 19, 2024 02:40
The introduction to Reactive Programming you've been missing
@youcune
youcune / fadein.html
Created August 24, 2014 12:23
CSS3 のみで display: none からフェードインさせる
<!DOCTYPE html>
<html>
<head>
<meta charst='utf-8'>
<title>TEST</title>
<script src="//code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>
<style>
.box {
background: #000000;
display: none;
@bcdejp
bcdejp / hcsr04.py
Created December 15, 2014 07:27
超音波距離センサモジュールHC-SR04を制御する
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def reading(sensor):
import time
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
TRIG = 11
@ethanhs
ethanhs / PurepyHook.py
Last active December 13, 2023 02:02
This is a pure python (or as close as possible) keyboard hook module.
# Some of this adapted from BoppreH's answer here:http://stackoverflow.com/questions/9817531/applying-low-level-keyboard-hooks-with-python-and-setwindowshookexa
import ctypes
from ctypes import wintypes
from collections import namedtuple
KeyEvents=namedtuple("KeyEvents",(['event_type', 'key_code',
'scan_code', 'alt_pressed',
'time']))
handlers=[]
@GRGSIBERIA
GRGSIBERIA / mpm.hpp
Last active February 22, 2021 01:55
MPMアルゴリズムの実装です.自己相関関数の周期をささっと求めるためのアルゴリズムです.以下のURLを参考にC++で実装してみました.
/*
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
@tkaczenko
tkaczenko / main.cpp
Last active September 27, 2021 06:49
Чтение .wav файла (С++ / СPP) / Reading .wav file (C++ / CPP)
#include <iostream>
#include <cstdio>
#include <cmath>
#include "string.h"
#include "mem.h"
//Wav Header
struct wav_header_t
{
char chunkID[4]; //"RIFF" = 0x46464952