Skip to content

Instantly share code, notes, and snippets.

@hiroaki
hiroaki / jquery-promise-problem.html
Created December 19, 2016 16:51
Promise - Error handling
<html><head><title>Promise - Error handling</title>
<script>
(function() {
var timeout, prepare, jquery_src;
prepare = function() {
jquery_src = {
'2': 'https://code.jquery.com/jquery-2.2.4.min.js',
'3': 'https://code.jquery.com/jquery-3.1.1.min.js'
}[location.search.substr(1, 1)];
@hiroaki
hiroaki / untitled.html
Last active December 18, 2016 05:31
invoke callbacks that contain async confirmation
<html><head><title>Promise</title>
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script>
$(function() {
$('#start').show();
$('#prepare').hide();
$('#dialog').hide();
$('#contents').hide();
$('#goal').hide();
@hiroaki
hiroaki / install-ffmpeg-centos5.sh
Created April 20, 2016 16:31
Install ffmpeg on CentOS 5 automatically
#!/bin/sh
set -eu
# @(#)Install ffmpeg on CentOS 5
#
# Before execute this script, you have to install dependent packages:
# (There may be excess or deficiency)
#
# yum install zlib-devel bzip2 bzip2-devel sqlite sqlite-devel \
@hiroaki
hiroaki / install-ruby-2.3.0.sh
Last active March 18, 2016 18:23
Install ruby-2.3.0 on OS X (El Capitan)
#!/bin/sh
set -eu
WORKDIR=/path/to/build_dir
PREFIX=/path/to/install_dir
backdir=`pwd`
mkdir -p $WORKDIR
cd $WORKDIR
@hiroaki
hiroaki / AtomicParsley.cpp.patch
Created July 27, 2013 15:44
This is a patch for AtomicParsley (v0.9.0). Because there is a problem when building on GCC 4.4, such as "error: invalid conversion from 'const char*' to 'char*'".
--- AtomicParsley.cpp.orig 2006-09-16 08:22:33.000000000 +0900
+++ AtomicParsley.cpp 2013-07-27 17:18:30.279141101 +0900
@@ -1447,7 +1447,7 @@
uint32_t atom_offsets = 0;
char* uuid_outfile = (char*)calloc(1, sizeof(char)*MAXPATHLEN+1); //malloc a new string because it may be a cli arg for a specific output path
if (output_path == NULL) {
- char* orig_suffix = strrchr(originating_file, '.');
+ const char* orig_suffix = strrchr(originating_file, '.');
if (orig_suffix == NULL) {
fprintf(stdout, "AP warning: a file extension for the input file was not found.\n\tGlobbing onto original filename...\n");
@hiroaki
hiroaki / beanstalk_client.pl
Last active December 16, 2015 11:49
(prototype) asynchronous client of beanstalk that performs as producer or multi process worker daemon.
#!/usr/bin/env perl
use 5.12.0;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../lib";
use AnyEvent::Beanstalk;
use Data::Dumper;
use MyApp::App::Command;
@hiroaki
hiroaki / flatten-multipart.pl
Created March 4, 2013 14:18
Each MIME part which may be nested will be arranged in an array.
=head1 NAME
flatten-multipart.pl - flatten multipart message
=head1 SYNOPSIS
$ perl flatten-multipart.pl email.eml
multipart/mixed (2)
multipart/related (2)
application/octetstream (142019)
@hiroaki
hiroaki / gist:ad55b38be8701f25eb93
Last active October 28, 2015 02:42
Real-time monitor (Server-Sent Events)
#!/usr/bin/env ruby
require 'sinatra/base'
SECONDS_INTERVAL = 1.0
URL_STREAM = '/stream'
NAME_EVENT = 'ldavg'
NUMBER_MAX_PLOT = 180
SEPARATOR_OF_DATA = ' '
@hiroaki
hiroaki / viewer.html
Created May 21, 2012 16:51
Overlay GPX on the Google Maps
<!DOCTYPE html>
<html><head><title>GPX Casual Viewer v3</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-script-type" content="text/javascript" />
<meta http-equiv="content-style-type" content="text/css" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0px; padding: 0px }
#map_canvas { height: 100% }
@hiroaki
hiroaki / plist2gpx.pl
Created February 27, 2012 14:46
This converts plist which was printed out by KingGPS into GPX
#!/usr/bin/env perl
use 5.12.0;
use warnings;
use Geo::Gpx;
use Getopt::Std;
use Mac::PropertyList;
#-- setting
my $options = {};