Skip to content

Instantly share code, notes, and snippets.

@tokudu
tokudu / StrictModeManager.kt
Last active April 5, 2021 21:04
StrictMode util that allows you to whitelist stack traces
package com.myapp
import android.os.Build
import android.os.StrictMode
import com.snap.core.BuildConfig
import com.snapchat.android.framework.logging.Timber
import java.lang.reflect.Field
import java.lang.reflect.Modifier
/**
@tokudu
tokudu / pretty_print.php
Created March 12, 2011 23:26
A function to pretty print a associative array in PHP
<?php
function debug($var = false) {
echo "\n<pre style=\"background: #FFFF99; font-size: 10px;\">\n";
$var = print_r($var, true);
echo $var . "\n</pre>\n";
}
?>
@tokudu
tokudu / backup_db.sh
Created June 25, 2015 05:15
Simple shell script to back up a mongodb database to S3 using mongodump.
#!/bin/bash
MONGODUMP_PATH="/usr/bin/mongodump"
TIMESTAMP=`date +%F-%H%M`
S3_CONFIG="/home/ubuntu/.s3cfg"
CHUNK_SIZE="500m" # 500 mg
DUMPS_TO_KEEP=30
if [ $# -lt 2 ]
// If true, the emails will be sent to the support email
var DEV_MODE = false;
// Index of some column that is not used.
var SENT_COLUMN = 15;
// Place your Grid API Key here.
var SENDGRID_KEY = PUT_YOUR_SEND_GRID_API_KEY_HERE;
// The emails will be send here.
var EMAIL_TO = "your-mail@mail.com";
// Errors will be send here
@tokudu
tokudu / PaddingBackgroundColorSpan.java
Created February 2, 2015 23:22
How to create BackgroundColorSpan with padding
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.text.style.LineBackgroundSpan;
public class PaddingBackgroundColorSpan implements LineBackgroundSpan {
private int mBackgroundColor;
private int mPadding;
private Rect mBgRect;
package com.tokudu.begemot.widgets;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Checkable;
import android.widget.CheckedTextView;
import android.widget.LinearLayout;
/*
@tokudu
tokudu / deploy.sh
Created November 14, 2012 02:41
A simple deployment script for EC2 instances
#!/bin/bash
# Updates all EC2 instances from git
# Author: anton@sothree.com
CODE_LOCATION=/var/www/your_project
SERVER_PREFIX=your_project
# exit if something fails
set -e
2018-07-03 11:03:13.648 22151-22151/com.myapp D/StrictMode: StrictMode policy violation; ~duration=9 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=3211271 violation=2
at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1293)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:183)
at libcore.io.IoUtils.canOpenReadOnly(IoUtils.java:163)
at dalvik.system.DexPathList$Element.findNativeLibrary(DexPathList.java:550)
at dalvik.system.DexPathList.findLibrary(DexPathList.java:480)
at dalvik.system.BaseDexClassLoader.findLibrary(BaseDexClassLoader.java:84)
at java.lang.Runtime.loadLibrary0(Runtime.java:966)
at java.lang.System.loadLibrary(System.java:1567)
at com.qualcomm.qti.Performance.<clinit>(Performance.java:21)
@tokudu
tokudu / SSNFormattingTextWatcher.java
Created October 12, 2016 04:52
TextWatcher for formatting SSN as XXX-XX-XXXX
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
public class SSNFormattingTextWatcher implements TextWatcher {
private EditText mEditText;
private boolean mShouldDeleteSpace;
public SSNFormattingTextWatcher(EditText editText) {
mEditText = editText;
int padding = 10; // in pixels
yourTextView.setShadowLayer(padding /* radius */, 0, 0, 0 /* transparent */);
yourTextView.setPadding(padding, padding, padding, padding);
// Now create the new span
String str = "Some really long string goes in here";
Spannable spannable = new SpannableString(str);
spannable.setSpan(new PaddingBackgroundColorSpan(
getResources().getColor(android.R.color.black),
padding