Skip to content

Instantly share code, notes, and snippets.

View brescia123's full-sized avatar

Giacomo Bresciani brescia123

View GitHub Profile
@brescia123
brescia123 / aggr_collector.py
Last active August 29, 2015 14:17
A script for collecting data aggregates from multiple simulations run with aDock - affear.github.io/adock
from firebase import firebase
import json
bifrost = firebase.FirebaseApplication('https://bifrost.firebaseio.com/', None)
sims = bifrost.get('/sims', None)
avgs = {}
for sim in sims:
@brescia123
brescia123 / send_file_nc.sh
Created September 29, 2015 08:16
Commands to send a file with Netcat
# Listening
nc -l -p 1234 > out.file
# Sending
nc -w 3 [destination] 1234 < out.file
@brescia123
brescia123 / latex_commands.tex
Created September 29, 2015 08:21
Useful commands for Latex
\definecolor{light-gray}{gray}{0.95}
\definecolor{yellow}{RGB}{255, 251, 140}
% single line code blocks with monospace font and light-gray background (StackOverflow style)
\newcommand{\code}[1]{\colorbox{light-gray}{\texttt{#1}}}
% note command
\newcommand{\todo}[1]{\colorbox{yellow}{\textbf{\#TODO} #1}}
@brescia123
brescia123 / sign_apk.gradle
Last active October 27, 2015 13:41
Configuration to generate a signed apk from the command line
signingConfigs {
releaseSigning {
storeFile file(System.getenv("ANDROID_KEYSTORE"))
storePassword System.console().readPassword("\nStore password: ").toString()
keyAlias System.getenv("ANDROID_KEYALIAS")
keyPassword System.console().readPassword("Key password: ").toString()
}
}
buildTypes {
Atom settings sync
@brescia123
brescia123 / CustomMockitoArgumentMatcher.java
Last active June 15, 2020 21:59
Two custom ArgumentMatcher used to match Lists that contain elements without equals(). They use Mockito's ReflectionEquals to check elements equality.
/**
* Custom matcher that checks if a list is equal to expected when elements don't have equals()
* using {@link ReflectionEquals}.
*/
public static ArgumentMatcher<List> equalsList(List expectedList) {
return new ArgumentMatcher<List>() {
@Override
public boolean matches(Object argument) {
List list = (List) argument;
boolean assertion;
/* --- Log functions with Tag as caller class name --- */
inline fun <reified T: Any> T.logD(text: String) {
Log.d(T::class.java.simpleName, text)
}
inline fun <reified T: Any> T.logE(text: String) {
Log.e(T::class.java.simpleName, text)
}
@brescia123
brescia123 / TextView.xml
Created October 10, 2016 14:09
Layout properties needed to make TextView Ellipsize work
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"/>
@brescia123
brescia123 / MVP.kt
Last active March 4, 2019 16:50
Main components for lifecycle-aware presenters
import java.lang.ref.WeakReference
/**
* Base Interface for all the presenters.
*
* @param T The type of view (which extends [View]) the presenter is controlling.
*/
interface PresenterApi<in T : View> {
fun onAttach(v: T)
fun onDetach()
import io.reactivex.Observable
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable
import io.reactivex.observers.DisposableObserver
import io.reactivex.subjects.BehaviorSubject
import io.reactivex.subjects.PublishSubject
interface ViewState