Skip to content

Instantly share code, notes, and snippets.

View kibotu's full-sized avatar
🎯
Focusing

Jan Rabe kibotu

🎯
Focusing
View GitHub Profile
@kibotu
kibotu / gist:1278883c19810f40f2c4
Created September 17, 2014 13:10
should_verify_response()
[Test]
public function should_verify_response():void {
// @see https://manage.sbs.wooga.com/docs/api/abconfig
// 1) Decrypt the X-SBS-Config-Signature using the public key for your SBS-ID
var rsa:RSAKey = PEM.readRSAPublicKey(correctKey);
var src:ByteArray = new ByteArray();
src.writeUTFBytes(Base64.encode(correctSignature));
@kibotu
kibotu / Sierpinski.java
Created September 20, 2014 12:49
Sierpinski Triangle and Carpet
package klausur.spierpinski;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import static javax.swing.JFrame.EXIT_ON_CLOSE;
@kibotu
kibotu / gist:5745d401f26aec4e13cc
Created November 17, 2014 10:54
Unlock Achievement with Promises
public override Promise unlockAchievements (string name, double points, bool autoStart = true)
{
var deferred = new Deferred<bool>();
string format = "Unlock Achievement " + name + " with " + points;
deferred.OnFulfilled += (bool result) => Debug.Log(format + ": " + result);
deferred.OnFailed += (bool result) => Debug.Log(format + ": " + result);
deferred.action += () =>
Social.ReportProgress(name, points, (bool success) => {
if(success)
@kibotu
kibotu / Extensions
Created December 18, 2014 15:56
IEnumerable ToString with separator extension method
public static string ToString<T>(this IEnumerable<T> list, string separator)
{
StringBuilder sb = new StringBuilder();
foreach (var obj in list) {
if (sb.Length > 0) {
sb.Append(separator);
}
sb.Append(obj);
}
return sb.ToString();
@kibotu
kibotu / extension
Created January 29, 2015 10:20
get component by interface from gameobject
public static T GetComponentByInterface<T>(this GameObject go) where T : class
{
var components = go.GetComponents<MonoBehaviour>();
foreach (var c in components)
{
T t = c as T;
if (t != null)
return t;
}
return null;
@kibotu
kibotu / build.gradle
Created July 21, 2015 13:55
git version count and version name
def getCommitCount() {
final Scanner s = new Scanner(getCommitNumberFromGit());
int count = 0;
while (s.hasNextLine()) {
s.nextLine();
count++;
}
return count;
@kibotu
kibotu / set crashlytics custom version name
Last active September 18, 2015 12:23
crashlytics hack to set different version name
private void setupCrashlytics(@NotNull final Activity activity) {
final Crashlytics crashlytics = new Crashlytics();
// hack to set fully classified version name @see gradle task.canonicalReleaseVersionName
try {
final Field versionNameField = CrashlyticsCore.class.getDeclaredField("versionName");
versionNameField.setAccessible(true);
versionNameField.set(crashlytics.core, Build.getValue(CANONICAL_VERSION_NAME));
} catch (Exception e) {
e.printStackTrace();
@kibotu
kibotu / gist:d80545ef4d3700a4f832
Created September 22, 2015 13:45
parse date format
/**
* Format dd.MM.yy hh:mm e.g.: 24.09.15 12:26
*/
public static Date parseDate(final String date) {
final DateFormat df = new SimpleDateFormat("dd.MM.yy hh:mm");
Date result = null;
try {
result = df.parse(date);
@kibotu
kibotu / RequestMethod.java
Last active November 24, 2015 13:30
gson request methods annotation
import android.support.annotation.IntDef;
import com.android.volley.Request;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@IntDef({
Request.Method.DEPRECATED_GET_OR_POST,
Request.Method.GET,
@kibotu
kibotu / upload_to_hockey.sh
Last active April 2, 2016 12:41
Upload to hockey using curl with progress bar.
#!/bin/sh
HOCKEY_API_TOKEN=""
HOCKEY_APP_TOKEN=""
APP_PATH="ci-build.apk"
curl \
--progress-bar \
-F "status=2" \
-F "notify=1" \