Skip to content

Instantly share code, notes, and snippets.

@naoki-sawada
naoki-sawada / client.js
Last active February 21, 2025 09:39
Simple socket.io room and auth example
const io = require('socket.io-client');
const socket = io('http://localhost:3000', {
transportOptions: {
polling: {
extraHeaders: {
'Authorization': 'Bearer abc',
},
},
},
@drart
drart / index.js
Last active March 13, 2024 05:30
MIDI to OSC bridge using Node.js
var midi = require('midi');
var input = new midi.input();
console.log(input.getPortCount());
console.log(input.getPortName(1));
//
input.openPort(0);
input.ignoreTypes(false, false, false);
//
input.on('message', function(deltaTime, message) {
midiMessageReceived(message);
@jgdev
jgdev / index.html
Last active June 1, 2022 19:04
Get percentage of image loading.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Get percentage loaded from image</title>
<script type="text/javascript">
Image.prototype.onChangeSize;
Image.prototype.load = function(url){
var _this = this,
req = ((XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"));
@jaywilliams
jaywilliams / csv_to_array.php
Created April 30, 2010 23:18
Convert a comma separated file into an associated array.
<?php
/**
* Convert a comma separated file into an associated array.
* The first row should contain the array keys.
*
* Example:
*
* @param string $filename Path to the CSV file
* @param string $delimiter The separator used in the file
* @return array