Skip to content

Instantly share code, notes, and snippets.

View chemikadze's full-sized avatar

Nikolay Sokolov chemikadze

  • Google
  • Fremont, CA
View GitHub Profile
demo: lib420.so
LD_PRELOAD=./lib420.so ls -l
.PHONY: demo
lib420.so: lib420.c
gcc -shared -o lib420.so lib420.c
clean:
rm lib420.so
@chemikadze
chemikadze / code.py
Last active April 9, 2017 02:09
Strava ride clustering
from pyspark.mllib.clustering import KMeans, KMeansModel
from pyspark.mllib.linalg.Vectors
from numpy import isnan
from IPython.lib.pretty import pprint
# hypotesis: mtb offroad normal, mtb road normal, mtb flat intervals, mtb hill intervals, road normal
def do_clustering(sc, sqlCtx):
ss = sqlCtx.sparkSession
activities = ss.read.json("gs://chemikadze/strava-analysis/activities_full.json")
train_data = activities.rdd \
scala> case class Scalar(s: String)
scala> case class Sequence(s: Seq[String])
scala> object ScalarMatcher { def unapply(x: Scalar) = Some(x.s) }
scala> object SequenceMatcher { def unapply(x: Sequence) = Some(x.s) }
scala> Scalar("x").s match { case ScalarMatcher(x) => x ; case _ => "because fuck you" }
<console>:11: error: scrutinee is incompatible with pattern type;
found : Scalar
required: String
Scalar("x").s match { case ScalarMatcher(x) => x ; case _ => "because fuck you" }
- get-properties:
action: getEnvironmentProperties
output:
props: result
- compute-properties:
action: serialize
precedingPhases: [get-properties]
parameters:
format: JSON
@chemikadze
chemikadze / constants-example.yml
Last active August 29, 2015 14:06
Example of usage constants service to provide
# launch and add to env
application:
interfaces:
values:
subnet: bind(const#network.subnet)
prefixLength: bind(const#network.prefixLength)
configuration:
values: bind(const#configuration.values)
configuration:
configuration.values:
application:
configuration:
input.image: "us-east-1/ami-aede32c6"
input.image-user: "Administrator"
input.instance-size: "m1.medium"
input.password: "123QweAsd"
input.recipe-url: "https://dl.dropboxusercontent.com/u/250836/jenkins.tar.gz"
input.jenkin-server-url: "http://23.20.248.221:8080/"
input.quantity: "1"
launch:
steps:
provision-do:
action: provisionVms
parameters:
jcloudsNodeNamePrefix: test
roleName: cloud
imageId: us-east-1/ami-f666929e
hardwareId: m1.medium
vmIdentity: Administrator
function setup_mcollective() {
CFGNAME=$1
HOST=$2
PORT=$3
USER=$4
PASSWORD=$5
cp /etc/mcollective/$CFGNAME.cfg /etc/mcollective/$CFGNAME.cfg.orig
sed -re 's/connector = .*/connector = rabbitmq/' < /etc/mcollective/$CFGNAME.cfg.orig > /etc/mcollective/$CFGNAME.cfg
cat >> /etc/mcollective/$CFGNAME.cfg <<EOF
direct_addressing = 1 # ???
@chemikadze
chemikadze / Parent$$anon$1.class
Created March 18, 2014 16:54
Anonymous class gotchas!
Compiled from "anon-class.scala"
public final class Parent$$anon$1 implements IChild {
private java.lang.Object notReferenced; # notReferenced field is not prefixed
private java.lang.Object Parent$$anon$$referenced; # referenced field is prefixed
private java.lang.Object notReferenced(); # notReferenced field is private
private void notReferenced_$eq(java.lang.Object);
public java.lang.Object Parent$$anon$$referenced(); # referenced field is public
private void Parent$$anon$$referenced_$eq(java.lang.Object);
private scala.Function0<java.lang.Object> lambda();
public Parent$$anon$1(Parent);
import org.scalameter.api._
import scala.util.Random
import scala.collection.mutable
import scala.collection.mutable.Builder
object MirrorBenchmark extends PerformanceTest.Quickbenchmark {
val sizes = Gen.range("size")(100, 500, 100)
val maps = for (sz <- sizes) yield {
val r = (0 until sz)
val random = new Random()