Skip to content

Instantly share code, notes, and snippets.

@suclike
suclike / understanding-word-vectors.ipynb
Created August 15, 2018 21:44 — forked from arpit/understanding-word-vectors.ipynb
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@suclike
suclike / curl_post_json.md
Created August 15, 2018 14:57 — forked from ungoldman/curl_post_json.md
post a file JSON file with curl

How do POST file with curl??

You can post a json file with curl like so:

curl -X POST -H "Content-Type: application/json" -d @FILENAME DESTINATION

so for example:

@suclike
suclike / RxImmediateSchedulerRule.kt
Created August 3, 2018 09:58 — forked from starkej2/RxImmediateSchedulerRule.kt
RxJava Immediate Scheduler Test Rule
/**
* Replaces the default RxJava schedulers with a synchronous one.
*/
class RxImmediateSchedulerRule : TestRule {
private val immediateScheduler = object : Scheduler() {
@NonNull
override fun scheduleDirect(@NonNull run: Runnable, delay: Long, @NonNull unit: TimeUnit): Disposable {
// Hack to prevent stack overflows in unit tests when scheduling with a delay;
return super.scheduleDirect(run, 0, unit)
}
@suclike
suclike / curl.md
Created July 17, 2018 12:39 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@suclike
suclike / MutableLazy.kt
Created June 15, 2018 15:31 — forked from felipecsl/MutableLazy.kt
A Kotlin lazy that can be set to override the initializer value
private fun <T> mutableLazy(initializer: () -> T) = Delegate(lazy(initializer))
class Delegate<T>(private val lazy: Lazy<T>) {
private var value: T? = null
operator fun getValue(thisRef: Any?, property: KProperty<*>): T {
return value ?: lazy.getValue(thisRef, property)
}
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {
@suclike
suclike / CardViewCollapsible.kt
Created May 28, 2018 12:59 — forked from fabio-filho/CardViewCollapsible.kt
Card View Easy Collapsible - With Kotlin =D
// Usage - MainActivity
val collapsible = myCardView.buildCollapsible()
myButton.onClick {
collapsible.toggle()
}
// ============================================================================================================================
package your_package
import android.animation.ValueAnimator
import android.support.v7.widget.CardView
@suclike
suclike / FxRateLoaderTest.java
Created May 14, 2018 15:10 — forked from nowsprinting/FxRateLoaderTest.java
@it掲載「Android Mockを利用してHTTP通信をテストするには」サンプルコードのmockito使用版
/*
* Copyright(c) 2012 Android Test and Evaluation Club.
*
*/
package org.android_tec.atmarkit.usemockexample.models;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@suclike
suclike / App.kt
Created March 25, 2018 23:08 — forked from tinmegali/App.kt
Injecting ViewModel with Dagger2 on Android using Kotlin
class App : Application(), HasActivityInjector {
@Inject lateinit var activityInjector: DispatchingAndroidInjector<Activity>
override fun activityInjector(): AndroidInjector<Activity> {
return activityInjector
}
override fun onCreate() {
super.onCreate()
@file:Suppress("unused", "FunctionName", "IllegalIdentifier")
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
/**
* The best way to launch yourself an activity. Your implementation should enable the following api:
/**
* ArcUtils.java
*
* Copyright (c) 2014 BioWink GmbH.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is