Skip to content

Instantly share code, notes, and snippets.

@hikoma
hikoma / 3 Concurrent Objects.md
Created August 9, 2012 14:59
3 Concurrent Objects

3 Concurrent Objects (並行オブジェクト)

この章では並行オブジェクトの correctness と progress を規定する様々な方法を学ぶ。

correctness の3つタイプ

  • Quiescent consistency
    • 弱い制約。ハイパフォーマンスを必要とするシステムに使える
  • Sequential consistency
@hikoma
hikoma / kobo.bat
Created July 25, 2012 16:58
Converts pdf to cbz using ChainLP.exe
@set CHAINLP_DIR=C:\ChainLP40b12
@set CHAINLP=%CHAINLP_DIR%\ChainLP.exe
@set SETTING=%CHAINLP_DIR%\%~n0.ini
@set OUTPUT_DIR=%~dp0
@for %%f in (%*) do "%CHAINLP%" -b -ini "%SETTING%" -i %%f -o "%OUTPUT_DIR%\%%~nf.cbz"
@hikoma
hikoma / CpuMonitor.java
Created May 20, 2012 14:42
Prints java stack traces of java threads eating the CPU
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
@hikoma
hikoma / linear_hashing.sql
Created May 14, 2012 02:42
A hash function controls the address calculation of linear hashing.
-- http://dev.mysql.com/doc/refman/5.5/en/partitioning-linear-hash.html
DELIMITER $$
DROP FUNCTION IF EXISTS linearHashing$$
CREATE FUNCTION linearHashing(value INT, num INT) RETURNS INT DETERMINISTIC
BEGIN
SET @v := POWER(2, CEILING(LOG(2, num)));
SET @n := value & (@v - 1);
IF @n >= num THEN
SET @v := CEILING(@v / 2);
SET @n := @n & (@v - 1);
@hikoma
hikoma / random_data.sql
Created April 26, 2012 07:05
Create tables containing random int values
DROP TABLE IF EXISTS t;
CREATE TABLE t (
id INT NOT NULL AUTO_INCREMENT,
x INT NOT NULL,
y INT NOT NULL,
z INT NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
DELIMITER $$
@hikoma
hikoma / java-cpu-monitor.sh
Created March 7, 2012 14:52
Prints java stack traces of java threads eating the CPU
#!/bin/bash
threshold=${1-95}
now=$(date '+%Y-%m-%d %H:%M:%S')
cache=()
jps -q | xargs ps hH k -pcpu o pid,lwp,pcpu,args \
| awk "\$3 >= $threshold" | while read line; do
array=($(echo "$line"))