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.
@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
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
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
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
classpath.add(("org.scalaz" , "scalaz-core_2.11" ,"7.2.2"))
@EugeneLoy
EugeneLoy / features.m
Created August 4, 2016 20:11
"ops" feature generation
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)
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
import org.apache.log4j.Logger
import org.apache.log4j.Level
Logger.getLogger("org").setLevel(Level.ERROR)
Logger.getLogger("akka").setLevel(Level.ERROR)
@EugeneLoy
EugeneLoy / cheatsheets
Last active June 11, 2021 13:34
Cheat Sheets
Searching ---------------------------------------------------------------------
Find all files that has full filename pattern "YYY" in this rdirectory, recursive:
find . -wholename "YYY"
Find all matches of regexp "XXX" in file YYY:
grep -n -E "XXX" YYY
Find all occurences of "XXX" in all files with name "YYY" in this directory, recursive:
find . -name "YYY" -print0 | xargs -0 grep -n -F "XXX"
@EugeneLoy
EugeneLoy / .bashrc
Created August 22, 2017 10:37
git config
export PS1='\[\033[01;37m\]\u@\h\[\033[01;32m\] \w $(__git_ps1 "\n[%s]")
\$\[\033[00m\] '