Skip to content

Instantly share code, notes, and snippets.

View lscott3's full-sized avatar

Larry Scott lscott3

View GitHub Profile
@lscott3
lscott3 / main.tf
Created April 12, 2018 04:58
Terraform example for an aws_vpc resource
provider "aws" {
access_key = ""
secret_key = ""
region = "us-east-1"
}
resource "aws_vpc" "default" {
cidr_block = "10.0.0.0/16"
tags {
@lscott3
lscott3 / wp-user.sql
Created December 3, 2013 19:57
Create user in wordpress mysql
INSERT INTO `database`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('4', 'test', MD5('test@1'), 'Test User', 'test@gmail.com', 'http://www.google.com/', '2011-06-07 00:00:00', '', '0', 'Test User');
INSERT INTO `database`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `database`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_user_level', '10');
calculatePrice = (selector) ->
total = 0.00
$.each $(selector), (index, value) ->
num = parseFloat($(this).html(), 10)
total = Math.round((total + num) * 1e10) / 1e10
total
user_id = connection.insert("INSERT INTO users (prefix, first_name,
middle_name, last_name, suffix, nick_name, email, password,
individual_id, account_id, avectra_id) VALUES (#{prefix},
#{first_name}, #{middle_name}, #{last_name}, #{suffix}, #{nick_name},
#{email}, #{password}, #{individual.id}, #{Account.first.id},
#{row['ind_cst_key']}) RETURNING id")
$authority->allow('manage', 'License', function($self, $user){
return $self->company()->id === $user->company()->id;
});
@lscott3
lscott3 / application_controller.rb
Created May 31, 2013 02:32
Rails 4 rc1 CanCan work around for strong params
# Rails 4 CanCan work around for strong params
before_filter do
resource = controller_name.singularize.to_sym
method = "#{resource}_params"
params[resource] &&= send(method) if respond_to?(method, true)
end
# Can't remember where I found this. Probably in the cancan github issue list.
@lscott3
lscott3 / header.html
Created February 13, 2013 05:21
Column example
<!-- this is an example using the bootstrap grid -->
<div class='span12'>
<div class='row'>
<div class='span4'>
<!-- this is where the logo markup would go -->
</div>
<div class='span6'>
<!-- this is where the slogan markup would go -->
</div>
<div class='2'>

Behold, the nav_link:

The nav_link helper works just like the standard Rails link_to helper, but adds a 'selected' class to your link (or its wrapper) if certain criteria are met. By default, if the link's destination url is the same url as the url of the current page, a default class of 'selected' is added to the link.

<%= nav_link 'My Page', my_path %>

When my_path is the same as the current page url, this outputs:

<a class="selected" href="http://example.com/page">My Page</a>
@lscott3
lscott3 / alias
Last active December 11, 2015 21:58
alias project='cd ~/path/to/project/; rm log/test.log && rm log/development.log; touch log/test.log && touch log/development.log && git branch'
@lscott3
lscott3 / deploy.rb
Created January 18, 2013 03:28
Run rake task from capistrano
desc 'Run the sqlite dump after deploy'
task :sqlite_dump_dev do
rake = fetch(:rake, 'rake')
rails_env = fetch(:rails_env, 'development')
run "cd '#{current_path}' && #{rake} sqlite_dump RAILS_ENV=#{rails_env}"
end