Skip to content

Instantly share code, notes, and snippets.

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;
/*
<?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 / 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 / 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: [email protected] (SoThree.com).
set -e
if [ $# -lt 1 ]
then
echo "Usage: `basename $0` instance_name"
exit 1
fi
@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: [email protected]
CODE_LOCATION=/var/www/your_project
SERVER_PREFIX=your_project
# exit if something fails
set -e
@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>
@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);
@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;
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 / 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 ]