Skip to content

Instantly share code, notes, and snippets.

View mediavrog's full-sized avatar

Maik B mediavrog

  • @shackersNFT
  • Germany / Japan
View GitHub Profile
@mediavrog
mediavrog / findByXPath.js
Created June 27, 2015 16:08
Javascript find by XPath
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 August 29, 2015 14:19
JodaSupport ActiveRecord
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]})
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"))
@mediavrog
mediavrog / bound_greeting.js
Created February 10, 2015 08:29
JS bound greeting
/*
* Assuming we have some object with properties and methods
*/
var me = {
first_name: 'Ahikar',
last_name: 'Grilka',
race: 'Klingon',
email: 'AhikarGrilka@jourrapide.com',
occupation: 'Commander of Defence',
greet: function(other_person){
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) {
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 (、。’)
// Create the Global class in your /app folder root package:
import play.api.{GlobalSettings, Play}
import play.api.Play.current
import play.api.mvc._
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
/**
@mediavrog
mediavrog / build.gradle
Created July 16, 2014 09:25
Evernote library build.gradle file
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
@mediavrog
mediavrog / build.gradle
Created July 15, 2014 04:59
Simple gradle build file for legacy structure library projects
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
@mediavrog
mediavrog / EditText.xml
Created June 4, 2014 02:27
Cursor not visible in EditText in Jelly Bean - this happens if you set a background for the field; to fix it, set the cursorDrawable to @null. Always use this combination when using custom backgrounds.
<EditText
android:id="@+id/my_edit_text"
...
android:background="@drawable/some_bg"
android:textCursorDrawable="@null" />