Skip to content

Instantly share code, notes, and snippets.

{liftAll} = require "when/node"
{call} = require "when/generator"
{readFile, writeFile} = (liftAll require "fs")
marked = require "marked"
call ->
try
buffer = yield readFile "my-blog-post.md"
html = marked buffer.toString()
yield writeFile "my-blog-post.html", html
{readFile, writeFile} = require "fs"
marked = require "marked"
readFile "my-blog-post.md", (error, buffer) ->
unless error?
try
html = marked buffer.toString()
writeFile "my-blog-post.html", html, (error) ->
if error?
console.error error
{readFileSync, writeFileSync} = require "fs"
marked = require "marked"
try
markdown = (readFileSync "my-blog-post.md").toString()
html = marked markdown
writeFileSync "my-blog-post.html", html
catch error
console.error error
load_product_catalog = (url, frequency, callback) ->
data = {} # keep the data for the catalog
json = "" # keep the raw JSON
# load the product catalog, possibly from cache
# the browser will add the caching request headers for us
load = ->
request = new XMLHttpRequest()
request.open "GET", url, true
@dyoder
dyoder / license.txt
Created October 30, 2013 19:46
The Panda Strike License
The Panda Strike License
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
coffee> decodeURIComponent
[Function: decodeURIComponent]
coffee> `function decodeURIComponent(c) { console.log(c); }`
[Function: decodeURIComponent]
coffee> decodeURIComponent("foo")
'foo'
@dyoder
dyoder / blog.jade
Created October 9, 2013 08:54
Harp / Jade template for a blog summary page, automatically excepting anything before `<!-- more -->`
- function excerpt(markup) {
- return markup.split("<!-- more -->")[0]
- }
.blog.summary
ul
each post, slug in public.posts.data
li
h3 #{post.title}
p.byline
@dyoder
dyoder / gist:5179473
Created March 17, 2013 03:46
Demonstration of Node's support for chunked encoding.
http = require "http"
fs = require "fs"
app = (request,response) ->
n = 0
out = fs.createWriteStream "./test.png"
request.pipe out
request.on "data", (data) ->
console.log "CHUNK #{++n}: #{data.length} bytes"
request.on "end", ->
@dyoder
dyoder / fnotify.pl
Last active December 12, 2015 04:48 — forked from matthutchinson/fnotify.pl
Instructions and scripts for setting Up IRSSI so that it does native Apple notifications.
# todo: grap topic changes
use strict;
use vars qw($VERSION %IRSSI);
use Irssi;
$VERSION = '0.0.3';
%IRSSI = (
authors => 'Thorsten Leemhuis',
contact => 'fedora@leemhuis.info',
@dyoder
dyoder / Readme.md
Created December 6, 2012 00:59
Using terminal-notifier with irssi and SSH

These are adapted from Ben Browning's blog post for using irssi with growl. I just wanted to use the Apple Notification center or whatever it's called. Fortunately, there's a nice gem that allows you to trigger Apple notifications from the command line. The only trick was that NSApplication has a screwy way of parsing command-line arguments and so the terminal-notifier command was failing. I fixed this with a stupid hack of putting an asterisk in front of the message.

I figured I'd post this in case someone runs into the same problem.