Skip to content

Instantly share code, notes, and snippets.

@JohnAZoidberg
JohnAZoidberg / android1.2.4
Created August 26, 2014 21:44
minify_json
function minify_json($json) {
$search = array("recipient", "name", "sender", "sent", "seen", "message", "update", "exists", "brid", "title", "description", "city", "country", "userid", "date", "upload", "user", "user", "ownBracelet", "alreadyUpToDate", "picid", "longitude", "latitude", "state", "commid", "fileext", $username, "Deutschland", "United States");
$replace = array("1‡", "2‡", "3‡", "4‡", "5‡", "6‡", "7‡", "8‡", "9‡", "‡10", "‡11", "‡12", "‡13", "‡14", "‡15", "‡16", "‡17", "‡18", "‡19", "‡20", "‡21", "‡22", "‡3", "‡24", "‡25", "‡26", "‡27", "‡28", "‡29");
$json = str_replace($search, $replace, $json);
return $json;
}
@JohnAZoidberg
JohnAZoidberg / Dialogue.java
Last active February 21, 2016 20:26
Just a small class to aid in creating dialogs for Android applications. Called Dialogue because of the name conflict with the Android class Dialog.
import android.content.Context;
import android.content.DialogInterface;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog;
import android.text.InputType;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
@JohnAZoidberg
JohnAZoidberg / CanvasActivity.java
Created February 17, 2016 18:06
Android-Activity for drawing
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.view.View;
@JohnAZoidberg
JohnAZoidberg / ByteUtils.java
Last active February 19, 2016 23:05
Some useful methods for handling byte arrays.
package de.struckmeierfliesen.nxt.linefollower;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
public class ByteUtils {
private ByteUtils() {}
private static final byte MAX_BYTE = (byte) 0xff;
private static final byte NULL = 0x00 & MAX_BYTE;
@JohnAZoidberg
JohnAZoidberg / RecursiveLGame.java
Created March 26, 2016 18:53
Recursive Java solution to this problem: http://qr.ae/R6xOqn
import java.util.Arrays;
import java.util.Random;
public class RecursiveLGame {
enum Direction {
NW, NE, SW, SE
}
private static final int ILLEGAL = -1;
private static final int BLANK = 0;
@JohnAZoidberg
JohnAZoidberg / index.py
Last active June 29, 2016 16:59
"Hello World" for Python on Apache2 with CGI
#!/usr/bin/python -u
# coding=utf-8
import sys
reload(sys)
sys.setdefaultencoding("utf8")
import cgitb
cgitb.enable() # Displays any errors
print "Content-Type: text/html;charset=utf-8"
print
print "Hello World"
@JohnAZoidberg
JohnAZoidberg / .vimrc
Last active July 28, 2016 23:10
My vim config file
set nocompatible
filetype off
" set leader to , (Comma)
let mapleader=","
" Vundle Plugin manager
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
@JohnAZoidberg
JohnAZoidberg / bootstrap.sh
Last active March 17, 2023 09:44
Ubuntu fresh install bootstrap script
PYTHON_CONFIG_DIR=$1
if [ -z "$PYTHON_CONFIG_DIR" ]; then
echo "Python config dir unset - should be somewhere in /usr/lib/python2.7/";
exit 1
fi
# update
sudo apt-get update
# install git
sudo apt-get install -y git
@JohnAZoidberg
JohnAZoidberg / bitshifting.c
Last active July 2, 2017 07:23
Demonstrate the behaviour of bitshifting in C
#include <stdio.h>
/*** Output looks like the following ***/
/* ******** Signed ********: */
/* Bitshift right (>>=1) */
/* -128 in binary: 10000000 */
/* -64 in binary: xxxxxxxx */
/* */
/* Bitshift right (>>=1) */
/* 64 in binary: 01000000 */

Keybase proof

I hereby claim:

  • I am JohnAZoidberg on github.
  • I am johnzoidberg (https://keybase.io/johnzoidberg) on keybase.
  • I have a public key whose fingerprint is 85C6 A8B8 A3F6 AF24 117A 293E 5F01 E234 0DD0 2716

To claim this, I am signing this object: