Skip to content

Instantly share code, notes, and snippets.

View skiyo's full-sized avatar

LiQiang Dong skiyo

  • Baidu
  • Beijing, China
View GitHub Profile
@skiyo
skiyo / document.ready.js
Last active August 29, 2015 13:56
document.ready
(function () {
var ie = !!(window.attachEvent && !window.opera);
var wk = /webkit//(/d+)/i.test(navigator.userAgent) && (RegExp.$1 < 525);
var fn = [];
var run = function () {
for (var i = 0; i < fn.length; i++) fn[i]();
};
var d = document;
d.ready = function (f) {
if (!ie && !wk && d.addEventListener)
@skiyo
skiyo / gist:3162852
Created July 23, 2012 09:49
NSUserNotificationCenter
//Initalize new notification
NSUserNotification *notification = [[NSUserNotification alloc] init];
//Set the title of the notification
[notification setTitle:@"My Title"];
//Set the text of the notification
[notification setInformativeText:@"My Text"];
//Set the time and date on which the nofication will be deliverd (for example 20 secons later than the current date and time)
[notification setDeliveryDate:[NSDate dateWithTimeInterval:20 sinceDate:[NSDate date]]];
//Set the sound, this can be either nil for no sound, NSUserNotificationDefaultSoundName for the default sound (tri-tone) and a string of a .caf file that is in the bundle (filname and extension)
[notification setSoundName:NSUserNotificationDefaultSoundName];