Instantly share code, notes, and snippets.

View coffee.java
Coffee coffee = new Coffee();
if(coffee.Empty) {
coffee.Refill();
}
coffee.Drink();
View BufferClipboardUrl.py
#!/usr/bin/env python
# Coded poorly by Brett Kelly
# http://nerdgap.com
# @inkedmn
# -*- coding: utf-8 -*-
import urllib2
import urllib
import re
View NewMarkdownFile.applescript
property targetDir : "/Users/bkelly/Dropbox/Notes/"
property editorApp : "/Applications/Byword.app"
on getNewFileName()
set fileName to (text returned of (display dialog "Enter the filename with extension" default answer "Untitled-1.md"))
return fileName
end getNewFileName
tell application "Byword"
set fname to my getNewFileName()
View get-two-ps.php
<?php
function get_two_paragraphs(){
global $post;
$str = wpautop( get_the_content() );
$psToGrab = 2; // number of paragraphs to get
$maxFirstParaLength = 200; // character max in first paragraph
$matches = array(); // matching elements will go here
$pattern = '%<p[^>]*>(.*?)</p>%i'; // match what's between all <p> tags
preg_match_all($pattern, $str, $matches); // do the regex match
View get-fisrt-paragraph.php
<?php
/**
* Get first paragraph from a WordPress post. Use inside the Loop.
*
* @return string
*/
function get_first_paragraph(){
global $post;
$str = wpautop( get_the_content() );
View md2scrivener.py
#!/usr/bin/env python
import re, sys
input = '%clipboard'
r = re.compile("!\[\]\(images\/([^.]+).png\)")
m = r.match(input)
if m:
outp = "<$img:%s>" % m.groups()[0]
else:
View post.md

I'm a blog post

I have Markdown syntax like bold

Can you diff me?

I have a new line of text with an image...

View NewMeeting.applescript
set myNotebook to "@Inbox"
set myTags to {"to_process"}
set myTitle to "Meeting Notes with "
set myContent to ""
tell application "Evernote"
set myNote to create note title myTitle with text myContent notebook myNotebook tags myTags
delay (1) -- give the note a sec to save
open note window with myNote
end tell
View foo.applescript
tell application "Evernote"
set myNote to selection
try
set myUrl to (source URL of item 1 of myNote)
tell application "System Events"
open location myUrl
end tell
on error
-- real programmers would put something here
end try