Skip to content

Instantly share code, notes, and snippets.

View TechFounder's full-sized avatar

Jimmy Chen TechFounder

View GitHub Profile
@TechFounder
TechFounder / assets.css.scss
Last active August 29, 2015 13:56
A useful jQuery snippet to make any tagged item a clickable link. This is how in Rails.
[data-link] {
cursor: pointer;
}
@TechFounder
TechFounder / index.html
Last active August 29, 2015 13:57
You want a way to center any object to the middle of the page (horizontal centering)?
<div id="first">
<div id="second">
Item you want centered
</div>
</div>
for example:
<a href="mailto:info@email.com?Subject=Web%20Page" target="_top" id="first">
<img src="photo.png" alt="photo">
@TechFounder
TechFounder / hide_unhide.coffee
Last active August 29, 2015 14:06
CoffeeScript to use with checkbox to hide / unhide form fields or div.
# Use this if you only want to use the checkbox as a clicker
$('#checkbox-id').click ->
$('.what-you-want-to-hide').slideToggle('slow')
# Use this if you actually care about checking to see if the checkbox has been checked
$('#checkbox-id').click ->
if $(@).prop('checked')
$('.what-you-want-to-hide, .what-you-want-to-hide-also').slideDown 'slow'
else
$('.what-you-want-to-hide, .what-you-want-to-hide-also').slideUp 'slow'
@TechFounder
TechFounder / view.haml
Created September 23, 2014 21:55
Prevent link_to from redirecting to a new page when you don't have any particular link to go to. So you don't get that annoying top of the page action.
= link_to 'Link to Nowhere', 'javascript:;'
@TechFounder
TechFounder / javascript.js.coffee
Last active August 29, 2015 14:07
How to setup a fixed navbar using javascript when you have an extra header on top of it. Or, a fading navbar.
# The basic idea here is that you set a num of pixels before triggering the css "fixed"
# which would freeze whatever you div attribute you set, in this case"nav".
# This is a simple way to do it but there's a library you can use to do the same thing.
# http://imakewebthings.com/jquery-waypoints/shortcuts/sticky-elements/
num = 250 #number of pixels before modifying styles
$(window).bind "scroll", ->
if $(window).scrollTop() > num
$("nav").addClass "fixed"
else
@TechFounder
TechFounder / font.sass
Created January 5, 2015 22:50
SASS mixin font sizes
$min-font-size: 10
$max-font-size: 50
@mixin font-sizes
@for $i from $min-font-size through $max-font-size
.font-#{$i}px
font-size: ($i / 16)em
@extend .font-normal
@include font-sizes
@TechFounder
TechFounder / comment
Created January 7, 2015 19:22
Safety Pig
.
_
_._ _..._ .-', _.._(`))
'-. ` ' /-._.-' ',/
) \ '.
/ _ _ | \
| a a / |
\ .-. ;
'-('' ).-' ,' ;
'-; | .'
#fade {
width: 100px;
height: 100px;
border-radius: 50%;
border: none;
}
img {
cursor:pointer;
}
#!/usr/bin/ruby
#
# This script fixes /usr/local only.
#
# 6th January 2010:
# Modified the script to just fix, rather than install. - rpavlik
#
# 30th March 2010:
# Added a check to make sure user is in the staff group. This was a problem
# for me, and I think it was due to me migrating my account over several