Skip to content

Instantly share code, notes, and snippets.

@dmcg
dmcg / Examples.scala
Created June 10, 2011 14:22
GivenWhenThenFeatureSpec
class LoginFeature extends GivenWhenThenFeatureSpec with ShouldMatchers with OneInstancePerTest {
feature("Admin Login") {
scenario("Incorrect password") {
// You can provide the code for a step in a block
given("user visits", the[AdminHomePage]) {
startPage(pageClass)
}
@mumoshu
mumoshu / various-accumulation-examples.scala
Created December 10, 2011 05:54
Various accumulation examples in Scala
/** まず、import, case class, val nodeseqのところまで
* REPLの:pasteコマンドでコピペして、各Exampleも同様にコピペして実行してみてね!
*
* Use :paste command in Scala REPL to run example code.
*/
import xml._
case class ColorPair(foregroundOption: Option[String], backgroundOption: Option[String])
TitanKey happiness = g.makeType().name("happiness").dataType(Integer.class).eidetic(true).makePropertyKey();
TitanVertex v = g.addVertex()
v.setProperty("name","Zack")
v.setProperty("happiness",2)
v.getProperty("happiness")
//TimeSeries([[2,1000]])
v.setProperty("happiness",10)
v.getProperty("happiness")
//TimeSeries([[2,1000],[10,1001]])
v.getProperty("happiness").now()
@radimklaska
radimklaska / gist:3963664
Last active December 15, 2015 18:33
Easy git stats in one command
git log --author="Radim Klaska" --pretty=tformat: --numstat | gawk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "added lines: %s removed lines: %s total lines: %s\n",add,subs,loc }' -
# returns: "added lines: XXX removed lines: XXX total lines: XXX"
git log --shortstat --pretty="%cE" | sed 's/\(.*\)@.*/\1/' | grep -v "^$" | awk 'BEGIN { line=""; } !/^ / { if (line=="" || !match(line, $0)) {line = $0 "," line }} /^ / { print line " # " $0; line=""}' | sort | sed -E 's/# //;s/ files? changed,//;s/([0-9]+) ([0-9]+ deletion)/\1 0 insertions\(+\), \2/;s/\(\+\)$/\(\+\), 0 deletions\(-\)/;s/insertions?\(\+\), //;s/ deletions?\(-\)//' | awk 'BEGIN {name=""; files=0; insertions=0; deletions=0;} {if ($1 != name && name != "") { print name ": " files " files changed, " insertions " insertions(+), " deletions " deletions(-), " insertions-deletions " net"; files=0; insertions=0; deletions=0; name=$1; } name=$1; files+=$2; insertions+=$3; deletions+=$4} END {print name ": " files " files changed, " insertio
@b0c1
b0c1 / OrientDbTest.scala
Last active December 17, 2015 06:19
Orient DB 1.3 vs scala 2.10
package hu.javaportal.test
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.{BeforeAndAfter, FunSuite}
import org.scalatest.mock.MockitoSugar
import com.orientechnologies.orient.`object`.db.{OObjectDatabasePool, OObjectDatabaseTx}
import com.orientechnologies.orient.core.tx.OTransaction.TXTYPE
import javax.persistence.{Version, Id}
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery
@mheffner
mheffner / README.md
Created October 3, 2012 18:11
Upload Travis CI builds to S3

Upload Travis CI builds to S3

This will demonstrate how to upload build files from Travis CI to S3.

NOTE: Keys have been changed to protect the innocent.

Step 1: Create an S3 policy.

Create an S3 ACL policy, see s3_policy.json for an example.

@herry13
herry13 / japronto_vs_tornado-static_file.md
Last active March 1, 2018 03:52
Japronto vs Tornado performances on static file
  • Python, version 3.6.2, macOS 10.12.6 (from Brew)

  • MacBook Pro 2016, Intel i5 3.1GHz, mem 16GB

  • Content of main.html

    <html>
      <body>
        <h1>Hello World!</h1>
@rweald
rweald / build.sbt
Created March 24, 2012 18:22 — forked from mumoshu/build.sbt
DES and AES encryption in Scala
name := "DES and AES encryption in Scala"
version := "1.0"
scalaVersion := "2.9.1"
libraryDependencies += "commons-codec" % "commons-codec" % "1.6"
@creaktive
creaktive / cpux86.js
Created May 18, 2011 13:07
Javascript PC Emulator by Fabrice Bellard
/*
PC Emulator
Copyright (c) 2011 Fabrice Bellard
Redistribution or commercial use is prohibited without the author's
permission.
*/
"use strict";
var aa;
@thearn
thearn / capture.py
Created June 15, 2013 21:31
Screen capture using python PIL
import time
import Image
import ImageGrab
while True:
time.sleep(0.5)
t = str(time.time()).replace('.','-')
tt = time.time()
img=ImageGrab.grab()
img = img.resize((800,600))