Skip to content

Instantly share code, notes, and snippets.

View dirkarnez's full-sized avatar
💪
want a lot of sleep...

Dirk Arnez dirkarnez

💪
want a lot of sleep...
  • Freelance
  • Hong Kong
View GitHub Profile
@dirkarnez
dirkarnez / normalizeVersionNumber.java
Created March 1, 2018 02:15
Normalize Version Number By Regex
private Version normalizeVersionNumber(String version) {
int major = 0;
int minor = 0;
int patch = 0;
// Now create matcher object.
Matcher m = Pattern.compile("(\\d+)(?:.(\\d+))?(?:.(\\d+))?").matcher(version);
if (m.find()) {
String majorString = m.group(1);
@dirkarnez
dirkarnez / SimpleCallbackWrapper.java
Created March 1, 2018 03:12
Callback wrapper for retrofit library
public class SimpleCallbackWrapper<T> implements retrofit2.Callback<T> {
private final String TAG = this.getClass().getSimpleName();
private Callback callback;
public SimpleCallbackWrapper(Callback callBack) {
this.callback = callBack;
}
@Override
public final void onResponse(Call<T> call, Response<T> response) {
@dirkarnez
dirkarnez / es6Annotation.js
Last active May 14, 2019 11:38
ES6 annotation
/**
* target is the class object,
* key is method name as String,
* descriptor is the meta-data behind the
* target
*/
function readonly(target, key, descriptor) {
target[key] = function() {
console.log('roar!');
}
@dirkarnez
dirkarnez / pointerToStruct.go
Created April 17, 2018 01:39
GoLang pointer to struct
package main
import "fmt"
type Vertex struct {
X int
Y int
}
func main() {
import { connect } from 'react-redux';
import { getTranslate } from 'react-localize-redux';
connect(
(state, ownProps) => ({translate: getTranslate(state.locale)}),
(dispatch, ownProps) => ({})
)(Component)
@dirkarnez
dirkarnez / reflection.go
Created April 20, 2018 02:37 — forked from drewolson/reflection.go
Golang Reflection Example
package main
import (
"fmt"
"reflect"
)
type Foo struct {
FirstName string `tag_name:"tag 1"`
LastName string `tag_name:"tag 2"`
@dirkarnez
dirkarnez / BuildVariant.cmd
Created April 20, 2018 02:57
Batch file for build variant
echo off
:begin
cls
echo Build Image for:
echo =============
echo -
echo 1) Development (TODO)
echo 2) UAT (TODO)
echo 3) Production
echo -
@dirkarnez
dirkarnez / hoverEnlarge.css
Last active April 30, 2018 06:09
Enlarge image when mouse hover
img {
transition:transform 0.25s ease;
}
img:hover {
transform:scale(1.5);
}
@dirkarnez
dirkarnez / Message.java
Created May 3, 2018 03:30
Java Builder Class
import java.util.*;
public class Message {
private int mType;
private String mMessage;
private List<String> mUsername;
private Message() {}
public int getType() {
@dirkarnez
dirkarnez / BitwiseCheckNthBit.java
Last active May 3, 2018 06:10
Java Bitwise check Nth bit is true
public class BitwiseCheckNthBit {
/*
* for more tutorial on bitwise operations
* http://www.catonmat.net/blog/low-level-bit-hacks-you-absolutely-must-know/
*/
public static void main(String []args){
int num = 2;
System.out.println(String.format("%b", getNth(num, 1)));
}