Skip to content

Instantly share code, notes, and snippets.

View ben-ole's full-sized avatar

Benjamin Gaertig ben-ole

View GitHub Profile
@jlong
jlong / position.js
Last active July 18, 2022 11:03
Get the offset of an element relative to the viewport and take scrolling and borders into account
function getViewportOffset(element) {
var node = element
, left = node.offsetLeft
, top = node.offsetTop
;
node = node.parentNode;
do {
var styles = getComputedStyle(node);
@francois-blanchard
francois-blanchard / production.rb
Created June 19, 2014 11:00
Notification backup (gem) on Slack
# ~/Backup/models/production.rb
Backup::Model.new(:production, 'Descritpion') do
require 'json'
notify_by HttpPost do |post|
post.on_success = true
post.on_warning = true
post.on_failure = true