Skip to content

Instantly share code, notes, and snippets.

View niallsmart's full-sized avatar

Niall Smart niallsmart

View GitHub Profile
@niallsmart
niallsmart / Craigslist extract
Created February 13, 2011 19:24
Simple JQuery snippet to extract Craigslist search results to CSV
$("p.row").each(function(index) {
var csv = $(this).text().trim().replace(/[ \r\n\t]+/g, ' ');
csv = csv.replace(/ pic$/, "\tpic")
csv = csv.replace(/ pic img$/, "\tpic img")
csv = csv.replace(/^([^-]*)- /, "$1\t")
csv = csv.replace(/ - ([($])/, "\t$1")
//csv = csv.replace(/(\$[0-9]+) ([^(])/, "$1\t\t$2")
@niallsmart
niallsmart / productivity.cron
Created February 20, 2011 18:34
Growl on on the half hour
# cronjob to get a Growl notification every half hour.
#
# Get growl & growlnotify from http://growl.info/ then
# install this cronjob using "crontab -e"
#
0,30 * * * * /usr/local/bin/growlnotify -m "The time is now `date +\%H:\%M`" -a "iCal"
@niallsmart
niallsmart / makeUri.js
Created July 8, 2011 23:01
makeUri.js - create a URI from an object specification
// makeURI 1.2.2 - create a URI from an object specification; compatible with
// parseURI (http://blog.stevenlevithan.com/archives/parseuri)
// (c) Niall Smart <niallsmart.com>
// MIT License
function makeUri(u) {
var uri = "";
if (u.protocol) {
uri += u.protocol + "://";
@niallsmart
niallsmart / use-strict.sed
Created September 18, 2011 18:37
Sed script to add "use strict"; to the top of JavaScript files
#
# Sed script to add "use strict"; to the top of files that don't
# already have it there.
#
# use like this: find . -name \*.js | xargs -n 1 sed -f make-strict.sed -i ''
#
1 { s/use strict/&/
t
i\
"use strict";
@niallsmart
niallsmart / hack.sh
Created March 31, 2012 22:13 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@niallsmart
niallsmart / st2-haml-element-hyphen.diff
Last active December 20, 2015 14:59
Fix for ST2 Ruby HAML formatting – allow hyphens in element tag names.
diff --git a/Ruby Haml.tmLanguage.orig b/Ruby Haml.tmLanguage
index 88d43f2..8a2e90c 100644
--- a/Ruby Haml.tmLanguage.orig
+++ b/Ruby Haml.tmLanguage
@@ -70,7 +70,7 @@
</dict>
<dict>
<key>begin</key>
- <string>^\s*(?:((%)([\w:]+))|(?=\.|#))</string>
+ <string>^\s*(?:((%)([\w:-]+))|(?=\.|#))</string>
@niallsmart
niallsmart / LICENSE
Last active December 20, 2015 17:19
ngProviderController implements controller resolution using $injector.
The MIT License
Copyright (c) 2013 Niall Smart
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@niallsmart
niallsmart / linebreak.rb
Created October 8, 2013 01:50
Axlsx line break
require 'axlsx'
Axlsx::Package.new do |package|
workbook = package.workbook
workbook.add_worksheet do |sheet|
wrap = workbook.styles.add_style alignment: {wrap_text: true}
sheet.add_row ["Foo\r\nBar", "Foo\rBar", "Foo\nBar", "Foo\n\r\nBar"], style: wrap
end
package.serialize "linebreak.xlsx"
module Honeybadger
IGNORED_NOT_FOUND_PATHS = %w{
/apple-touch-icon-72x72.png
/apple-touch-icon-72x72-precomposed.png
/apple-touch-icon-114x114.png
/apple-touch-icon-114x114-precomposed.png
/apple-touch-icon-120x120.png
/apple-touch-icon-120x120-precomposed.png
/apple-touch-icon-152x152.png
@niallsmart
niallsmart / compare_assets.sh
Last active August 29, 2015 13:57
Compare web/app vs app/assets
DIFF_FLAGS=-qwc
(cd web/app; find . -name *.coffee) | while read file; do
diff $DIFF_FLAGS web/app/$file app/assets/javascripts/$file
done
(cd web/app; find . -name *.scss) | grep -v vendor | while read file; do
diff $DIFF_FLAGS web/app/$file app/assets/stylesheets/$file
done