Skip to content

Instantly share code, notes, and snippets.

View dougalcorn's full-sized avatar

Doug Alcorn dougalcorn

View GitHub Profile
@dougalcorn
dougalcorn / after_use.sh
Created July 6, 2011 15:19
~/.rvm/hooks/after_use for JRUBY_OPTS
case "$GEM_HOME" in
*jruby*)
# -J-Djruby.reify.classes=true
# JRUBY_OPTS="-J-Djruby.reify.classes=true -J-Xmx512M -J-XX:MaxPermSize=256m -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled" ; export JRUBY_OPTS
JRUBY_OPTS="-J-Xmx1024m -J-XX:MaxPermSize=256m " ; export JRUBY_OPTS
;;
esac
@dougalcorn
dougalcorn / gist:1212205
Created September 12, 2011 19:52
testing backbone models using the right backend endpoints
/* This is in SpecHelper.js */
$(function() {
beforeEach(function() {
this.addMatchers({
toRequest: function(expectedRequest) {
var actualRequest, name, value;
actualRequest = this.actual;
for (name in expectedRequest) {
value = expectedRequest[name];
@dougalcorn
dougalcorn / password.rb
Created September 22, 2011 20:27
Generate XKCD style passwords on OS X
#!/usr/bin/env ruby
number_of_words = ARGV[0].to_i
number_of_words ||= 4
dictionary = File.read('/usr/share/dict/web2a').split
words = []
until words.length == number_of_words do
word = dictionary[rand(dictionary.size)]
@dougalcorn
dougalcorn / gist:1242310
Created September 26, 2011 14:05
Bash Prompt for Git Status
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
# Black 0;30 Dark Gray 1;30
# Blue 0;34 Light Blue 1;34
# Green 0;32 Light Green 1;32
@dougalcorn
dougalcorn / irb
Created December 9, 2011 22:01
$in criteria in Mongoid
irb(main):062:0> base.in(:from_id => port_ids)
=> #<Mongoid::Criteria
selector: {:from_id=>"$in0d06b030-04d8-012f-18e7-388d1201202c5b932da1-04d8-012f-b944-388d1201202c"},
options: {},
class: Ccom::PortConnection,
embedded: false>
# that's a jacked up selector
# now not using the _id on the field name
@dougalcorn
dougalcorn / failure_message.txt
Created December 10, 2011 15:36
Simplified example of failing any_in criteria for mongoid using string id fields
Failures:
1) Mongoid inclusion criteria
Failure/Error: @criteria.selector.should == {"$in" => {:from_id => [from_port.id, to_port.id]}}
expected: {"$in"=>{:from_id=>["6055df90-0572-012f-2043-388d1201202c", "60562bc0-0572-012f-2043-388d1201202c"]}},
got: {:from_id=>"{\"$in\"=>[\"6055df90-0572-012f-2043-388d1201202c\", \"60562bc0-0572-012f-2043-388d1201202c\"]}"} (using ==)
Diff:
@@ -1,5 +1,3 @@
-{"$in"=>
- {:from_id=>
@dougalcorn
dougalcorn / ejabberd.cfg
Created July 18, 2013 13:33
Problems with registering my first user from the command line on ejabberd on ubuntu
{hosts, ["localhost", "semperubisububi.org"]}.
{access, max_user_sessions, [{10, all}]}.
{access, max_user_offline_messages, [{5000, admin}, {100, all}]}.
{access, local, [{allow, all}]}.
{access, c2s, [{deny, blocked},
{allow, all}]}.
{access, c2s_shaper, [{none, admin},
{normal, all}]}.
{access, s2s_shaper, [{fast, all}]}.

Web Development with Ruby on Rails and Nitrous.IO.

Introduction

We will create a simple "Wish List" Web application using Ruby on Rails (Rails) and Nitrous.IO (Nitrous).

Rails is a Web application development framework written in the Ruby programming language. It follows a "convention over configuration" philosophy that allows developers to quickly create valuable products if they choose to follow convention. However, Rails is powerful enough to to create applications like Twitter and Groupon.

Nitrous is a Web-based application development service. It permits software developers to focus on writing code and less on the intricacies of their development environment. Their tagline is, "making coding in the cloud a reality." Using Nitrous, you are literally programming a server running in "The Cloud."

@dougalcorn
dougalcorn / open_ports.md
Last active March 14, 2016 13:46
Some questions about ports "open to the world"

@p9k put out a question on Twitter about ports open to the world: https://twitter.com/p9k/status/408721475345330177

$ netstat -na|grep '^tcp4\W.*\*\.\d.*LISTEN'|wc -l
       5

His command was specifically only looking for processes listening on an IPv4 TCP port. I've modified the filter to pull both IPv4 and IPv6 TCP ports.

Keybase proof

I hereby claim:

  • I am dougalcorn on github.
  • I am dougalcorn (https://keybase.io/dougalcorn) on keybase.
  • I have a public key whose fingerprint is 4AFA 9F41 2256 E31E B97F 86AA 7EBC 2B80 3393 094A

To claim this, I am signing this object: