Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Marcus Shepherd marcusshepp

🎯
Focusing
View GitHub Profile
@marcusshepp
marcusshepp / css_mouse_detection.css
Created May 26, 2016
css onmouseenter, onmouseout
View css_mouse_detection.css
/* on mouse enter */
.foo:hover{
}
/* on mouse out */
.foo:not(:hover){
}
@marcusshepp
marcusshepp / ellipsis.css
Created May 26, 2016
css truncate text with ellipsis
View ellipsis.css
.foo{
width: 250px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
@marcusshepp
marcusshepp / follow_mouse.js
Last active May 27, 2016
Javascript Element Follows Mouse Movement
View follow_mouse.js
// <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
Ruby Ternary Operator
View ternary_op.rb
## Ternary Operator
x = 1 ? 2 : 3
puts x # >> 2
puts (x.nil? ? "pop" : "bar") # >> "bar"
@marcusshepp
marcusshepp / include_any.rb
Created May 27, 2016
Ruby Does This String Include Any
View include_any.rb
## 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
Javascript search and replace
View search_repalce.js
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");
View scp.sh
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 Jun 2, 2016
restart current shell
View find_file.sh
find . -name foo.txt
# find a file name that contains the given string
# find accepts a regex
find /path/to/searchable -name "*foo*"
View svn.sh
# 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