Skip to content

Instantly share code, notes, and snippets.

@amaya382
amaya382 / Benchmark.scala
Last active July 7, 2016 20:09
Scalaのベンチマーク用スニペット
def timeOf(action: => Unit, noTimes: Int = 10, multiplier: Int = 1): Double = {
import java.util.concurrent.TimeUnit
val runtime = Runtime.getRuntime
val result = (1 to noTimes + 1) map { _ =>
val startTime = System.nanoTime
var i = 0
while (i < multiplier) {
action
i += 1
}
@amaya382
amaya382 / TransposeAndDotUDAF.java
Created September 16, 2016 05:06
[WIP] TransposeAndDotUDAF
package hivemall.tools.matrix;
import hivemall.utils.hadoop.HiveUtils;
import hivemall.utils.hadoop.WritableUtils;
import hivemall.utils.lang.Preconditions;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.parse.SemanticException;
@amaya382
amaya382 / SkeletonUDAF.java
Last active September 21, 2016 04:38
skeleton for GenericUDAF
package somewhere;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.parse.SemanticException;
import org.apache.hadoop.hive.ql.udf.generic.AbstractGenericUDAFResolver;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFParameterInfo;
@amaya382
amaya382 / SkeletonUDF.java
Last active September 21, 2016 04:38
skeleton for GenericUDF
package somewhere;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
#include <vector>
using namespace std;
template<typename T, size_t N>
class aligned_allocator : public allocator<T> {
using size_type = typename allocator<T>::size_type;
using pointer = typename allocator<T>::pointer;
using const_pointer = typename allocator<T>::const_pointer;

Keybase proof

I hereby claim:

  • I am amaya382 on github.
  • I am amaya (https://keybase.io/amaya) on keybase.
  • I have a public key whose fingerprint is 5194 E80C A366 3CE7 B1BD B18B C6D2 C54B 81CB 8C08

To claim this, I am signing this object:

@amaya382
amaya382 / 1-host_prepare_qemu.sh
Last active August 6, 2017 06:12
Easy installation and test of xgboost scripts for hadoop/hive/hivemall on ubuntu16.04/arm64
#!/bin/sh
# http://www.mztn.org/dragon/arm64_01.html
mkdir -p qemu-arm64
cd qemu-arm64
wget http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-arm64-uefi1.img
sudo qemu-img resize xenial-server-cloudimg-arm64-uefi1.img +10G
@amaya382
amaya382 / guidepost.plantuml
Last active October 11, 2017 05:50
scala.collection選択フローチャート(http://plantuml.com/plantuml/uml に投げると見れます)
@startuml
start
if (複数の型) then (Y)
:shapeless.HList;
detach
else (N)
if (順序が重要) then (Y)
if (規則的な値を生成) then (Y)
:immutable.Range;
detach
@amaya382
amaya382 / garbage.scala
Last active December 10, 2017 06:01
(dotty)
object Main {
def main(args: Array[String]): Unit = {
case class =>>[T, U](f: T => Boolean, g: T => U)
implicit class Ex[T](f: T => Boolean) {
def =>>[U](g: T => U): T =>> U = new =>>(f, g)
}
def matchx1[T, U](target: T)(cases: (T =>> U)*): U = {
cases.collectFirst {
case cas if cas.f(target) => cas.g(target)
#!/bin/sh -eu
BRD='10.255.255.255' # for searching interface
enable_wol() {
sudo ethtool -s $1 wol g
sudo sh -c 'cat << EOF > /etc/systemd/system/wol@.service
[Unit]
Description=Wake-on-LAN for %i
Requires=network.target