Skip to content

Instantly share code, notes, and snippets.

View westonal's full-sized avatar

Alan Evans westonal

View GitHub Profile
@westonal
westonal / rtl8192cu.sh
Last active August 20, 2017 10:10
Wifi of rtl8192cu chipset devices has bad drivers by default - instructions of https://github.com/pvaret/rtl8192cu-fixes.git in script
#!/bin/bash
#stop script on first error
set -e
#Pre-requisits
sudo apt-get update
sudo apt-get -y install git build-essential dkms #linux-headers-generic
#Clone this repository:
import io.reactivex.plugins.RxJavaPlugins
import io.reactivex.schedulers.TestScheduler
import io.reactivex.subjects.BehaviorSubject
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Test
import java.util.concurrent.TimeUnit
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
@westonal
westonal / decorate.kt
Created August 18, 2017 16:28
Decorator pattern for Kotlin ReadWriteProperties
private fun <ThisRef, Value> ReadWriteProperty<ThisRef, Value>.decorate(): ReadWriteProperty<ThisRef, Value?> {
return DecoratorExample(this)
}
class DecoratorExample<in ThisRef, Value>(val decorated: ReadWriteProperty<ThisRef, Value>) : ReadWriteProperty<ThisRef,
Value?> {
override fun getValue(t: ThisRef, property: KProperty<*>): Value {
return decorated.getValue(t, property)
}
class SomeThing {
final Dependency1 dependency1;
Dependency2 dependency2;
Something(Dependency1 dependency1){
this.dependency1 = dependency1;
}
void setDependency2(Dependency2 dependency2){
this.dependency2 = dependency2;
data class ClipAPI(var id: String?,
var type: String?,
var url: String?,
var mgid: String?,
var title: String?,
var format: String?,
var description: String?,
var duration: DurationAPI?,
var images: List<ImageAPI>?,
var season: SeasonAPI?,
package com.redspace.NamedMonads
import org.junit.Assert.assertEquals
import org.junit.runner.RunWith
@RunWith(SpecRunner::class)
class CalculatorTestsUsingRunner {
val givenCalculator = "calculator" sut given {
Calculator()
import com.redspace.fullbowlingkata.BowlingScorer
import com.redspace.fullbowlingkata.given
import org.junit.Assert.assertEquals
import org.junit.Test
class FullBowlingKataTest1 {
val spare: (BowlingScorer) -> Unit = {
it.bowl(5)
@westonal
westonal / PassByValueProofTests.cs
Last active April 3, 2017 12:12
C# is Pass-By-Value by default proof
using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Framework.Tests.General
{
[TestClass]
public class PassByValueProofTests
{
package entities;
/** Represents a content item. */
abstract class Content {
UUID id;
}
———————————————————————————————————————————————————————————————————————————
package domain.usecases;
@westonal
westonal / Timber310Issue.md
Created March 9, 2017 13:47
Timber issue

Logging with a throwable calls Log and you can't stop it

Timber 3.1.0

uprootAll disables the logging, this works with, say Timber.w(String) but not Timber.w(Throwable, String). Here is a test that demonstrates this when run without Robolectric:

import org.junit.Test;

import java.util.concurrent.atomic.AtomicInteger;