Skip to content

Instantly share code, notes, and snippets.

object Kernel {
implicit class Times(val n: Int) extends AnyVal {
def times[T](block: => T) = for (i <- 1 to n) yield block
def times[T](block: Int => T) = for (i <- 1 to n) yield block(i)
}
implicit class RunnableConversion(block: => Unit) extends Runnable {
def run = block
}
@visualskyrim
visualskyrim / AkkaTest.scala
Last active August 29, 2015 14:02
AkkaTest.scala
package Synapse
import akka.actor._
import scala.concurrent.duration._
import akka.util.Timeout
import akka.pattern.ask
import akka.dispatch._
import scala.concurrent.{Future, Await, ExecutionContext}
import ExecutionContext.Implicits.global
@visualskyrim
visualskyrim / template.html
Created January 21, 2015 11:01
Lopash nvAlt template with fenced code block enabled
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>{%title%}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
@visualskyrim
visualskyrim / nested_json_parse.go
Last active September 23, 2020 13:39
golang - Unmarshal nested Json
package main
import (
"encoding/json"
)
type SomeJsonObj struct {
ID string `json:"id"`
Outter struct {
Mid struct {
Atom Config Sync Gist
@visualskyrim
visualskyrim / .gitconfig
Created December 25, 2015 05:59
Git Log tree
[alias]
lg1 = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(cyan)%s%C(reset) %C(dim black)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg = !"git lg1"
name := "spark-playground"
version := "1.0"
scalaVersion := "2.11.8"
libraryDependencies += "org.apache.spark" %% "spark-core" % "2.1.0"
libraryDependencies += "org.apache.spark" %% "spark-streaming" % "2.1.0"
/**
* Created by visualskyrim on 17/01/20.
*/
import org.apache.kafka.common.serialization.StringDeserializer
import org.apache.spark._
import org.apache.spark.streaming._
import org.apache.spark.streaming.kafka010._
import org.apache.spark.streaming.kafka010.LocationStrategies.PreferConsistent
import org.apache.spark.streaming.kafka010.ConsumerStrategies.Subscribe
# Package generated configuration file
# See the sshd_config(5) manpage for details
# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
$+h::
GetKeyState, state, s, P ; D if CapsLock is ON or U otherwise.
if state = D
{
if isCancelled != 1
{
isCancelled = 1
Send {Shift down}{Left}{Shift up}
} else {