Skip to content

Instantly share code, notes, and snippets.

View fannheyward's full-sized avatar
🎯
Slow to response

Heyward Fann fannheyward

🎯
Slow to response
View GitHub Profile
@fannheyward
fannheyward / statusline of vim
Created April 9, 2011 09:16
statusline for vim, via newsmth.
set laststatus=2 " always show the status line
let statusHead ="%-.50f\ %h%m%r"
let statusBreakPoint ="%<"
let statusSeparator ="|"
let statusFileType ="%{((&ft\ ==\ \"help\"\ \|\|\ &ft\ ==\ \"\")?\"\":\"[\".&ft.\"]\")}"
let statusFileFormat ="[%{(&ff\ ==\ \"unix\")?\"u\":\"d\"}]"
let statusAscii ="\{%b:0x%B\}"
let statusCwd ="%-.50{getcwd()}"
let statusBody =statusFileType.statusFileFormat.statusSeparator.statusAscii.statusSeparator."\ ".statusBreakPoint.statusCwd
let statusEncoding ="[%{(&fenc\ ==\ \"\"?&enc:&fenc).(&bomb?\",BOM\":\"\")}]"
@fannheyward
fannheyward / longURL.scpt for Quicksilver
Created May 10, 2011 03:15
longURl action for Quicksilver, powered by http://longurl.org
using terms from application "Quicksilver"
on process text _text
try
set the _encodedUrl to _urlEncode(_text) of me
set curlCMD to "curl --stderr /dev/null \"http://api.longurl.org/v2/expand?url=" & _encodedUrl & "\""
tell me to set _longURL to (do shell script curlCMD)
set AppleScript's text item delimiters to "CDATA["
@fannheyward
fannheyward / gist:1113426
Created July 29, 2011 08:08
Show/hide keyboard
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.35];
if (self.isFlipped) {
[self.textView resignFirstResponder];
self.keyboard.transform = CGAffineTransformMakeRotation(0);
self.showHideButton.transform = CGAffineTransformMakeRotation(0);
} else {
[self.textView becomeFirstResponder];
self.keyboard.transform = CGAffineTransformMakeRotation(M_PI);
@fannheyward
fannheyward / iPhone Done like button
Created August 30, 2011 02:11
iPhone Done like button
doneButton.frame = CGRectMake(5, 27, 48, 30);
doneButton.backgroundColor = [UIColor clearColor];
UIImage *buttonImageNormal = [UIImage imageNamed:@"doneButton.png"];
UIImage *stretchableButtonImageNormal = [buttonImageNormal stretchableImageWithLeftCapWidth:5 topCapHeight:0];
[doneButton setBackgroundImage:stretchableButtonImageNormal forState:UIControlStateNormal];
@fannheyward
fannheyward / iChatGrowl.applescript
Created September 5, 2011 08:01
Save this AppleScript to “~/Library/Scripts/iChat/Growl.applescript”. via http://amccloud.com/lion-ichat-growl-notifications-50108
using terms from application "iChat"
on message received message from theBuddy for textChat
set whoDidIt to full name of theBuddy
set buddyIcon to image of theBuddy
tell application "System Events"
set frontApp to name of first application process whose frontmost is true
end tell
tell application frontApp
set window_name to name of front window
end tell
property growlAppName : "Growl iChat"
property notificationNames : {"Buddy Became Available", ¬
"Buddy Became Unavailable", ¬
"Message Received", ¬
"Completed File Transfer"}
property defaultNotificationNames : {"Buddy Became Available", ¬
"Buddy Became Unavailable", ¬
"Message Received", ¬
"Completed File Transfer"}
// DLog is almost a drop-in replacement for NSLog
// DLog();
// DLog(@"here");
// DLog(@"value: %d", x);
// Unfortunately this doesn't work DLog(aStringVariable); you have to do this instead DLog(@"%@", aStringVariable);
#ifdef DEBUG
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
# define DLog(...)
#endif
@fannheyward
fannheyward / download video from 3g.sina
Created November 29, 2011 02:55
从 3g.sina 下载视频。
javascript:(function(){window.open('http://3g.sina.com.cn/3g/site/proc/video/show_convert_video.php?url='+encodeURIComponent(location.href)+'&vt=4');})()
@fannheyward
fannheyward / RSSOutHandler.py
Created November 30, 2011 07:42
Picky RSSOutHandler
class RSSOutHandler(webapp.RequestHandler):
def get(self):
site_domain = Datum.get('site_domain')
site_name = Datum.get('site_name')
site_author = Datum.get('site_author')
site_slogan = Datum.get('site_slogan')
site_analytics = Datum.get('site_analytics')
site_updated = Datum.get('site_updated')
if site_updated is None:
site_updated = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
@fannheyward
fannheyward / picky_rss_out.xml
Created November 30, 2011 07:48
Picky RSS export out.xml
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{{ site_name }}</title>
<subtitle>{{ site_slogan }}</subtitle>
<link rel="alternate" type="text/html" href="http://{{ site_domain }}/" />
<link rel="self" type="application/atom+xml" href="{{ feed_url }}" />
<id>http://{{ site_domain }}/</id>
<updated>{{ site_updated }}</updated>
<rights>Copyright © 2009-2010, {{ site_author }}</rights>
{% for article in articles %}