Skip to content

Instantly share code, notes, and snippets.

View moorage's full-sized avatar

Matthew Moore moorage

View GitHub Profile
@moorage
moorage / email-sanitizer.go
Last active December 18, 2015 23:29
Have you ever needed to clean email addresses out of a file (like a SQL Dump) so that you don't accidentally email people in it? This script does exactly that! It turns all email addresses in the file into developers+EMAILADDRESS@example.com
package main
import (
"bufio"
"os"
"fmt"
"flag"
"regexp"
"strings"
"log"
@moorage
moorage / Gemfile4.0.rb
Last active December 19, 2015 14:19
Raw Gemfile from running 'rails new NEWAPP' with Rails 4.0 + Ruby 2.0
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
@moorage
moorage / Gemfile4.0Upgrade.rb
Created July 10, 2013 17:27
Cinchro Gemfile after 4.0 Upgrade
source 'https://rubygems.org'
ruby '2.0.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
@moorage
moorage / scaffolded_users_controller_rails4.rb
Created July 10, 2013 17:37
Controller output of rails g scaffold user name:string admin:boolean
class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
# GET /users
# GET /users.json
def index
@users = User.all
end
# GET /users/1
import "code.google.com/p/go.net/html"
func innerHtml(n *html.Node) string {
if (n == nil) {
return ""
}
result := ""
if n.Type == html.TextNode {
result = result + strings.TrimSpace(n.Data)
@moorage
moorage / 01.png
Last active April 1, 2020 01:41
How to add libmysqlclient.a to your Mac OS X App
01.png
@moorage
moorage / collect-css-classnames.js
Created April 4, 2014 00:44
How to parse all custom class names from bootstrap (or any stylesheet file) using nodejs with the css-parse package.
var fs = require('fs')
, read = fs.readFileSync
, css_parse = require('css-parse');
var parsedCss = css_parse(read("./path/to/bootstrap.min.css", 'utf8'));
var collectedClassnames = {}
for (var i = 0; i < parsedCss.stylesheet.rules.length; ++i) {
var rule = output_obj.stylesheet.rules[i];
@moorage
moorage / rails-scaffold-to-bootstrap-commands.md
Last active July 26, 2023 01:27
Rails Scaffolding to Bootstrap Forms: Find And Replace All Commands (e.g. for TextMate)

Index Pages

Change the H1

  • Find (regex):
    <h1>Listing (.*?)</h1>
  • Replace:
    <% content_for :page_title do %>
    $1s -
    <% end %>
    <div class="container">
    <div class="page-header">
@moorage
moorage / bash_profile
Created December 13, 2014 21:42
rvm and git and directory in bash_profile
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
### BEGIN: history bash shell useful settings ###
export HISTCONTROL=ignoredups # Ignores dupes in the history
shopt -s checkwinsize # After each command, checks the windows size and changes lines and columns
@moorage
moorage / opencv-xphoto-howto.md
Last active March 8, 2019 17:01
How I built xphoto module into opencv-3.0.0