Skip to content

Instantly share code, notes, and snippets.

@EugeneLoy
EugeneLoy / Log test names (JUnit, SLF4J)
Last active August 29, 2015 14:02
Add this field to your test class to log names of the tests when they start. Works with JUnit 4.9+ and SLF4J.
View Log test names (JUnit, SLF4J)
@Rule
public TestRule loggingRule = new TestWatcher() {
protected void starting(Description description) {
Logger logger = LoggerFactory.getLogger(description.getClassName());
logger.info("Starting: {}", description.getMethodName());
}
};
@EugeneLoy
EugeneLoy / Call private methods on Scala and Java objects
Last active August 29, 2015 14:07
Helper that allows to call private methods on Scala/Java objects
View Call private methods on Scala and Java objects
package object utils {
/**
* Helper that allows to call private methods on Scala/Java objects.
*
* Usage: `someObject.exposeMethod('methodName)(arg1, arg2, arg3)`
*
* See: https://gist.github.com/EugenyLoy/5873642543f869c7e25f
*/
implicit class ExposePrivateMethods(obj: AnyRef) {
@EugeneLoy
EugeneLoy / gist:76727e5cec6943f5dd73
Created March 24, 2015 16:50
Save GET to file with datetime as a name
View gist:76727e5cec6943f5dd73
curl -i https://api.github.com/repos/EugenyLoy/awesome-github > `date -u '+%F'_%H_%M`.txt
@EugeneLoy
EugeneLoy / IO.hs
Last active August 29, 2015 14:24
todo
View IO.hs
module IO where
import System.IO
import Control.Exception
import Control.DeepSeq
import Control.Monad.Trans.Either
import Control.Monad.Trans.Class
import Data.Either.Combinators
import System.Environment
@EugeneLoy
EugeneLoy / gist:f4efbef43a6764a7f9469a2b670cc128
Created April 17, 2016 18:34
adding scalaz dependency to jupyter-scala
View gist:f4efbef43a6764a7f9469a2b670cc128
classpath.add(("org.scalaz" , "scalaz-core_2.11" ,"7.2.2"))
@EugeneLoy
EugeneLoy / features.m
Created August 4, 2016 20:11
"ops" feature generation
View features.m
clear ; close all; clc
% helpers used later ---
function [result] = measureError(X, y, theta)
result = linearRegCostFunction(X, y, theta, 0);
endfunction
@EugeneLoy
EugeneLoy / axline.py
Last active November 15, 2016 19:38
pyplot: draw a line through 1 or 2 reference points (works with scrolling)
View axline.py
import matplotlib.pyplot as plt
def axline(xdata, ydata, ax = plt.subplot(111), *args, **kwargs):
try:
x1 = xdata[0]
y1 = ydata[0]
except:
# assume first point coordinates given as numbers
x1 = float(xdata)
@EugeneLoy
EugeneLoy / main.scala
Created March 16, 2017 19:15
Silence Spark logging
View main.scala
import org.apache.log4j.Logger
import org.apache.log4j.Level
Logger.getLogger("org").setLevel(Level.ERROR)
Logger.getLogger("akka").setLevel(Level.ERROR)
@EugeneLoy
EugeneLoy / .bashrc
Created August 22, 2017 10:37
git config
View .bashrc
export PS1='\[\033[01;37m\]\u@\h\[\033[01;32m\] \w $(__git_ps1 "\n[%s]")
\$\[\033[00m\] '
@EugeneLoy
EugeneLoy / export.py
Created January 19, 2018 16:42
Export cards from specific list in Trello (json) to csv
View export.py
import json
import csv
LIST_NAME = "Backlog"
INPUT_FILE = "data.json"
OUTPUT_FILE = 'data.csv'
with open(INPUT_FILE) as jsonfile:
data = json.load(jsonfile)