Skip to content

Instantly share code, notes, and snippets.

@hattorix
hattorix / memo
Last active June 13, 2023 05:30
AudioWorklet で音量取得
https://g200kg.github.io/web-audio-api-ja/ のを TypeScript 化と少し機能を整理
@hattorix
hattorix / MicToggle.ahk
Last active March 1, 2022 16:50
Toggle default communication device in AutoHotkey
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance force
#include %A_ScriptDir%/VA.ahk
GetDefaultCaptureCommDevice() {
if (r := DllCall("ole32\CoCreateInstance"
, "ptr", VA_GUID(CLSID_MMDeviceEnumerator, "{BCDE0395-E52F-467C-8E3D-C4579291692E}")
@hattorix
hattorix / gist:4509323
Last active December 10, 2015 23:28
node.js で AzureTable のクエリ実行
azure = require 'azure'
process.env['AZURE_STORAGE_ACCOUNT'] = 'xxxx'
process.env['AZURE_STORAGE_ACCESS_KEY'] = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=='
EPOCH = 621355968000000000
# Unix epoch to Ticks
exports.getTicks = (date) ->
(date.getTime() * 10000) + EPOCH
@hattorix
hattorix / gist:4388082
Last active December 10, 2015 05:29
AzureTable のクエリ全行取得
from azure.storage import TableService
def query_all(account_name, account_key, table_name, query):
nextpartitionkey = None
nextrowkey = None
ts = TableService(account_name, account_key)
while True:
rows = ts.query_entities(table_name, query, next_partition_key=nextpartitionkey, next_row_key=nextrowkey)
@hattorix
hattorix / gist:4388057
Last active December 10, 2015 05:28
.NET の DateTime.Ticks と同等の数値を取得する関数
def get_ticks(date):
unix_time = datetime(1, 1, 1)
delta = date - unix_time
return int(delta.total_seconds() * 10000000) + (delta.microseconds * 10)
def ticks_to_date(ticks):
delta = timedelta(microseconds=ticks / 10)
return datetime(1, 1, 1) + delta
@hattorix
hattorix / PKGBUILD
Created September 23, 2012 03:36
kdeutils-ark 日本語対応パッチ
pkgname=kdeutils-ark-ja
pkgver=4.9.1
pkgrel=1
pkgdesc='Archiving Tool'
url='http://kde.org/applications/utilities/ark/'
arch=('i686' 'x86_64')
license=('GPL' 'LGPL' 'FDL')
groups=('kde' 'kdeutils')
depends=('kdebase-runtime' 'kdebase-lib' 'libarchive' 'qjson')
makedepends=('cmake' 'automoc4')
@hattorix
hattorix / gist:2792734
Created May 26, 2012 07:21
rename file to SHA1
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
import sys
import hashlib
import gio
def get_hash_of_sha1(fname):
@hattorix
hattorix / sbt
Created March 8, 2012 11:38
sbt executor
#!/bin/bash
BASEDIR=`dirname $0`
SBT_VERSION=0.11.3
SBT_OPTS=
SBT_ARGS=()
function get-launcher() {
if [[ $# -ne 1 ]]; then
exit 1
# - Find Thrift (a cross platform RPC lib/tool)
# Once done this will define
#
# THRIFT_ROOT - Set this variable to the root installation of Thrift
#
# Variables defined by this module:
#
# Thrift_FOUND - system has the Thrift library
# Thrift_NB_FOUND - system has the Thrift non-blocking library
# Thrift_VERSION - version number of the Thrift libraries that have been found
#include <iostream>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
using namespace std;
using namespace boost::spirit;
namespace phx = boost::phoenix;
struct Test
{