Skip to content

Instantly share code, notes, and snippets.

View sudar's full-sized avatar

Sudar Muthu sudar

View GitHub Profile
@sudar
sudar / MediaPlayerServiceConnection.java
Created March 5, 2011 10:59
Finding the currently playing song in Android
/**
* The service connection class that allows you to talk to the MediaPlayer Service
*
* @author "Sudar Muthu (http://sudarmuthu.com)"
*
*/
private class MediaPlayerServiceConnection implements ServiceConnection {
public com.htc.music.IMediaPlaybackService mServiceHtc;
public com.android.music.IMediaPlaybackService mServiceAndroid;
<?php
require_once('geoplugin.class.php');
$geoplugin = new geoPlugin();
$geoplugin->locate();
echo get_posts_by_tag("{$geoplugin->city},$geoplugin->region}", 5);
?>
public class ConditionalCompile {
private static final Logger LOGGER = Logger.getLogger(ConditionalCompile.class);
private final static boolean doLogging = false;
public static void importantMethod( ) {
// Do some set up code.
if (doLogging) {
LOGGER.debug("Set up complete, beginning phases.");
}
// do first part.
ADK demo start
ADK Init
ADK protocol rev. 1
Accessory mode switch attempt
ADK Init
Acc.mode device detected
Endpoint Structure:
EP0:
@sudar
sudar / index.php
Created August 19, 2011 16:37
A very simple PHP script to query YQL
<html>
<head>
<title>PHP Workshop</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h1>PHP Workshop</h1>
<p id = "special">The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
</p>
@sudar
sudar / 1
Created August 24, 2011 14:16
[gist id = "{GIST_ID}" file = "{GIST_FILE}"]
<?php
/**
* Expand short urls
*
* @param <string> $url - Short url
* @return <string> - Longer version of the short url
*/
function expand_url($url){
//Get response headers
$response = get_headers($url, 1);
@sudar
sudar / unselect.html
Created September 23, 2011 16:03
Making some text unselectable in browser. More details at http://sudarmuthu.com/blog/making-text-unselectable-in-browser
<html>
<head>
<title>Making text unselectable</title>
<style>
body {
*-moz-user-select: none;
*-khtml-user-select: none;
*user-select: none;
}
.unselectable {
@sudar
sudar / gist:1289281
Created October 15, 2011 08:37
Access YQL in YUI
<html>
<head>
<title></title>
<script src="http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js"></script>
<script type="text/javascript">
YUI().use('node', 'yql', function(Y) {
var res = Y.one('#res'),
zip = '90210';
@sudar
sudar / deploy.sh
Created October 15, 2011 09:26
rsync command to sync two folders
# rsync command to sync two folders
rsync --verbose --progress --stats --compress --rsh=ssh \
--recursive --times --links -u --rsh='ssh -p8023' \
--exclude "*.sh" --exclude "*~" --exclude "*.svn" --exclude "*.git" --exclude "nbproject" --exclude ".DS_Store" \
/path/to/local/file/ myserver.org:/path/in/remote/server/