This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd $HOME | |
echo Updating system | |
sudo apt-get update -y | |
sudo apt-get upgrade -y | |
sudo apt-get install -y curl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SERVICE_URL=http://icanhazip.com/ | |
if hash wget 2>/dev/null; then | |
wget -qO- $SERVICE_URL | |
elif hash curl 2>/dev/null; then | |
curl $SERVICE_URL | |
else | |
>&2 echo Need wget or curl. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Ubuntu: apt-get install libtagc0-dev | |
# gem install taglib-ruby | |
require 'taglib' | |
require 'fileutils' | |
#------------------------------------------------ | |
# Configuration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'date' | |
class Cache | |
Entry = Struct.new(:expiry, :value) | |
def initialize(opts={}) | |
@data = Hash.new | |
@opts = opts | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
1st | |
2nd | |
3rd | |
4th | |
11th | |
12th | |
21st | |
22nd | |
121st |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Cache(config) { | |
config = config || {}; | |
config.trim = config.trim || 600; | |
config.ttl = config.ttl || 3600; | |
var data = {}; | |
var self = this; | |
var now = function() { | |
return new Date().getTime() / 1000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$#" -ne 1 ]; then | |
echo "No filename specified." >&2 | |
exit 1 | |
fi | |
FILENAME=$1 | |
MIMETYPE=$(file -b --mime-type "$FILENAME") | |
DATA=$(cat "$FILENAME" | base64) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.content.res.TypedArray; | |
import android.util.AttributeSet; | |
import android.widget.ImageView; | |
public class RatioImageView extends ImageView { | |
private static final float DEFAULT_WIDTH_RATIO = 1; | |
private static final float DEFAULT_HEIGHT_RATIO = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// APK signing | |
def signingPropFile = new File(project.rootDir, "signing.properties") | |
if(signingPropFile.exists()) { | |
Properties props = new Properties() | |
props.load(new FileInputStream(signingPropFile)) | |
android { | |
signingConfigs { | |
release { | |
storeFile file(props['signing.keystore']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ONE implementation for everything | |
public static T[][] chunkArray<T>(T[] array, int chunkSize) { | |
int numOfChunks = (int)Math.Ceiling((double)array.Length / chunkSize); | |
T[][] output = new T[numOfChunks][]; | |
for(int i = 0; i < numOfChunks; ++i) { | |
int start = i * chunkSize; | |
int length = Math.Min(array.Length - start, chunkSize); | |
T[] temp = new T[length]; |