This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# simple Http server for sharing a folder over the network. | |
python -c "import SimpleHTTPServer;SimpleHTTPServer.test()" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#for setting up the headset as the default sound card in the system | |
asoundconf set-default-card Headset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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: "[email protected]"}, | |
license: "MIT", | |
homepage: "http://nextdoorhacker.com", | |
arguments: [{role: 'object', nountype: noun_arb_text}], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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; |
OlderNewer