Skip to content

Instantly share code, notes, and snippets.

bytesToSize = function (bytes, precision) {
var kilobyte = 1024;
var megabyte = kilobyte * 1024;
var gigabyte = megabyte * 1024;
var terabyte = gigabyte * 1024;
if ((bytes >= 0) && (bytes < kilobyte)) {
return bytes + ' B';
} else if ((bytes >= kilobyte) && (bytes < megabyte)) {
var SizePrefixes = ' KMGTPEZYXWVU';
GetHumanSize = function(size) {
if(size <= 0) return '0';
var t2 = Math.min(Math.round(Math.log(size)/Math.log(1024)), 12);
return (Math.round(size * 100 / Math.pow(1024, t2)) / 100) +
SizePrefixes.charAt(t2).replace(' ', '') + 'B';
}
@MWers
MWers / nginx.conf
Created November 7, 2013 18:39 — forked from Stanback/nginx.conf
server {
listen 80;
listen [::]:80;
server_name yourserver.com;
root /path/to/your/htdocs;
error_page 404 /404.html
index index.html;
@MWers
MWers / svn.md
Created November 7, 2013 18:53
SVN Presentation

svn update - full

Update all files in your workarea

$ svnupdateall
U    web/public/partners/premium_travel.cfm
U    web/public/premiumlanding/surf_travel_discounts.cfm
U    web/public/xml/inc_rep_data_tides.cfm
U web/public/xml/allspots.xml
@MWers
MWers / prerender.vcl
Created November 8, 2013 04:43
Example Varnish configuration for serving pre-rendered HTML from Javascript pages/apps using http://prerender.io/
#
# NOTE: Heroku/ELB domains resolve to multiple IP addresses and Varnish
# doesn't like this. The backend host must be a single IP address, a
# hostname that resolves to a single IP address, or a dynamically-
# generated director similar to the one described here:
#
# http://blog.cloudreach.co.uk/2013/01/varnish-and-autoscaling-love-story.html
#
backend prerender {
@MWers
MWers / prerender_varnish_node_generator.py
Created November 8, 2013 21:00
prerender.io Varnish node generator
import socket
domain = "prerender.herokuapp.com"
TEMPLATE_NODE = ''' {
.backend = {
.host = "%s";
.port = "80";
}
.weight = 1;
@MWers
MWers / winds_of_winter_excerpt.txt
Created March 27, 2014 21:17
Excerpt from the Winds of Winter
Excerpt from the Winds of Winter
January 27, 2013
MERCY
Titan_of_Braavos
She woke with a gasp, not knowing who she was, or where.
The smell of blood was heavy in her nostrils… or was that her nightmare, lingering? She had dreamed of wolves again, of running through some dark pine forest with a great pack at her hells, hard on the scent of prey.
@MWers
MWers / x-forwarded-for.cfm
Created April 4, 2014 04:16
Use X-Forwarded-For address if it exists, otherwise use cgi.remote_addr
<cfset req = GetHttpRequestData() />
<cfif structKeyExists(req.headers, "X-Forwarded-For")
AND Len(Trim(req.headers["X-Forwarded-For"])) GT 0>
<cfset ipAddress = req.headers["X-Forwarded-For"] />
<cfelse>
<cfset ipAddress = cgi.remote_addr />
</cfif>
@MWers
MWers / gist:8c89ed145b56392b62be
Created July 17, 2014 18:20
grads server packages
Red Hat Enterprise Linux Server release 5.6 (Tikanga)
Deployment_Guide-en-US.noarch 5.2-11 installed
GConf2.i386 2.14.0-9.el5 installed
GConf2.x86_64 2.14.0-9.el5 installed
GConf2-devel.i386 2.14.0-9.el5 installed
GConf2-devel.x86_64 2.14.0-9.el5 installed
ImageMagick.i386 6.2.8.0-4.el5_5.3 installed
ImageMagick.x86_64 6.2.8.0-4.el5_5.3 installed
MAKEDEV.x86_64 3.23-1.2 installed

This is a test

<cfset foo = "bar" />