Skip to content

Instantly share code, notes, and snippets.

@killercup
killercup / gist:2783854
Created May 24, 2012 19:56 — forked from mataspetrikas/gist:2300296
Check if element is visible in viewport and scroll if necessary
$.extend $.expr[":"],
inView: (a) ->
# cf. http://remysharp.com/2009/01/26/element-in-view-event-plugin/#comment-127058
st = (document.documentElement.scrollTop or document.body.scrollTop)
ot = $(a).offset().top
wh = (if (window.innerHeight and window.innerHeight < $(window).height()) then window.innerHeight else $(window).height())
ot > st and ($(a).height() + ot) < (st + wh)
$.fn.scroll_if_necessary = ->
if this.length && not @is(":inView")
@killercup
killercup / index.html
Last active January 4, 2016 06:29 — forked from anonymous/index.html
<!DOCTYPE html>
<html>
<head>
<title>Foo</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<style type='text/css'>
body {
font-family: 'Helvetica Neue';
background:#000;
@killercup
killercup / playground.rs
Created September 5, 2016 11:45 — forked from anonymous/playground.rs
Rust code shared from the playground
// https://benchmarksgame.alioth.debian.org/u64q/knucleotide-description.html#knucleotide
extern crate fnv;
use std::thread;
use std::sync::Arc;
use std::collections::HashMap;
use std::hash::BuildHasherDefault;
use fnv::FnvHasher;
const SEQ_LENS: [usize; 7] = [1, 2, 3, 4, 6, 12, 18];
@killercup
killercup / bling.js
Last active April 24, 2018 14:33 — forked from paulirish/bling.js
bling dot js
/**
* bling.js
*
* Original Author: Paul Irish
* Fetched from https://gist.github.com/paulirish/12fb951a8b893a454b32/fe4fa7794b6575d8356ac73a79b0aefd75ffacbb
*/
/**
* Select elements with CSS-style selector syntax
*
@killercup
killercup / min-max.rs
Created September 30, 2015 12:02 — forked from anonymous/playground.rs
Rust min! and max! macros
macro_rules! max {
($x:expr) => ( $x );
($x:expr, $($xs:expr),+) => {
{
use std::cmp::max;
max($x, max!( $($xs),+ ))
}
};
}