Skip to content

Instantly share code, notes, and snippets.

@tokudu
tokudu / ec2ssh.sh
Created October 27, 2012 23:55
A helper script for SSH'ing into EC2 instances by name
#!/bin/bash
# SSH into an EC2 instance by name
# Author: tokudu@github.com (SoThree.com).
set -e
if [ $# -lt 1 ]
then
echo "Usage: `basename $0` instance_name"
exit 1
fi
@tokudu
tokudu / embed.html
Last active October 13, 2015 07:07
Embeddable Umane player
<script>(function(d, s, id) {
var js, ujs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//umano.me/widgets/player.min.js";
ujs.parentNode.insertBefore(js, ujs);
}(document, 'script', 'umano-jssdk'));</script>
<div class="umano-player" data-canonical="http://pandodaily.com/2012/11/21/umano-wants-to-tell-you-the-news-literally">
</div>
<?xml version="1.0" encoding="utf-8"?>
<com.tokudu.begemot.widgets.CheckableLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dip"
android:orientation="vertical"
>
<CheckedTextView
android:id="@+id/user_name"
@tokudu
tokudu / restore_db.sh
Created June 25, 2015 05:16
Simple shell script to restore a mongodb databse from an S3 backup using mongorestore
#!/bin/bash
TIMESTAMP=`date +%F-%H%M`
DUMP_LOCAL=/tmp/dump-${TIMESTAMP}
# exit if something fails
set -e
if [ $# -lt 2 ]
then
@tokudu
tokudu / background_color_span.java
Last active November 21, 2016 11:35
BackgroundColorSpan Example
String str = "Some really long string goes in here";
Spannable spannable = new SpannableString(str);
spannable.setSpan(new BackgroundColorSpan(
getResources().getColor(android.R.color.black)
), 0, str.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
yourTextView.setText(spannable);
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
@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;
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 / 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
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;
/*