This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# As root user | |
sudo su | |
# Update the OS | |
apt-get update -y | |
# Setup Hostname & TimeZone | |
echo "{{HOSTNAME}}" > /etc/hostname | |
hostname -F /etc/hostname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in normal nc | |
nc -l -p 8888 | |
# in bsd nc | |
nc -l 0.0.0.0 8888 | |
# throw in a -k to keep listening to subsequent requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script>alert('hello');</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RecipeForm | |
ATTRIBUTES = [:name, :cooking_time_minutes] | |
attr_reader :recipe | |
attr_accessor *ATTRIBUTES | |
def initialize(recipe) | |
@recipe = recipe | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######## | |
# Author: Henry Turner | |
# Project: to_string | |
# Description: A speedy algorithm to convert a string to a string | |
# License: MIT | |
######## | |
def to_string | |
# process the string | |
self.to_s | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A Capybara Cheatsheet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In rails 3 | |
Post.select(:id, :created_at).count #=> SELECT COUNT(*) FROM posts | |
# In rails 4 | |
Post.select(:id, :created_at).count #=> SELECT COUNT(id, created_at) FROM posts ... bang | |
Post.select(:id, :created_at).count(:all) #=> SELECT COUNT(*) FROM posts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'pg' | |
gem 'activerecord' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Give me two arguments. | |
# 1) the path of the pwsafe xml file to import | |
# 2) the path of the csv to export | |
# format of lastpass data | |
# url,username,password,extra,name,grouping,fav | |
require 'nokogiri' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Event < ActiveRecord::Base | |
has_many :artists | |
end | |
class Artist < ActiveRecord::Base | |
def self.make_me_an_artist | |
create! do |artist| |