Skip to content

Instantly share code, notes, and snippets.

View benjamincharity's full-sized avatar
🤖

Benjamin Charity benjamincharity

🤖
View GitHub Profile
@benjamincharity
benjamincharity / rem.scss
Last active December 12, 2015 05:58 — forked from raybrownco/rem.scss
REM is a SCSS mixin that converts pixel values to REM values for whatever property is passed to it.
/*
* 'rem' is a Sass mixin that converts pixel values to rem values for whatever property is passed to it.
* It returns two lines of code — one of the regular pixel values (for IE), and another with the
* converted rem values (for everyone else). Special thanks to Chris Epstein (http://chriseppstein.github.com)
* and Martin Bavio (http://martinbavio.com) for the help and code!
*
* Sample input:
* .element {
* @include rem('padding',10px 0 2px 5px);
* }
/*
An attempt at fixing the dreaded iOS orientationchange zoom bug http://adactio.com/journal/5088/. Seems to work!
Authored by @scottjehl
MIT License.
*/
(function(w){
var doc = w.document;
if( !doc.querySelectorAll ){ return; }
@benjamincharity
benjamincharity / smooscroll.js
Created May 9, 2012 17:56 — forked from cange/smooscroll.js
Simple smooth scrolling solution
// <a rel="smoothscroll" href="#foo">got to foo</a>
// <div id="foo">Foo content</div>
$(function () {
$('a[rel=smoothscroll]').click(function( event ) {
var location = window.location,
hash = $(this).attr('href')
;
$('html, body')
.stop()
.animate({scrollTop: $(hash).offset().top}, 800, function () {
@benjamincharity
benjamincharity / zepto.smoothScroll.js
Last active October 4, 2019 15:21 — forked from austinpray/zepto.smoothScroll.js
Smooth scrolling with Zepto.js
function smoothScroll(el, to, duration) {
if (duration < 0) {
return;
}
var difference = to - $(window).scrollTop();
var perTick = difference / duration * 10;
this.scrollToTimerCache = setTimeout(function() {
if (!isNaN(parseInt(perTick, 10))) {
window.scrollTo(0, $(window).scrollTop() + perTick);
smoothScroll(el, to, duration - 10);
/*
* Normalized hide address bar for iOS & Android
* (c) Scott Jehl, scottjehl.com
* MIT License
*/
(function( win ){
var doc = win.document;
// If there's a hash, or addEventListener is undefined, stop here
if( !location.hash && win.addEventListener ){
@benjamincharity
benjamincharity / master.vim
Last active June 30, 2023 08:45 — forked from gmccreight/master.vim
Master Vim with this interactive tutorial.
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)