Skip to content

Instantly share code, notes, and snippets.

View sintaxi's full-sized avatar
🔥
GSD

Brock Whitten sintaxi

🔥
GSD
View GitHub Profile
@jorgepedret
jorgepedret / sitemap.xml.jade
Created October 25, 2013 19:02
Recursive function to create dynamic sitemap of your website in Harp using Jade
- var paths = [], files = []; function recursiveTree(obj) { if (typeof obj == "object" && !obj.length) { for (item in obj) { if (item === "contents") { recursiveTree(obj[item]); } else if (item != "data") { paths.push(item); recursiveTree(obj[item]); paths.splice(paths.length-1, 1); } } } else if (typeof obj == "object") { for (i in obj) { var file = obj[i]; if (/(\.html$)/.test(file)) { paths.push(file); files.push("/" + paths.join("/")); paths.splice(paths.length-1, 1); } } } }; recursiveTree(public);
xml
urlset(xmlns="http://www.sitemaps.org/schemas/sitemap/0.9")
- for(i in files) {
url
loc= files[i]
priority 0.5
- }
@brianleroux
brianleroux / harp-mod-request.md
Created October 12, 2013 20:53
fantasizing about some future integrations. - bringing harp some awareness of smart directories to build concat/min into convention - browserify for harp would be sweet - topcoatify does not yet exist but increasingly we something like it should exist - next www can just 'disappear' as that it becomes a build artifact
|- node_modules/
|- src/
|   |
|   |- index.js/ <----------- uses browserify so anything in node_modules is game for require()
|   |  |- index.js
|   |  '- foo.coffee
|   |
|   |- index.css/ <---------- uses topcoatify so anything in node_modules is game. how import/etc works needs consideration

| | |- index.css

@kennethormandy
kennethormandy / hb-snippet-variable-example.md
Last active February 26, 2019 16:57
A quick example Harp app that uses the correct title for your blog in the correct place.

A quick example Harp app that uses the correct title for your blog in the correct place.

The App

app/
  |- _harp.json
  |- _layout.ejs
  |- index.ejs
  |+ posts/
      |- _data.json
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Stripe Getting Started Form</title>
<!-- The required Stripe lib -->
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<!-- jQuery is used only for this example; it isn't required to use Stripe -->

Build your own private, encrypted, open-source Dropbox-esque sync folder

Prerequisites:

  • One or more clients running a UNIX-like OS. Examples are given for Ubuntu 12.04 LTS, although all software components are available for other platforms as well (e.g. OS X). YMMV
  • A cheap Ubuntu 12.04 VPS with storage. I recommend Backupsy, they offer 250GB storage for $5/month. Ask Google for coupon codes.

Software components used:

  • Unison for file synchronization
  • EncFS for folder encryption
var http = require('http');
var timeInterval = 20; //ms
var maxOutstandingRequests = 10;
var successCount = 0;
var outstandingRequests = 0;
var options = {
hostname: 'www.google.com'
@tima
tima / testrsync.yml
Created May 17, 2013 23:28
A playbook for testing of ansible-rsync
---
-
hosts: remote_host
gather_facts: no
name: "Testing synchronize"
vars:
start_time: "{{ lookup('pipe','date') }}"
test_files:
- test1
- test2
@SlexAxton
SlexAxton / .zshrc
Last active April 25, 2023 03:57
My gif workflow
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
@jaredhirsch
jaredhirsch / gist:4971859
Created February 17, 2013 15:19
all about ETags

ETags: a pretty sweet feature of HTTP 1.1

HTTP caching review

HTTP provides two ways for servers to control client-side caching of page components:

  • freshness may be based on a date or a token whose meaning is app-specific
  • whether or not the client needs to confirm the cached version is up-to-date with the server

This breaks down as follows:

  • Cache locally and don't check before using.
@jaredhirsch
jaredhirsch / gist:4963424
Last active March 19, 2021 08:54
ETags & If-None-Match headers: a dialogue

ETags & If-None-Match headers: a dialogue

1st request.

browser: can haz foo?

GET /foo HTTP/1.1

1st response.