Skip to content

Instantly share code, notes, and snippets.

View rietta's full-sized avatar
🏠
Working from home

Frank Rietta rietta

🏠
Working from home
View GitHub Profile
@rietta
rietta / gist:2761988
Created May 21, 2012 11:50
Get list of IP addresses that have failed to login to SSH from the /var/log/auth.log SSHD log.
A method for getting a list of IP addresses that failed to login to SSH from the /var/log/auth.log.
For just failed root login attempts:
grep "Failed password for root from" /var/log/auth.log | cut -d " " -f 11 | sort | uniq -c
For invalid user failed login attempts:
grep "Failed password for invalid user" /var/log/auth.log | cut -d " " -f 13 | sort | uniq -c
@rietta
rietta / gist:2763045
Created May 21, 2012 16:05
Ubuntu Linux language locale error
When got:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "utf-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
@rietta
rietta / gist:3036132
Created July 2, 2012 22:28
Spree on Ubuntu (with PostgreSQL) ActiveRecord::ConnectionNotEstablished
RAILS_ENV=development rails c
/home/railsapps/.rvm/gems/ruby-1.9.2-p290@spree_demo/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in `retrieve_connection': ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
from /home/railsapps/.rvm/gems/ruby-1.9.2-p290@spree_demo/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
from /home/railsapps/.rvm/gems/ruby-1.9.2-p290@spree_demo/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
from /home/railsapps/.rvm/gems/ruby-1.9.2-p290@spree_demo/gems/activerecord-3.2.3/lib/active_record/model_schema.rb:228:in `columns'
from /home/railsapps/.rvm/gems/ruby-1.9.2-p290@spree_demo/gems/activerecord-3.2.3/lib/active_record/model_schema.rb:248:in `column_names'
from /home/railsapps/.rvm/gems/ruby-1.9.2-p290@spree_demo/gems/rd_searchlogic-3.0.1/lib/searchlogic/n
@rietta
rietta / random_hash.sh
Created September 5, 2012 17:01
Easy command line random hash generator for Mac OS X, Linux, and FreeBSD.
#!/bin/sh
head -n 4096 /dev/urandom | openssl sha1
@rietta
rietta / domain_validator.rb
Created October 4, 2012 20:51
Rails 3 Bare Domain Validator
#
# Domain Validator by Frank Rietta
# (C) 2012 Rietta Inc. All Rights Reserved.
# Licensed under terms of the BSD License.
#
# To use in a validation, add something like this to your model:
#
# validates :name, :domain => true
#
class DomainValidator < ActiveModel::EachValidator
@rietta
rietta / example_deploy.rb
Created October 9, 2012 15:35
Capistrano Pre-compile Assets Locally and Deploy through Git
#
# One solution for deploying assets to production servers through git while
# precompiling the assets on the local development system.
#
# By Frank Rietta
# Copyright 2012 Rietta Inc. All Rights Reserved.
# Licensed as open source under terms of the BSD license.
#
# The script switches to the deploy branch, syncs it down, merges the changes from master, precompiles the
# assets and then pushes those to the deploy branch on remote so that the capistrano script can deploy the
@rietta
rietta / gist:3924671
Created October 20, 2012 20:25
Rails fails in JRuby out of box on Mac OS X (with Stack Trace)
My first attempts at running a new Rails application on JRuby is completely failing. Through the process of elimination, I have traced the source of the problem down to the asset pipeline in Rails 3.2. Though I do not know how to fix this:
stat.st_gid unsupported or native support failed to load
org/jruby/RubyFileStat.java:432:in `gid'
This is on October 20, 2012. Using jruby 1.6.7 and Rails 3.2.8 out of the box with the gems as published on this date.
Here are the steps to reproduce - again, no custom code on my part.
Using Mac OS X Mountain Lion, I installed the following:
@rietta
rietta / us_states_adj.txt
Created November 19, 2012 18:17
United States' State Adjacency Lists
# Author Gregg Lind
# License: Public Domain. I would love to hear about any projects you use if it for though!
# Original location: http://writeonly.wordpress.com/2009/03/20/adjacency-list-of-states-of-the-united-states-us/
AK
AL,MS,TN,GA,FL
AR,MO,TN,MS,LA,TX,OK
AZ,CA,NV,UT,CO,NM
CA,OR,NV,AZ
CO,WY,NE,KS,OK,NM,AZ,UT
@rietta
rietta / gist:4112483
Created November 19, 2012 18:21
The Provinces of Canada
Province/Territory Abbreviation
Alberta AB
British Columbia BC
Manitoba MB
New Brunswick NB
Newfoundland and Labrador NL
Northwest Territories NT
Nova Scotia NS
Nunavut NU
Ontario ON
@rietta
rietta / nokofix_for_bashrc
Created December 12, 2012 16:46
Add the following alias to your .bashrc file to be able to run the "nokofix" command in a project while running bundler. This assumes that libiconv was installed using brew.
alias nokofix="gem install nokogiri -- --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8 --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-iconv-dir=/usr/local/Cellar/libiconv/1.13.1/ && bundle config build.nokogiri – –with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8 –with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 –with-iconv-dir=/usr/local/Cellar/libiconv/1.13.1/"