Skip to content

Instantly share code, notes, and snippets.

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

Callum Taylor scruffyfox

🏳️‍🌈
+++
  • UK
View GitHub Profile
@scruffyfox
scruffyfox / gist:1333916
Created November 2, 2011 15:23 — forked from codeincontext/gist:1285806
Javascript function to show how long ago a timestamp was as a pretty string
/**
* Converts a timestamp to how long ago syntax
* @param time The time in seconds
* @return The formatted time
*/
public static String timeAgo(int time)
{
Unit[] units = new Unit[]
{
new Unit("s", 60, 1),
@scruffyfox
scruffyfox / gist:1362566
Created November 13, 2011 19:44
Brainfuck Interpreter
#include <stdio.h>
static unsigned char cell[30000];
static unsigned char *ptr;
void processCommand(char command, FILE *file)
{
char cmd;
long pos;
@scruffyfox
scruffyfox / gist:1362570
Created November 13, 2011 19:45
JQuery Delay
//********************************************************************
//
// jQuery delay created by Callum Taylor
// v 0.1
// This simple function is to emulate a javascript setTimeout but
// in a jQuery way. This is not the same as the standard effects delay
// where you can only use delay AFTER an effect, this plugin can
// be used on its own to delay a function from executing
//
// Usage:
@scruffyfox
scruffyfox / gist:1362572
Created November 13, 2011 19:46
JQuery Image Slider
//********************************************************************
//
// jQuery imageSlide created by Callum Taylor
// v 0.3
//
// Usage:
// $('div').imageSlide({timeout: 2000, children:"div", fadesSpeed:1000, loop: 2}, callback);
//
//********************************************************************
@scruffyfox
scruffyfox / gist:1885236
Created February 22, 2012 13:49
Clear anything outputted before outputting new text
ob_end_clean();
ob_start();
//output the message
echo ($message);
flush();
ob_end_clean();
exit();
@scruffyfox
scruffyfox / gist:2376327
Created April 13, 2012 11:54
Start a telephone call
String telNum = "tel:" + url.getHost().replaceAll(" ", "");
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(telNum));
startActivity(intent);
@scruffyfox
scruffyfox / gist:2376347
Created April 13, 2012 11:57
Launch email
MailTo mail = MailTo.parse(url.toString());
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("plain/text");
if (!StringUtils.isEmpty(website) && !StringUtils.isEmpty(email))
{
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{email + "@" + website});
}
@scruffyfox
scruffyfox / gist:2376354
Created April 13, 2012 11:58
Goto marketplace from app
Intent market = new Intent(Intent.ACTION_VIEW);
market.setData(Uri.parse("market://details?id=" + getPackageName()));
startActivity(market);
@scruffyfox
scruffyfox / gist:2412956
Created April 18, 2012 11:16
Goto external URL
Intent webIntent = new Intent(Intent.ACTION_VIEW);
webIntent.setData(Uri.parse(URL));
startActivity(webIntent);
@scruffyfox
scruffyfox / gist:2414891
Created April 18, 2012 16:40
Show keyboard for edit text programatically
editText.requestFocus();
editText.requestFocusFromTouch();
InputMethodManager m = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
m.showSoftInput(editText, 0);