Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# simple Http server for sharing a folder over the network.
python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"
// Android notification that cancels automatically when user clicks
Notification notification = new Notification(R.drawable.icon, "Posit",
System.currentTimeMillis());
Intent intent = new Intent(MAIN_ACTIVITY,SyncService.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
notification.setLatestEventInfo(MAIN_ACTIVITY, "Service started", "POSIT service started", pendingIntent);
notification.flags = Notification.FLAG_AUTO_CANCEL;
mNotificationManager.notify(R.string.addLabel, notification);
@prasincs
prasincs / java looping over HashMap
Created April 26, 2009 04:41
Loop over HashMap
Iterator iter = values.keySet().iterator();
while (iter.hasNext()) {
String key = iter.next();
String value = values.get(key);
System.out.println("Key ="+key+"\n Value"+value)
}
@prasincs
prasincs / Getting default preferences
Created May 3, 2009 23:51
get the default preferences in Android
// to get the default preferences for an application assuming your preferences file is in
// res/xml/posit_preferences
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
Log.i(TAG, sp.getString("APP_KEY", "test"));
#for setting up the headset as the default sound card in the system
asoundconf set-default-card Headset
//showing and editing AlertDialog with EditText
LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null);
myAlertDialog = new AlertDialog.Builder(this)
.setTitle(R.string.alert_dialog_title)
.setView(textEntryView)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
EditText et = (EditText) ShowProjectsActivity.myAlertDialog.findViewById(R.id.devicename_edit);
deviceName = et.getText().toString();
#!/bin/bash
#this is useful for seeing how far some directory has been used in real time
#needs to have dialog utility installed and ncurses
while true;do
cmd=`du -sh /home3/johndoe`
echo $cmd
x=` echo $cmd |cut -d ' ' -f 1`
#if [ $x == "10G" ]; then
# dialog --messagebox "10 gigs" 100 200;
# exit;
import socket
import pymedia.audio.sound as sound,time
PORT = 3001
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("",PORT))
s.listen(5)
while 1:
c, addr = s.accept()
while 1:
/*A script to update friendfeed status */
CmdUtils.CreateCommand({
names: ["friendfeed","ff"],
icon: "http://www.friendfeed.com/favicon.ico",
description: "Update your friendfeed status. Remember you need to give your API key from http://friendfeed.com/api",
help: "friendfeed \"status you want to put\"",
author: {name: "Prasanna Gautam", email: "you@mozilla.com"},
license: "MIT",
homepage: "http://nextdoorhacker.com",
arguments: [{role: 'object', nountype: noun_arb_text}],
/**
* @param filePath
* name of file to open. The file can reside
* anywhere in the classpath or absolute path path
*/
public static String readFileAsString(String filePath) throws java.io.IOException {
StringBuffer fileData = new StringBuffer(1000);
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(filePath)));
char[] buf = new char[1024];
int numRead = 0;