Skip to content

Instantly share code, notes, and snippets.

View randallreedjr's full-sized avatar

Randall Reed, Jr. randallreedjr

View GitHub Profile
@randallreedjr
randallreedjr / rails_engine.sh
Last active April 19, 2016 21:04
Useful options when generating a Rails engine
rails plugin new -OJT --skip-bundle --mountable --dummy-path spec/dummy
OJT prevents assets and test unit files being generated,
skip bundle because you're going to be adding rspec
--dummy-path because that's where rspec will live
@randallreedjr
randallreedjr / resize.js
Last active April 10, 2016 16:46
Function to display window width when resizing in Chrome
var onresize = function()
{
var width = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;
console.log(width);
}
//Source: http://stackoverflow.com/questions/35930283/chrome-does-not-show-width-and-height-of-screen-when-inspecting-the-page-with-in
namespace :coffee do
desc "Compile coffeescript source file into javascript"
task :compile, :input_file, :output_file do |t, args|
filename = args.input_file
coffee_file = File.open(filename, "r")
js_contents = CoffeeScript.compile(coffee_file)
coffee_file.close
output_filename = args.output_file
output = File.open("public/static/#{output_filename}","w" )
@randallreedjr
randallreedjr / 0_reuse_code.js
Created March 22, 2016 15:27
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
html {
background: url(images/bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
@randallreedjr
randallreedjr / ruby_abstraction_in_loops_6.rb
Created March 6, 2016 22:38
Sixth code sample for post Ruby Abstraction in Loops
def square_array(array)
array.collect {|element| element**2}
end
@randallreedjr
randallreedjr / ruby_abstraction_in_loops_5.rb
Created March 6, 2016 22:36
Fifth code sample for post Ruby Abstraction in Loops
array = [1,2,3]
array.collect do |element|
element ** 2
end
# => [1,4,9]
@randallreedjr
randallreedjr / ruby_abstraction_in_loops_4.rb
Created March 6, 2016 22:35
Fourth code sample for post Ruby Abstraction in Loops
squares = []
#do some code where squares is modified
return squares
@randallreedjr
randallreedjr / ruby_abstraction_in_loops_3.rb
Created March 6, 2016 22:33
Third code sample for post Ruby Abstraction in Loops
array = [1,2,3]
squares = []
array.each do |element|
squares << element ** 2
end
squares
# => [1,4,9]
@randallreedjr
randallreedjr / ruby_abstraction_in_loops_2.rb
Created March 6, 2016 22:30
Second code sample for post Ruby Abstraction in Loops
array = [1,2,3]
current_index = 0
squares = []
while current_index < array.size
squares << array[current_index] ** 2
current_index += 1
end
squares
# => [1,4,9]