Skip to content

Instantly share code, notes, and snippets.

Avatar

Maik Buchmeyer mediavrog

  • @shackersNFT
  • Germany / Japan
View GitHub Profile
@mediavrog
mediavrog / enable-volley-verbose-logging
Last active Mar 26, 2017
Enable verbose logging in Google Volley networking library
View enable-volley-verbose-logging
# (42f63b0de7318fe1 is a device id)
adb -s 42f63b0de7318fe1 shell setprop log.tag.Volley VERBOSE
@mediavrog
mediavrog / DecoratedRequestQueue.java
Created Oct 23, 2013
Make Volley RequestQueue / ThreadPool work with Espresso Testing library
View DecoratedRequestQueue.java
package com.vuzz.snapdish.test.functional;
import android.os.Handler;
import com.android.volley.Cache;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.google.android.apps.common.testing.ui.espresso.contrib.CountingIdlingResource;
/**
* A dummy request queue which enables us to use the Volley Library properly with Espresso.
View naver_line_post_image.java
package com.yokogoshi.line_intent_test;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
View regex-japanese.txt
Regex for matching ALL Japanese common & uncommon Kanji (4e00 – 9fcf) ~ The Big Kahuna!
([一-龯])
Regex for matching Hirgana or Katakana
([ぁ-んァ-ン])
Regex for matching Non-Hirgana or Non-Katakana
([^ぁ-んァ-ン])
Regex for matching Hirgana or Katakana or basic punctuation (、。’)
View CollectionUtils.java
package es.cloudey.pagespeed.util;
import java.util.HashMap;
import java.util.Map;
import android.os.Bundle;
import android.os.Parcelable;
public class CollectionUtils {
public static Bundle toBundle(Map<String, ? extends Parcelable> input) {
@mediavrog
mediavrog / analytics.coffee
Last active Aug 26, 2016
Javascript / Coffeescript snipped to use Google Analytics with Turbolinks in Rails 4
View analytics.coffee
# add the tracking code normally to your layout; then include this in every page
$(document).on 'page:change', ->
if window.ga?
ga('send', 'pageview');
else if window._gaq?
_gaq.push(['_trackPageview'])
else if window.pageTracker?
pageTracker._trackPageview()
View init_crittercism.java
/*######################
* Crittercism
* crittercism.com
######################*/
JSONObject crittercismConfig = new JSONObject();
JSONObject crittermeta = new JSONObject();
try {
crittermeta.put("screen_name", "" + screen_name);
crittermeta.put("user_id", "" + user_id);
@mediavrog
mediavrog / findByXPath.js
Created Jun 27, 2015
Javascript find by XPath
View findByXPath.js
function getElementByXpath(path) {
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}
console.log( getElementByXpath("//html[1]/body[1]/div[1]") );
@mediavrog
mediavrog / CustomActiveRecordDsl.scala
Last active Aug 29, 2015
JodaSupport ActiveRecord
View CustomActiveRecordDsl.scala
val jodaDateTimeConverter = new FormConverter[DateTime] {
override def serialize(v: Any): String =
new DateTime(v).toString(ISODateTimeFormat.dateHourMinuteSecond)
override def deserialize(s: String): DateTime =
new DateTime(s.toLong)
}
FormConverter.register(classOf[DateTime], jodaDateTimeConverter)
ClassInfo.factories.register(classOf[DateTime], {() => DateTime.now.asInstanceOf[AnyRef]})
View ARAutoRollback.scala
import com.github.aselab.activerecord.{PlayConfig, ActiveRecordTables}
import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach}
import play.api.Play
import play.api.test.FakeApplication
trait ActiveRecordAutoRollback extends BeforeAndAfterEach with BeforeAndAfterAll {
self: ApiBaseSpec =>
def schema: Seq[ActiveRecordTables] = Seq(ActiveRecordTables.find("models.Tables"))