Skip to content

Instantly share code, notes, and snippets.

View brettkelly's full-sized avatar

Brett Kelly brettkelly

View GitHub Profile
@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"
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;
}
@brettkelly
brettkelly / ECAppDelegate.m
Created May 15, 2012 23:38
handleOpenURL implementation
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
// delegate to the Evernote session singleton
if ([[EvernoteSession sharedSession] handleOpenURL:url]) {
return YES;
}
return NO;
}
@brettkelly
brettkelly / ECAppDelegate.m
Created May 15, 2012 23:00
ECAppDelegate.m modified to include Evernote OAuth configuration and initialization
- (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];
// Set up Evernote OAuth
@brettkelly
brettkelly / ECAppDelegate.m
Created May 15, 2012 23:03
Including EvernoteSession.h
#import "ECAppDelegate.h"
#import "ECViewController.h"
#import "EvernoteSession.h"