Skip to content

Instantly share code, notes, and snippets.

@DariusL
DariusL / gist:14b9b54de671f2effefd
Created December 17, 2015 20:03
JUnit4 test class template
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.Test;
import org.mockito.Mock;
import static org.mockito.Mockito.*;
import static org.mockito.Matchers.*;
import org.hamcrest.CoreMatchers;
@DariusL
DariusL / build.gradle
Created December 14, 2015 20:58
A gradle task to upload android build artifacts to dropbox
import groovyx.net.http.ContentType
import groovyx.net.http.RESTClient
task pushDropbox << {
def outName;
if (System.getenv("GITLAB_CI")) {
outName = "app-debug-${System.getenv("CI_BUILD_REF_NAME")}-SNAPSHOT.apk"
} else {
outName = "app-debug.apk"
}
@DariusL
DariusL / gist:1f311acf1fb922fce77a
Last active August 29, 2015 14:14
Bits of android
/**
* remeasures view with the same width and returns it's height, the view has to be laid out before calling this
* @param view the view
* @return measured height
*/
public static int measureViewHeight(View view){
view.measure(
View.MeasureSpec.makeMeasureSpec(view.getWidth(), View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
);
#pragma once
#include "includes.h"
template<typename... Factories>
class LoggerManager;
template<typename... Factories>
class LoggerHelper;
template<typename Factory, typename... Factories>
primitives["bool"] = Bool = new ExternalType(assembly, typeof(bool));
primitives["char"] = Char = new ExternalType(assembly, typeof(char));
primitives["int8"] = Int8 = new ExternalType(assembly, typeof(sbyte));
primitives["uint8"] = UInt8 = new ExternalType(assembly, typeof(byte));
primitives["int16"] = Int16 = new ExternalType(assembly, typeof(short));
primitives["uint16"] = UInt16 = new ExternalType(assembly, typeof(ushort));
primitives["int32"] = primitives["int"] = Int32 = new ExternalType(assembly, typeof(int));
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WhyOhGodWhy
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
@DariusL
DariusL / gist:0b2d9acde176a145d379
Last active September 27, 2020 14:15
Generic observer pattern implementation in c++
#pragma once
#include <list>
#include <unordered_map>
#include <functional>
using namespace std;
template<typename... Args>
class Observers
{
public:
using funcs = list<function<void(Args...)>>;
class ControlFunctionFactory {
def create = new ControlFunction().respond _
}
object Main {
def main(args: Array[String]) {
println(new ControlFunctionFactory().create("React(generation=0,time=100,view=_________________bWWW____WWW___bWWW_____PW____WWW,energy=100)"))
}