Skip to content

Instantly share code, notes, and snippets.

@zpao
zpao / code_highlight_lines.rb
Created May 10, 2013 20:19
Highlight specific lines of code with Markdown + Jekyll + Redcarpet
# Replace Jekyll's handling of the Redcarpet code_block (which already adds
# support for highlighting, but needs support for the very non-standard
# "code fences with line highlights" extension).
# Since this is currently depending on Redcarpet to cooperate, we are going to
# be naive, and only allow line highlighting when a language is specified. If
# you don't want any syntax highlighting but want to highlight lines, then you
# need to specify text as your language (or it will break), like:
# ```text{4}
module Jekyll
# HG changeset patch
# Parent 18542ed8614b337f29235d846133d15be1f6f065
# User Paul O’Shannessy <[email protected]>
diff --git a/browser/base/content/browser-sets.inc b/browser/base/content/browser-sets.inc
--- a/browser/base/content/browser-sets.inc
+++ b/browser/base/content/browser-sets.inc
@@ -68,16 +68,17 @@
<command id="cmd_pageSetup" oncommand="PrintUtils.showPageSetup();"/>
<command id="cmd_print" oncommand="PrintUtils.print();"/>
@zpao
zpao / requests.js
Created May 27, 2012 01:24
simple node script to check on your review queue
require("request");
var bz = require("bz");
var bugzilla = bz.createClient();
function getRequests(email) {
bugzilla.searchBugs({"flag.requestee": email}, function(err, bugs) {
bugs.forEach(function(bug) {
console.log(formatBugOutput(bug));
})
@zpao
zpao / quake.js
Created May 27, 2012 01:07
quick little node script to show growl alerts when the ground shakes
var request = require("request");
var csv = require("csv");
var growl = require("growl");
const URL = "http://earthquake.usgs.gov/earthquakes/catalogs/eqs1hour-M0.txt";
const INTERVAL = 20000;
// this is what the keys map to
var keys = ['Src', 'Eqid', 'Version', 'Datetime', 'Lat', 'Lon', 'Magnitude', 'Depth', 'NST', 'Region'];
var quakes = {};
@zpao
zpao / t2j.coffee
Created May 27, 2012 00:55
Script I wrote to import my Tumblr to Jekyll
#!/usr/bin/env coffee
request = require "request"
fs = require "fs"
TARGET_DIR = "./_posts"
PHOTO_SIZE = 1280
url = "http://blog.zpao.com/api/read?format=json&filter=none&num=50"
@zpao
zpao / freeze.js
Created May 27, 2012 00:11
Exploring prototypes & Object.freeze
function makeObj(freeze) {
var o = {
foo: "bar",
doit: function() {
console.log(this.foo);
}
}
if (freeze)
Object.freeze(o);
@zpao
zpao / ZAppDelegate.m
Created March 16, 2012 06:42
Xcode generates code with excellent whitespace...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.mainViewController = [[ZMainViewController alloc] initWithNibName:@"ZMainViewController_iPhone" bundle:nil];
} else {
self.mainViewController = [[ZMainViewController alloc] initWithNibName:@"ZMainViewController_iPad" bundle:nil];
}
self.window.rootViewController = self.mainViewController;
@zpao
zpao / gist:1665805
Created January 23, 2012 22:13
patch to get v8monkey building (but not working)
diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp
index afa2125..2afdbb8 100644
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -7230,7 +7230,6 @@ dumpValue(const Value &v)
fprintf(stderr, "false");
} else if (v.isMagic()) {
fprintf(stderr, "<invalid");
-#ifdef DEBUG
switch (v.whyMagic()) {
function datediff(aDate1, aDate2) {
var diff = Math.abs(aDate2 - aDate1);
var milliseconds = diff % 1000;
var seconds = Math.floor(diff / 1000 % 60);
var minutes = Math.floor(diff / (1000 * 60) % 60);
var hours = Math.floor(diff / (1000 * 60 * 60) % 24);
var days = Math.floor(diff / (1000 * 60 * 60 * 24) % 365);
return [
diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp
index afa2125..2afdbb8 100644
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -7230,7 +7230,6 @@ dumpValue(const Value &v)
fprintf(stderr, "false");
} else if (v.isMagic()) {
fprintf(stderr, "<invalid");
-#ifdef DEBUG
switch (v.whyMagic()) {