Skip to content

Instantly share code, notes, and snippets.

View cho45's full-sized avatar

Satoh, Hiroh cho45

View GitHub Profile
@cho45
cho45 / localhost
Last active September 29, 2015 05:39
launch local http/https static server
#!/bin/sh
# brew install h2o
# clone h2o
# cmake .
# make install
H2OCONF=`mktemp -t h2o.conf`
CRT=`mktemp -t server.crt`
@cho45
cho45 / Main.java
Last active September 28, 2015 01:42
Check TypedArray Endianness on Nashorn (JavaScript engine on JVM)
package net.lowreal;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
public class Main {
public static void main(String[] args) throws ScriptException {
final ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
var DTMF = function () { this.init.apply(this, arguments) };
DTMF.prototype = {
table : {
"1" : [697, 1209], "2" : [697, 1336], "3" : [697, 1477], "A" : [697, 1633],
"4" : [770, 1209], "5" : [770, 1336], "6" : [770, 1477], "B" : [770, 1633],
"7" : [852, 1209], "8" : [852, 1336], "9" : [852, 1477], "C" : [852, 1633],
"*" : [941, 1209], "0" : [941, 1336], "#" : [941, 1477], "D" : [941, 1633]
},
init : function (context, opts) {
#!/usr/bin/xcrun swift
import Cocoa
struct ProgramOption {
var list : Bool = false
var set : String? = nil
var help : Bool = false
}
#!ruby
require 'serialport'
@port = SerialPort.new(
"/dev/tty.usbserial-A402PY11",
38400,
8,
1,
0
@cho45
cho45 / keyscreen.rb
Last active August 29, 2015 14:05
一度起動したあと、「システム環境設定」→「セキュリティとプライバシー」→「アクセシビリティ」で macruby を許可する必要あり
#!macruby
framework "Cocoa"
class MainView < NSView
def init
super
@log = ""
end
if (foo) {
...;
} else
if (bar) {
...;
} else
if (baz) {
...;
} else {
...;
function formatN (n) {
const unitList = ['y', 'z', 'a', 'f', 'p', 'n', 'u', 'm', '', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
const zeroIndex = 8;
const nn = n.toExponential(2).split(/e/);
let u = Math.floor(+nn[1] / 3) + zeroIndex;
if (u > unitList.length - 1) {
u = unitList.length - 1;
} else
if (u < 0) {
u = 0;
use Mouse::Meta::Class;
use JSON::XS;
sub TO_JSON {
my ($self) = @_;
my $klass = +Mouse::Meta::Class->initialize(ref $self);
+{
map {
my $key = $_;
my $val = $self->{$key};
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin qw($Bin);
use lib "$Bin/../lib";
use Teng::Schema::Dumper;
use String::Random qw(random_regex);
use Path::Class;;
my $file = shift or die "require sql file";