Skip to content

Instantly share code, notes, and snippets.

View brettkelly's full-sized avatar

Brett Kelly brettkelly

View GitHub Profile
@brettkelly
brettkelly / DeleteAddressBookBirthdays.scpt
Created November 11, 2011 23:33
Delete Selected Birthdays from Address Book
(*
Brett Kelly wrote this.
http://nerdgap.com
*)
tell application "Address Book"
-- init our lists of stuff
set peeps to every person
set bdays to {}
set bdaynames to {}
@brettkelly
brettkelly / gist:1419008
Created December 1, 2011 18:59
norcross
select uniqueids from downloadkeys
where timestamp in
(select timestamp from downloadkeys order by timestamp desc limit 10)
order by timestamp desc
@brettkelly
brettkelly / EvernoteWordCount.scpt
Created December 15, 2011 18:48
Evernote Word Count for Selected Note
(* based almost entirely on Justin Lancy's script:
http://veritrope.com/code/evernote-get-plain-text-of-selected-note/
*)
tell application "Evernote"
set theSelection to selection
set theHTML to HTML content of (item 1 of theSelection)
set plainText to ¬
do shell script "echo " & quoted form of theHTML & space & "| textutil -convert txt -stdin -stdout"
set myWords to count of words in plainText
display dialog "Words: " & myWords with title "Word Count"
@brettkelly
brettkelly / InstallSendPdfToEvernote
Created February 15, 2012 18:19
Install the "Send PDF to Evernote" option in the Print > PDF menu
tell application "Finder"
try
set appPath to (path to application "Evernote" as text)
on error
display dialog "Couldn't find Evernote. Is it installed?"
end try
set printPath to (path to "dlib" from user domain as text) & "PDF Services"
make new alias at printPath to appPath with properties {name:"Send PDF to Evernote"}
end tell
def imageExists(url):
"""Checks to see if an image URL is actually real and returns a real image"""
goodMimes = ['image/png','image/jpg','image/jpeg','image/gif']
try:
h = httplib2.Http()
r,c = h.request(url,'GET')
return r['content-type'] in goodMimes
except:
return False
$(function(){
$('input[placeholder]').each(
function(){
var val = $(this).attr('placeholder');
$(this).attr('value',val);
}
);
});
@brettkelly
brettkelly / ECViewController.h
Created May 7, 2012 18:50
Adding IBOutlets for UI elements
#import <UIKit/UIKit.h>
@interface ECViewController : UIViewController
@property (strong, nonatomic) IBOutlet UILabel *usernameField;
@property (strong, nonatomic) IBOutlet UILabel *noteCountField;
@property (strong, nonatomic) IBOutlet UIButton *noteCountButton;
- (IBAction)retrieveUserNameAndNoteCount:(id)sender;
@brettkelly
brettkelly / ECViewController.m
Created May 7, 2012 21:25
Unmodified ECViewController.m
#import "ECViewController.h"
@interface ECViewController ()
@end
@implementation ECViewController
- (void)viewDidLoad
{
- (int)countAllNotesAndSetTextField:(EvernoteSession *)session
{
EvernoteNoteStore *noteStore = [EvernoteNoteStore noteStore];
[noteStore listNotebooksWithSuccess:^(NSArray *notebooks) {
__block int noteCount = 14;
for (EDAMNotebook *notebook in notebooks) {
if ([notebook guid]) {
@brettkelly
brettkelly / ECAppDelegate.m
Created May 15, 2012 22:58
An unmodified didFinishLaunchingWithOptions implementation, generated by Xcode
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ECViewController alloc] initWithNibName:@"ECViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}