Skip to content

Instantly share code, notes, and snippets.

@interface StatusItemController : NSObject {
NSStatusItem *statusItem;
NSMenu *statusMenu;
int secondsPassed;
}
@property (nonatomic, retain) NSMenu *theMenu;
@property (nonatomic, retain) NSStatusItem *statusItem;
- (void)updateLabel:(id)sender;
@implementation StatusItemController
@synthesize theMenu;
@synthesize statusItem;
- (id)init {
if ((self = [super init])) {
secondsPassed = 0;
NSStatusBar *bar = [NSStatusBar systemStatusBar];
statusItem = [bar statusItemWithLength:NSVariableStatusItemLength];
@clayallsopp
clayallsopp / new item alert.scpt
Created February 25, 2011 21:13
Sorts files added to folder into subfolder
property Docs : "Macintosh HD:Users:<YOUR NAME>:Downloads:Docs"
property Music : "Macintosh HD:Users:<YOUR NAME>:Downloads:Music"
property Videos : "Macintosh HD:Users:<YOUR NAME>:Downloads:Videos"
property Images : "Macintosh HD:Users:<YOUR NAME>:Downloads:Images"
property Profiles : "Macintosh HD:Users:<YOUR NAME>:Downloads:iPhone:Profiles"
on adding folder items to thefolder after receiving theAddedItems
repeat with eachitem in theAddedItems
tell application "Finder"
if (name of eachitem ends with ".png") then
@clayallsopp
clayallsopp / addendum.scpt
Created February 27, 2011 23:16
Addition to gist
property Downloads : "Macintosh HD:Users:clayallsopp:Downloads:"
on run
tell application "Finder"
set d to Downloads as alias
set folder_contents to every file in d
repeat with eachitem in folder_contents
if (name of eachitem ends with ".html") then
move eachitem to folder WebDev
end if
@clayallsopp
clayallsopp / OfflineListActivity.java
Created March 6, 2011 17:11
Initial revision of OfflienListActivity
package com.clayallsopp.isawesome;
import android.app.Activity;
import android.os.Bundle;
public class OfflineListActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@clayallsopp
clayallsopp / Main.xml
Created March 6, 2011 17:13
Android layout XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
package com.clayallsopp.isawesome;
import android.app.ListActivity;
import android.os.Bundle;
public class OfflineListActivity extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@clayallsopp
clayallsopp / Main.xml
Created March 6, 2011 18:32
Part 4 XML
<!--
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
public class OfflineListActivity extends ListActivity {
String[] brocabs = {"Brotocol","Brobot","Theodore Broosevelt"};
ArrayList<String> brocabList = new ArrayList<String>(Arrays.asList(brocabs));
...
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// EDIT: Shoutout to Cyril Mottier for pointing out that this setContentView isn't necessary
// "When using a ListActivity, Android will automatically creates a ListView that fills the screen."
// setContentView(R.layout.main);
setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,brocabList));
}