Skip to content

Instantly share code, notes, and snippets.

View angelix's full-sized avatar

Angelos Veglektsis angelix

  • Aveworks
  • Athens, Greece
View GitHub Profile
@swftvsn
swftvsn / FirebasePushIdGenerator.java
Created March 15, 2017 10:36
Firebase Java Push Id Generator
package firebase;
public class FirebasePushIdGenerator {
// Modeled after base64 web-safe chars, but ordered by ASCII.
private final static String PUSH_CHARS = "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";
// Timestamp of last push, used to prevent local collisions if you push twice in one ms.
private static long LAST_PUSH_TIME = 0L;
Unless specified otherwise, all of the below tinting applies to both Lollipop and pre-Lollipop using AppCompat v21.
To use the support version of these attributes, remove the android namespace.
For instance, "android:colorControlNormal" becomes "colorControlNormal".
These attributes will be propagated to their corresponding attributes within the android namespace
for devices running Lollipop. Any exceptions to this will be noted by including the "android:" prefix.
All Clickable Views:
-----------
@angelix
angelix / ManagedDataHelper.java
Last active December 20, 2015 16:59
ManagedDataHelper is a Helper class that gives you the ability to override strings (or array of strings) saved on Android Resources (xml) with data from a remote JSON document.
public class ManagedDataHelper {
static ManagedDataHelper sSelf = null;
static final String SHARED_PREFERENCES_FILENAME = "managed_data";
Context mContext;
Resources mResources;
SharedPreferences mSharedPreferences;
private ManagedDataHelper(Context context) {
mContext = context;
mResources = mContext.getResources();
@felixge
felixge / command.sh
Created October 29, 2011 13:43
Bash stuff for fighting a weak DOS attack
# Here a few bash one-liners that helped me analyze / fight a weak DOS attack against debuggable.com. Mostly for future reference.
# The attacker was opening lots of tcp connections without sending data, I believe it's called a SYN flood, see: http://tools.ietf.org/html/rfc4987#section-3.2
# Step 0: Check what is going on at port 80
$ netstat -tan | grep ':80 ' | awk '{print $6}' | sort | uniq -c
# Step 1: Increase the number of available fds
$ ulimit -n 32000
# Step 2: Restart your webserver, for me: