Skip to content

Instantly share code, notes, and snippets.

@killercup
killercup / gist:4045091
Created November 9, 2012 10:41
HTML5 AppCache: SwapCache
window.applicationCache.addEventListener('updateready', function(e) {
if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
// Browser downloaded a new app cache.
// Swap it in and reload the page to get the new hotness.
window.applicationCache.swapCache();
if (confirm('A new version of this site is available. Load it?')) {
window.location.reload();
}
} else {
// Manifest didn't changed. Nothing new to server.
@killercup
killercup / Instapaper.coffee
Created December 4, 2012 16:04
Instapaper xAuth API for client side JS
# # Instapaper API Class
#
# Instapaper xAuth API for client side JS. Depends on cross-domain requests.
#
# Reference: <http://www.instapaper.com/api/full>
#
# xAuth documentation from Twitter: <https://dev.twitter.com/docs/oauth/xauth>
#
# With help from <https://gist.github.com/447636>
#
@killercup
killercup / Rakefile
Last active December 12, 2015 10:49
Simple Rake file for compiling and deploying a Jekyll site along with CoffeeScript and Compass. Expects the following commands to be present: jekyll, coffee, compass, sleep, open
require 'yaml'
config_file = '_config.yml'
config = YAML.load_file(config_file)
class JekyllOutput
def self.compile
Process.spawn "jekyll --no-server --no-auto"
end
@killercup
killercup / MarkdownEditing.tmTheme
Last active December 14, 2015 09:28
See https://github.com/killercup/sublime-scheme-shiny <-- Slightly modified MarkdownEditing Theme for Textmate/SublimeText2. I think it looks good for SCSS, JS, HTML, CoffeeScript and Ruby. Also for Pygments: http://codepen.io/killercup/pen/BftmG
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>MarkdownEditing</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
@killercup
killercup / formtest.html
Last active December 14, 2015 19:08
Form Test: Create JS Form to POST cross-domain. You can take a local form, do stuff with it an then POST it to another domain using a newly created form element. This will of course not work with AJAX but change the actual window.location.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Form Test</title>
<script src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
<script>
jQuery(function($) {
$('form.original').live('submit', function(ev) {
@killercup
killercup / config.fish
Last active April 12, 2022 03:43
Server Config with fish, vim an tmux
# ~/.config/fish/config.fish
. ~/.config/fish/fish_prompt.fish
set fish_greeting '' # turn off greeting
function fish_title;end
alias vi 'vim'
@killercup
killercup / postgres2s3.sh
Last active December 18, 2015 00:09
Backup Postgres DB to S3 (app specific)
#! /bin/csh
##
# Backup Postgres and Avatars to S3
#
# Requires:
# - postgres with pg_dump
# - xz to compress
# - openssl to encrypt
# - pv for nice output (two progress bars, for sql dump and compress)
@killercup
killercup / newsyslog.conf
Last active September 30, 2019 03:21
FreeBSD logrotate via /etc/newsyslog.conf
/var/log/nginx-access.log 644 7 1024 * JC /var/run/nginx.pid 30
/var/log/nginx-error.log 644 7 1024 * JC /var/run/nginx.pid 30
/home/app/episodefever/shared/log/unicorn.stdout.log app:app 666 7 1024 * JC
/home/app/episodefever/shared/log/unicorn.stderr.log app:app 666 7 1024 * JC
/home/app/episodefever/shared/log/newrelic_agent.log app:app 666 7 1024 * JC
/home/app/episodefever/shared/log/production.log app:app 666 7 1024 * JC /usr/home/app/episodefever/shared/pids/unicorn.pid 30
/home/app/episodefever/shared/log/resque-pool.stdout.log app:app 666 7 1024 * JC /usr/home/app/episodefever/shared/pids/resque-pool.pid 30
/home/app/episodefever/shared/log/resque-pool.stderr.log 666 7 1024 * JC /usr/home/app/episodefever/shared/pids/resque-scheduler.pid 30
@killercup
killercup / config.fish
Last active December 18, 2015 02:59
My Fish Config
. ~/.config/fish/fish_prompt.fish
set fish_greeting '' # turn off greeting
alias vi 'vim'
alias o 'open'
alias wtf 'brew home'
alias pg 'ps aux | grep'
alias fuckthefinder 'sudo killall -KILL appleeventsd'
alias fuckdns 'sudo killall -HUP mDNSResponder'
/**
* scrollTop Module
*
* Just add `totop` as class or attribute to some element.
*
* This used to be plain jQuery, but we are cool now. Sadly, it
* still requires jQuery for the animation.
*
* This even works as a Facebook page, thanks to
* http://stackoverflow.com/a/8130267/1254484