Skip to content

Instantly share code, notes, and snippets.

View jefflarkin's full-sized avatar
🙃
Happy

Jeff Larkin jefflarkin

🙃
Happy
View GitHub Profile
@jefflarkin
jefflarkin / gist:658822
Created November 1, 2010 20:37
A quick-and-dirty way to get the memory usage of the current process in Linux. Read /proc/self/status. The line VmHWM will tell you the memory highwater mark (max used) and VmRSS will give you the current memory usage.
:) cat /proc/self/status
Name: cat
State: R (running)
SleepAVG: 89%
Tgid: 13668
Pid: 13668
PPid: 24697
TracerPid: 0
Uid: <removed>
Gid: <removed>
@jefflarkin
jefflarkin / gist:518961
Created August 11, 2010 13:19
My Favorite BASH Trick
$ make foo
...
$ ^foo^bar
make bar
# Sanitizing/Escaping HTML in the view is inefficient because it
# happens every time the view is rendered. This module forces
# text and string fields to be sanitized every time they are
# modified and saved to the database.
module Sanitizer
def sanitize_fields
columns = self.class.columns_hash
changes.each do |key,value|
if columns[key].type == :text
Sanitize.clean! value[1], Sanitize::Config::TEXTAREA
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test</title>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/reset/reset-min.css"/>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/fonts/fonts-min.css"/>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/base/base-min.css"/>
<style media="all" type="text/css">
html, body {
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test</title>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/reset/reset-min.css"/>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/fonts/fonts-min.css"/>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/base/base-min.css"/>
<style media="all" type="text/css">
#admin {
http://chart.apis.google.com/chart?cht=lc&chs=400x250&chd=t:24.4,28.1,25.6,24.3|26,26&chds=23.0,30.0&chco=ff0000,0000ff&chxt=y&chxr=0,23,30&chdl=Economy|Average&chf=bg,lg,90,888888,0.5,dddddd,0&chxs=0,ffffff&chma=25,25,25,25
@jefflarkin
jefflarkin / JQuery Sortable Searialize
Created February 7, 2009 22:01
Sample code using JQuery Sortable lists. I've fixed my mistake, the code below should now work.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css">
#sortable ul {
list-style: none;
display: inline;
padding: 0;
margin-left: 0;