Skip to content

Instantly share code, notes, and snippets.

git branch --merged develop | grep -v master | grep -v develop | xargs -L1 git branch -d
@goofyahead
goofyahead / testrunner.html
Created December 19, 2017 14:06 — forked from jonnyreeves/testrunner.html
Unit Testing Promises with Sinon.js
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css" type="text/css" media="screen" />
<!-- when.js Promises implementation -->
<script src="https://raw.github.com/cujojs/when/master/when.js"></script>
<!-- Unit testing and mocking framework -->
<script type="text/javascript" src="http://code.jquery.com/qunit/git/qunit.js"></script>
0x6C45A5019F0e56Baad94B014961cD3EEbe95ceF8
0xE4E0A63f6f275bb45279046f27BB8436ecFdfF21
@goofyahead
goofyahead / Interceptor.java
Created June 7, 2017 04:08 — forked from alex-shpak/Interceptor.java
Refreshing OAuth token with okhttp interceptors. All requests will wait until token refresh finished, and then will continue with the new token.
private class HttpInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//Build new request
Request.Builder builder = request.newBuilder();
builder.header("Accept", "application/json"); //if necessary, say to consume JSON
android.applicationVariants.all {
def aptOutputDir = new File(buildDir, "generated/source/apt/${it.unitTestVariant.dirName}")
it.unitTestVariant.addJavaSourceFoldersToModel(aptOutputDir)
}
@Module
public class FlombulatorTestModule {
@Provides
Flumbolator provideTestFlombulator() {
System.out.println("I the mocked flumbolator have been summoned, behold my mock power");
Flumbolator flum = Mockito.mock(Flumbolator.class);
when(flum.frumbolateMe()).thenReturn("flumbolate test");
return flum;
}
@Subcomponent(modules = {
FlombulatorTestModule.class,
TestMainActivitySubComponent.MainActivityModule.class
})
public interface TestMainActivitySubComponent extends AndroidInjector<MainActivity> {
@Module
class MainActivityModule {}
@Subcomponent.Builder
@Module(subcomponents = {
TestMainActivitySubComponent.class,
TestSecondaryActivitySubComponent.class
})
public abstract class TestBindingModule {
@Binds
@IntoMap
@ActivityKey(MainActivity.class)
abstract AndroidInjector.Factory<? extends Activity> bindMainActivityInjectorFactory(TestMainActivitySubComponent.Builder builder);
@Component(
modules = {
AndroidInjectionModule.class,
TestBindingModule.class,
TestApplicationComponent.TestAppModule.class
})
interface TestApplicationComponent {
void inject(TestApplication app);