Skip to content

Instantly share code, notes, and snippets.

@daddykotex
daddykotex / DummyAndroidTextUtilsMockTest.java
Last active April 20, 2017 10:51
Mock Android TextUtils static method
import android.text.TextUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@daddykotex
daddykotex / DummyAndroidSpringRestTemplateApiTest.java
Created March 17, 2015 14:31
Test your Spring Rest Template APIs with the new Android Unit testing that requires mocking
package com.mnubo.platform.android.sdk.internal;
import android.util.Log;
import org.apache.http.conn.params.ConnManagerParams;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.AbstractHttpClient;
import org.apache.http.impl.client.DefaultHttpClient;

Keybase proof

I hereby claim:

  • I am daddykotex on github.
  • I am daddykotex (https://keybase.io/daddykotex) on keybase.
  • I have a public key ASDZYqHaKPAmTw84LVasQbF3XFK3QMaNH9NLJxTBstuRpAo

To claim this, I am signing this object:

@daddykotex
daddykotex / update-wordpress.sh
Created October 17, 2016 18:27
Update wordpress via shell access (3.1+)
#!/bin/bash
set -ex
# Update wordpress to a specific version. This script should work with versions above 3.1
# If you provide a LANG_CODE. It will be used to the appropriate Wordpress package.
# LANG_CODE examples: fr_CA, pt_BR, es_ES
# See WP supported languages here: https://codex.wordpress.org/Installing_WordPress_in_Your_Language#Manually_Installing_Language_Files
# See extended WP procedures here: https://codex.wordpress.org/Upgrading_WordPress_Extended
@daddykotex
daddykotex / variable-python-decorators.py
Last active January 5, 2021 04:17
Use an existing python decorator with variable parameters
#
# pip install tenacity
# Usage:
# → py variable-python-decorators.py 4
# The given maximum attempt number is 4
# We want this function to be retried 5 times
# We want this function to be retried 5 times
# We want this function to be retried 5 times
# We want this function to be retried 5 times
# We want this function to be retried 5 times
@daddykotex
daddykotex / DoobieComposite.scala
Created November 20, 2017 15:26
If you have a SQL column that allows NULL but you want to fallback to a default rather than using an `Option[T]`, you can define your own composite like that. This is probably nota good way to do it but it works and avoid the throwing of `NonNullableColumnRead`
import java.sql.{ResultSet, PreparedStatement}
import doobie.enum.nullability.Nullable
import doobie.imports._
import doobie.util.meta
import doobie.util.meta.Meta
import doobie.util.kernel.Kernel
sealed trait LoginWay {
import LoginWay._
@daddykotex
daddykotex / fetch-lightroom-album.sc
Created October 14, 2020 13:06
Allows you to download the higher resolution photos from a lightroom album (not original resolution).
import $ivy.`co.fs2::fs2-io:2.3.0`, fs2.io._
import $ivy.`co.fs2::fs2-core:2.3.0`, fs2._
import ammonite.ops._
import upickle.default.{ReadWriter => RW, macroRW}
import upickle._
import cats.effect._
import scala.concurrent.duration._
/**
@daddykotex
daddykotex / http4s-repro
Last active April 8, 2022 13:57
double scheme is a valid uri
//> using lib "org.http4s::http4s-core:0.23.11"
//> using scala "2.13.8"
object Repro extends App {
org.http4s.Uri
.fromString("https://https://some-url.com/path")
.fold(
err => println("Not gonna happen"),
_ => println("This prints")
)
@daddykotex
daddykotex / http4s-repro.scala
Created April 8, 2022 14:02
http4s double scheme
//> using lib "org.http4s::http4s-core:0.23.11"
//> using scala "2.13.8"
object Repro extends App {
org.http4s.Uri
.fromString("https://https://some-url.com/path")
.fold(
err => println("Not gonna happen"),
_ => println("This prints")
)