Skip to content

Instantly share code, notes, and snippets.

View marcusshepp's full-sized avatar
🎯
Focusing

Marcus Shepherd marcusshepp

🎯
Focusing
View GitHub Profile
@marcusshepp
marcusshepp / ellipsis.css
Created May 26, 2016 19:27
css truncate text with ellipsis
.foo{
width: 250px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
@marcusshepp
marcusshepp / follow_mouse.js
Last active May 27, 2016 12:52
Javascript Element Follows Mouse Movement
// <div class="foo">I follow</div>
window.addEventListener("mousemove", function(e){
$(".foo").css({
left: (e.pageX - ($(window).width() * .35)),
top: (e.pageY - 600)
});
});
@marcusshepp
marcusshepp / ternary_op.rb
Created May 27, 2016 13:03
Ruby Ternary Operator
## Ternary Operator
x = 1 ? 2 : 3
puts x # >> 2
puts (x.nil? ? "pop" : "bar") # >> "bar"
@marcusshepp
marcusshepp / include_any.rb
Created May 27, 2016 13:05
Ruby Does This String Include Any
## 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
@marcusshepp
marcusshepp / search_repalce.js
Last active May 31, 2016 15:26
Javascript search and replace
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");
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
@marcusshepp
marcusshepp / restrt.sh
Created June 2, 2016 12:33
restart current shell
exec bash
@marcusshepp
marcusshepp / find_file.sh
Last active June 2, 2016 13:31
find a file
find . -name foo.txt
# find a file name that contains the given string
# find accepts a regex
find /path/to/searchable -name "*foo*"
@marcusshepp
marcusshepp / svn.sh
Last active June 2, 2016 14:54
SVN notes
# 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
## 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