Skip to content

Instantly share code, notes, and snippets.

@Paanini
Paanini / Shorten Links
Last active October 3, 2021 12:49
Google Apps Script to shorten all URLs in a doc using Bit.ly
@chrismdp
chrismdp / http
Last active May 5, 2021 18:54
Simple http server in ruby, that ensures there's no browser caching. For serving static files in development. I copy this into my ~/bin directory.
#!/usr/bin/env ruby
require 'webrick'
class NonCachingFileHandler < WEBrick::HTTPServlet::FileHandler
def prevent_caching(res)
res['ETag'] = nil
res['Last-Modified'] = Time.now + 100**4
res['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'
res['Pragma'] = 'no-cache'
res['Expires'] = Time.now - 100**4
@jstarrdewar
jstarrdewar / http
Created September 30, 2012 00:36
Convenient way to launch WEBrick to serve the current directory and prevent caching.
#!/usr/bin/env ruby
require 'webrick'
class NonCachingFileHandler < WEBrick::HTTPServlet::FileHandler
def prevent_caching(res)
res['ETag'] = nil
res['Last-Modified'] = Time.now + 100**4
res['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'
res['Pragma'] = 'no-cache'
res['Expires'] = Time.now - 100**4