Skip to content

Instantly share code, notes, and snippets.

@tatat
tatat / convert_uint16_to_float32.js
Created December 1, 2012 12:14
Uint16で扱ってるサウンドデータをFloat32に変換
var convert_uint16_to_float32 = function(data_view, little_endian) {
var byte_length = data_view.byteLength
, result = new DataView(new ArrayBuffer(byte_length * 2))
, converter = new DataView(new ArrayBuffer(2));
little_endian = !! little_endian;
for (var i = 0, uint16, int16; i < byte_length; i += 2) {
uint16 = data_view.getUint16(i, little_endian);
converter.setInt16(0, (uint16 + 0x8000) * 0xFFFF);
import * as AWS from 'aws-sdk'
export const fetch = async (startKey?: AWS.DynamoDB.Key | undefined) => {
const ddb = new AWS.DynamoDB({
endpoint: 'http://localhost:8000'
})
const limit = 6
const defaultInput: AWS.DynamoDB.ScanInput = {
type VDate = Date
type VDateContext = {
current: (actualBase?: Date) => VDate;
toVirtual: (date: Date) => VDate;
toActual: (date: VDate) => Date;
mapToVirtual: (date: Date, actualBase?: Date) => VDate;
}
const createContext = (factor: number, _virtualBase?: Date): VDateContext => {
#!/bin/bash
_puts() {
echo "$1" >&2
}
# NOTE: https://docs.aws.amazon.com/ja_jp/systems-manager/latest/userguide/getting-started-configure-preferences-cli.html
ssm_configuration="$(
cat <<EOS | sed "s/__SESSION_LOGS_BUCKET__/$SESSION_LOGS_BUCKET/g"
{
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Notification for SSM Session Manager
Globals:
Function:
Timeout: 60
Parameters:
#!/bin/sh
if [[ "$1" != "up" ]]; then
exit 1
fi
typing () {
text="$1"
length=${#text}
function isValid() {
return (
isSpecifiedUser() ||
(
request.resource.data.privateKey1 == resource.data.privateKey1 &&
request.resource.data.privateKey2 == resource.data.privateKey2 &&
'publicKey' in request.resource.data
)
) && (
request.resource.data.keys().hasOnly(['privateKey1', 'privateKey2' 'publicKey'])
@tatat
tatat / kouiukannji.rb
Created November 29, 2012 06:44
こういうかんじしたくて
class NyanController < ApplicationController
def index
where = {
:type1 => 1,
:type2 => 1
}
if params[:nyan1].is_a?(String) && /^(?:1|true|TRUE|True|T|t|yes|YES|Yes|Y|y)$/ =~ params[:nyan1]
where[:type1] = 2
else
require "digest/md5"
d = Digest::MD5.hexdigest("nyan" + Time.now.strftime("%Y%m%d")).to_i(16);
shindan = []
10.times {|n| shindan[n] = []; 99.times {|nn| shindan[n] << nn.to_s } }
result = []
@tatat
tatat / sampler.swift
Created February 12, 2019 03:30
Some notes don't play a sound.
import Foundation
import AVFoundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
// NOTE: ~/Documents/Shared Playground Data/GeneralUser GS v1.471.sf2
// http://schristiancollins.com/generaluser.php
let url = PlaygroundSupport.playgroundSharedDataDirectory.appendingPathComponent("GeneralUser GS v1.471.sf2")