This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget -r -k -np --user-agent="Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53" http://examle.com/xxxx/yyyy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def test-data "'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value ") | |
(->> (re-seq #"\w+" test-data) | |
(map #(.toLowerCase %)) | |
(group-by identity) | |
(map (fn [[k v]] [k (count v)]))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Memoize1[-T, +R](f: T => R) extends (T => R) { | |
private[this] val memorized = scala.collection.mutable.Map.empty[T, R] | |
def apply(x: T):R = { | |
memorized.getOrElseUpdate(x, f(x)) | |
} | |
} | |
object Memoize1 { | |
def apply[T, R](f: T => R) = new Memoize1(f) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.NoSuchElementException | |
/** | |
* | |
* | |
*/ | |
abstract class Term | |
case class TmVar(info:Object, x:Int, n:Int) extends Term |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* | |
*/ | |
abstract class Term | |
case class TmTrue(info: Object) extends Term | |
case class TmFalse(info: Object) extends Term | |
case class TmIf(info: Object, t1:Term, t2:Term, t3:Term) extends Term | |
case class TmZero(info: Object) extends Term | |
case class TmSucc(info: Object, t:Term) extends Term |