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
.foo{ | |
width: 250px; | |
white-space: nowrap; | |
overflow: hidden; | |
text-overflow: ellipsis; | |
} |
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
// <div class="foo">I follow</div> | |
window.addEventListener("mousemove", function(e){ | |
$(".foo").css({ | |
left: (e.pageX - ($(window).width() * .35)), | |
top: (e.pageY - 600) | |
}); | |
}); |
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
## Ternary Operator | |
x = 1 ? 2 : 3 | |
puts x # >> 2 | |
puts (x.nil? ? "pop" : "bar") # >> "bar" |
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
## string include? | |
string = "marcus is my name" | |
bad_words = ["foo", "bar", "marcus"] | |
if bad_words.any? { | w | string.include? w } | |
puts "yes" | |
else | |
puts "no" | |
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
var s = "marcus is the king"; | |
undefined | |
// the `g` flag causes multiple replacements | |
var soo = s.replace(/marcus/g, "foo"); | |
undefined | |
soo | |
"foo is the king" | |
var foo = s.replace(/s/g, "foo"); |
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
scp my_local_file user@serveraddress:/file/path/on/server | |
# an entire folder recursively | |
scp -pr path/to/my_local_dir user@serveraddress:/file/path/on/server |
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
exec bash |
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
find . -name foo.txt | |
# find a file name that contains the given string | |
# find accepts a regex | |
find /path/to/searchable -name "*foo*" |
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
# showing a diff num1:num2 is the commits that we're compairing. | |
svn diff -r 2748:2749 >> ~/Desktop/foo.txt | |
# finding something in the log (-B is how many lines before -A is how many lines after) | |
svn log | grep "4294" -B 3 -A 3 | |
# blow away the changes to file(s) | |
svn revert *.txt | |
# update head |
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
## if a is false, nil or undefined, then evaluate b and set a to the result | |
a ||= 1 # => 1 | |
a ||= 2 # => 1 | |
foo = false # => false | |
foo ||= true # => true | |
foo ||= false # => true |