Skip to content

Instantly share code, notes, and snippets.

View scruffyfox's full-sized avatar
🏳️‍🌈
+++

ScruffyFox scruffyfox

🏳️‍🌈
+++
View GitHub Profile
@scruffyfox
scruffyfox / whitespace.rb
Created September 12, 2013 09:04
Remove whitespace and replace 4 spaces with tabs in xml resource files
#!/usr/bin/ruby
# Based on the script from http://www.splinter.com.au/ruby-script-to-increment-a-build-number/
@path = File.dirname(__FILE__)
res = "/res/"
def strip(filename)
# Read it
file_str = ''
if File.exists?(filename)
@scruffyfox
scruffyfox / licences.html
Last active December 19, 2015 01:39
Licenses for android. Includes: Android support lib GCM Gson Lombok Otto Action bar sherlock Async http client Facebook Google play services View page indicator
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<style type="text/css">
pre
{
background: #eeeeee;
padding: 5px;
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
{
"clauses": [
{
"field": "/data/entities/mentions/*/id",
"object_type": "message",
"operator": "one_of",
"value": "$authorized_userids"
},
{
"field": "/meta/channel_type",
@scruffyfox
scruffyfox / gist:5821823
Created June 20, 2013 10:51
Get time/date string based on user's set date/time configuration
GregorianCalendar cal = new GregorianCalendar();
GregorianCalendar todayDate = new GregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DATE));
long startDate = todayDate.getTimeInMillis();
DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(c);
DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(c);
String time = "";
if (getPostDate() > startDate)
@scruffyfox
scruffyfox / LocationHelper.java
Created June 19, 2013 10:32
Location helper class which uses a series of different listeners to determine the user's current location as accurately as possible.
/**
* @brief x lib is the library which includes the commonly used functions in 3 Sided Cube Android applications
*
* @author Callum Taylor
**/
package in.lib.helper;
import java.util.List;
import android.content.Context;

View injection class which runs at runtime rather than compile time like ButterKnife. The benefit to this is there's no generated code which some IDEs (such as Eclipse) fail to generate properly and can often lead to broken references.

Also contains an onClick annotation.

Useage:

// View inject for variable
@InjectView(R.id.view_id) private View view;
@InjectView(id = "view_id") private View view; // use this in libraries because IDs are not constant
@scruffyfox
scruffyfox / gist:5592299
Last active December 17, 2015 10:09
Using drawer layout with actionbar sherlock support
package com.cube.arc.vh;
import android.app.ActionBar;
import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
@scruffyfox
scruffyfox / Debug.java
Last active December 15, 2015 18:19
Debug class for Android
package in.lib;
import android.util.Log;
import java.util.Collection;
public class Debug
{
private static long timeseed = 0L;
private final static String LOG_TAG = "DEBUG";
App.net Filter for use in a stream receiving private messages and posts. Specify ['post', 'message'] as value for the 'object_types' field when creating (or updating) a stream. This filter will catch mentions in posts and private messages sent to any of the users using your ADN app.
Filter:
"match_policy":"include_any",
"clauses":[
{
"operator":"one_of",
"field":"\/data\/entities\/mentions\/*\/id",
"object_type":"post",
"value":"$authorized_userids"
@scruffyfox
scruffyfox / gist:5227546
Last active December 15, 2015 07:59
Square layout
package x.ui;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;
/**
* @brief Square layout class to create layouts that adjust its width/height to achieve the 1:1 scale ratio.
*
* @code