Skip to content

Instantly share code, notes, and snippets.

View potix2's full-sized avatar
:octocat:

Katsunori Kanda potix2

:octocat:
View GitHub Profile
@potix2
potix2 / TLP.scala
Created July 27, 2014 13:18
type-level-programming-in-scala
package com.potix2.tlp
import Bool._
import Nat._
//http://apocalisp.wordpress.com/2010/06/08/type-level-programming-in-scala/
sealed trait Bool {
type If[T <: Up, F <: Up, Up] <: Up
}
#!/bin/bash
# ssh-multi
# D.Kovalov
# Based on http://linuxpixies.blogspot.jp/2011/06/tmux-copy-mode-and-how-to-control.html
# a script to ssh multiple servers over multiple tmux panes
starttmux() {
if [ -z "$HOSTS" ]; then
@potix2
potix2 / gist:1df815621d76e7ad3c70
Created April 16, 2015 10:18
GCJ2015-C-Small
package gcj2015;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class C {
@potix2
potix2 / gist:5e54e07e217b9feb3ab6
Created April 16, 2015 10:30
GCJ2015-D-small
package gcj2015;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class D {
import org.apache.spark.sql.SQLContext
def etl(sqlContext: SQLContext, source: String, destination: String): Unit = {
val df = sqlContext.read.format("com.databricks.spark.csv").option("header", "true").load(source)
df.select("year", "model").write.format("com.databricks.spark.csv").save(destination)
}
// etl(new SQLContext(sc), "cars.csv", "newcars.csv")
val testContext = TestSQLContext()
class ConcatDFSpec extends org.specs2.mutable.Specification {
def concat(df: DataFrame, inputColName: String, concatColName: String, outputColName: String, dataType: DataType): DataFrame =
df.withColumn(outputColName, callUDF(_ ++ _, dataType, df(inputColName), df(concatColName)))
// val paramMap: ParamMap
// val inputCol: Param[String]
// val outputCol: Param[String]
// val concatCol: Param[String]
// concat(df, paramMap(inputCol), paramMap(outputCol), paramMap(concatCol), dataType)
type A = Map[String, Int]
@potix2
potix2 / gist:1126865
Created August 5, 2011 03:32
screenrc
vbell off
autodetach on
startup_message off
defscrollback 1000
term xterm-256color
escape ^La
defbce on
hardstatus alwayslastline "[%02c] %`%-w%{=b bw}%n %t%{-}%+w"
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
export PATH="/usr/local/bin:$PATH"
#export PS1='\033k\033\\[\u@\h \W]\$ '
@potix2
potix2 / .zshrc
Created August 19, 2011 02:17
zshrc
autoload colors
colors
setopt auto_pushd
setopt noautoremoveslash
bindkey -e
autoload -U compinit
compinit
PROMPT='%39<...<%/%% '
PROMPT2="%_%% "
SPROMPT="%r is correct? [n,y,a,e]: "
@potix2
potix2 / gist:1218324
Created September 15, 2011 01:50
HSV to RGB
public function toRGB(h:Number, s:Number, v:Number):uint {
var hi:Number = Math.floor(h / 60) % 6;
var f:Number = h / 60 - hi;
var p:Number = v * ( 1.0 - s);
var q:Number = v * ( 1.0 - f * s);
var t:Number = v * ( 1.0 - (1.0 - f) * s);
var r:Number;
var g:Number;
var b:Number;
switch(hi) {