Skip to content

Instantly share code, notes, and snippets.

View cho45's full-sized avatar

Satoh, Hiroh cho45

View GitHub Profile
class Foo
def to_a
[:to_a, :to_a]
end
def to_ary
[:to_ary, :to_ary]
end
end
//#!g++ -O3 -std=c++14 cpp.cpp -o a.out && ./a.out ; ;:
#include <cstdio>
#include <stdint.h>
#include <type_traits>
template <uint8_t int_bits, uint8_t fractional_bits, class T>
inline float fixed_point_to_float(const T fixed) {
static_assert(std::is_unsigned<T>::value, "argument must be unsigned");
//#!ano build -f="-std=c++11 -Os" && /Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-objdump -d .build_ano/uno/firmware.elf ;:
#include <Arduino.h>
// ARDUINO_MAIN で ifdef されているので外からみえない
constexpr uint8_t PB = 2;
constexpr uint8_t PC = 3;
constexpr uint8_t PD = 4;
// template version of Arduino builtin functions
package com.company;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
public class Main {
public static void main(String[] args) {
new Main().doMain(args);
}
puma: rackup --port 3333 --server puma -b 'run lambda {|env| [ 200, { "Content-Type" => "text/plain" }, [ "puma" ] ] }'
h2o: h2o --conf ./h2o.conf.yaml --mode master
@cho45
cho45 / hoge.js
Last active November 16, 2015 10:35
-1.6 'toFixed' '-2' 'ceil' -1 'floor' -2 'round' -2
-1.5 'toFixed' '-2' 'ceil' -1 'floor' -2 'round' -1
-1.4 'toFixed' '-1' 'ceil' -1 'floor' -2 'round' -1
-1 'toFixed' '-1' 'ceil' -1 'floor' -1 'round' -1
-0.5 'toFixed' '-1' 'ceil' -0 'floor' -1 'round' -0
-0.4 'toFixed' '-0' 'ceil' -0 'floor' -1 'round' -0
0 'toFixed' '0' 'ceil' 0 'floor' 0 'round' 0
0.4 'toFixed' '0' 'ceil' 1 'floor' 0 'round' 0
0.5 'toFixed' '1' 'ceil' 1 'floor' 0 'round' 1
1 'toFixed' '1' 'ceil' 1 'floor' 1 'round' 1
@cho45
cho45 / scala.js
Created October 14, 2015 11:32 — forked from suzak/scala.js
indexer = {
id: 'scala',
name: 'Scala',
icon: 'https://www.zdrojak.cz/wp-content/uploads/2014/07/scala-icon.png',
index: function (ctx) {
return ctx.fetchDocument('http://www.scala-lang.org/api/current/').then(function (document) {
Array.from(document.querySelectorAll('li.pack')).map(function (pack) {
ctx.pushIndex(pack.title, pack.querySelector('a.tplshow').href);
Array.from(pack.querySelector('.templates').querySelectorAll('li')).map(function (it) {
@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();