Skip to content

Instantly share code, notes, and snippets.

View wezm's full-sized avatar

Wesley Moore wezm

View GitHub Profile
@wezm
wezm / README.md
Created May 1, 2015 03:48
Generate listing

Listing

How would you go about generating a page like this in Rails?

screenshot

Each of the letters at the top of the page is a link to #a, #b, etc. Above each row <a name="a"></a> tags need to be added for all the letters that occur between the previous row and this row.

Here is a sample array:

require 'active_support/core_ext/array'
items = ["African", "Ambient", "Asian", "Avant-garde", "Blues", "Breakbeat", "Caribbean", "Comedy", "Country", "Disco", "Downtempo", "Drum & Bass", "Easy listening", "Electro", "Electronic", "Folk", "Hardcore", "Hardstyle", "Hip hop", "House", "Industrial", "Jazz", "Jungle", "Latin", "Pop", "R&B", "Rock", "Soul", "Techno", "Trance"]
letters = ('a'..'z')
puts letters.to_a.map(&:upcase).join(' ')
last_letter = '`' # ` is the char before 'a'
items.in_groups_of(2).each do |group|
next_letter = group.compact.map { |item| item[0].downcase }.last
@wezm
wezm / private.xml
Last active August 29, 2015 14:23
Karabiner Slack Customisation
<?xml version="1.0"?>
<root>
<appdef>
<appname>SLACK</appname>
<equal>com.tinyspeck.slackmacgap</equal>
</appdef>
<item>
<name>Slack Customisation</name>
@wezm
wezm / .vimrc_windows
Created January 14, 2009 04:04
Dot Files for Windows/Cygwin
" Make Windows use my UNIX vimfiles
if has("win32")
set runtimepath=$HOME/.vim,$HOME/vimfiles,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/vimfiles/after
endif
let skip_loading_mswin=1
"let perl_fold = 1
let perl_include_pod = 1
let perl_extended_vars = 1
"set ttybuiltin
@wezm
wezm / xhtml1.0.html
Created January 14, 2009 09:45
XHTML 1.0 Strict Template for xhtmldoctype.com
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title></title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="script.js" type="text/javascript"></script>
</head>
<body>
@wezm
wezm / gist:47103
Created January 14, 2009 21:45
XHTML 1.0 Transitional Template for xhtmldoctype.com
<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title></title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="script.js" type="text/javascript"></script>
</head>
<body>
@wezm
wezm / gist:47104
Created January 14, 2009 21:45
XHTML 1.0 Frameset Template for xhtmldoctype.com
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title></title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="script.js" type="text/javascript"></script>
</head>
<frameset cols="25%, 75%">
@wezm
wezm / gist:47105
Created January 14, 2009 21:45
XHTML 1.1 Template for xhtmldoctype.com
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title></title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="script.js" type="text/javascript"></script>
</head>
<body>
#!/bin/sh
# passwd_login should be set to the password
curl \
-H 'Referer: http://lesswrong.local:8000/a/1i/about_lesswrong/' \
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
-H 'Accept-Encoding: gzip,deflate' \
--form-string 'rem=off&passwd_login=www&user_login=wmoore&op=login-main&uh=&_=' \
-o lesswrong_login.txt.gz 'http://lesswrong.local:8000/api/login'
@wezm
wezm / README
Created March 26, 2009 03:44
A pair of scripts to notify via Growl when a Skype user comes online
I turned off most of Skype's pesky notifications. This pair of scripts allows
you to be notified when a particular user becomes available. Since it is
separate from the Skype application its settings can be customised individually
in the Growl preference pane. I have mine set to play a sound and show the
notification as a bezel.
It probably isn't necessary for this to be two seperate scripts. At some point
I should look in to consolidating them into one AppleScript or one Ruby scirpt.
Probably the former.