Skip to content

Instantly share code, notes, and snippets.

View mherod's full-sized avatar
🏳️‍🌈

Matthew Herod mherod

🏳️‍🌈
View GitHub Profile
@mherod
mherod / hashnav.js
Created July 17, 2013 14:23
Ajax hash navigation with default page switch and transition animation
var container_div = ".container", content_div = ".content", default_hash = "#main";
function anchorRefresh() {
var a = location.hash.substring(1);
$(".active").removeClass("active");
$(content_div).css({opacity:0.5});
$(content_div).load("ajax/" + a + ".html", function() {
$(location.hash).addClass("active");
$(content_div).animate({opacity:1})
})
@mherod
mherod / preventanchor.js
Created July 17, 2013 14:32
Prevent hash anchor jump
setTimeout(function() {
location.hash && window.scrollTo(0, 0)
}, 1);
@mherod
mherod / LiveLocationManager.java
Created July 17, 2013 14:37
LiveLocationManager for acquiring and optionally maintaining the most accurate and relevant location fix
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
public class LiveLocationManager implements LocationListener {
private final String TAG = "LiveLocationManager";
@mherod
mherod / helloworld.c
Created July 18, 2013 01:57
Hello world in C
#include<stdio.h>
main()
{
printf("Hello World");
}
@mherod
mherod / helloworld.c
Created July 18, 2013 01:58
Hello world in C++
#include <iostream>
using namespace std;
void main()
{
cout << "Hello World!" << endl;
}
@mherod
mherod / getgooglemapthumb.java
Created July 31, 2013 11:02
Google Maps static map bitmap function suitable for android
public static Bitmap getGoogleMapThumbnail(double lati, double longi){
String URL = "http://maps.google.com/maps/api/staticmap?center=" +lati + "," + longi + "&zoom=15&size=200x200&sensor=false";
Bitmap bmp = null;
HttpClient httpclient = new DefaultHttpClient();
HttpGet request = new HttpGet(URL);
InputStream in = null;
try {
in = httpclient.execute(request).getEntity().getContent();
bmp = BitmapFactory.decodeStream(in);
function throttle( fn, time ) {
var t = 0;
return function() {
var args = arguments, ctx = this;
clearTimeout(t);
t = setTimeout( function() {
fn.apply( ctx, args );
}, time );
};
@mherod
mherod / gist:6797975
Created October 2, 2013 18:08
Change Android ProgressBar colour
progressBar.getProgressDrawable().setColorFilter(Color.RED, Mode.SRC_IN);
@mherod
mherod / nnull.java
Created October 19, 2013 01:21
Checks to ensure that a number of given objects aren't null
private boolean nNull(Object... os) {
for (Object o : os) {
if (o == null) {
return false;
}
}
return true;
}
@mherod
mherod / YahooPrintCSV.java
Created June 7, 2014 01:25
A quick and dirty way to take yahoo printed contacts and convert them to a Google Contacts compatible CSV
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class YahooPrintCSV {
public static void main(String[] args) {