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
replaceText = function(string, oldText, newText) { | |
index = string.indexOf(oldText); | |
front = string.substring(0, index); | |
back = string.substring(index + oldText.length); | |
return front + newText + back; | |
}; | |
replaceTextGlobal = function(string, oldText, newText) { | |
while(string.indexOf(oldText) >= 0) { | |
string = replaceText(string, oldText, newText); |
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
# Configuring Our Prompt | |
# ====================== | |
# if you install git via homebrew, or install the bash autocompletion via homebrew, you get __git_ps1 which you can use in the PS1 | |
# to display the git branch. it's supposedly a bit faster and cleaner than manually parsing through sed. i dont' know if you care | |
# enough to change it | |
# This function is called in your prompt to output your active git branch. | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' |
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
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 |
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
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 |
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
array = [1,2,3] | |
current_index = 0 | |
squares = [] | |
loop do | |
if current_index < array.size | |
squares << array[current_index] ** 2 | |
current_index += 1 | |
else | |
break |
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
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" ) |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
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; | |
} |
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
def square_array(array) | |
array.collect {|element| element**2} | |
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
array = [1,2,3] | |
array.collect do |element| | |
element ** 2 | |
end | |
# => [1,4,9] |