Skip to content

Instantly share code, notes, and snippets.

View andreruffert's full-sized avatar

André Ruffert andreruffert

View GitHub Profile
@andreruffert
andreruffert / once.js
Created August 11, 2014 21:14
Once wrapper for a function which you only want to run once.
// http://davidwalsh.name/javascript-once
function once(fn, context) {
var result;
return function() {
if(fn) {
result = fn.apply(context || this, arguments);
fn = null;
}
@andreruffert
andreruffert / deploy.sh
Created July 24, 2014 12:05
Simple scp deployment
# Deployment via scp
keyfile="/path/id_rsa"
username="username"
servername="servername"
remotePath="/path"
files="path/folder path/path/folder"
scp -i $keyfile -r $files $username@$servername:$remotePath
@andreruffert
andreruffert / _hidpi.scss
Last active August 29, 2015 14:02
Sass, Compass solution to generate basic- and high-resolution-image sprite maps.
// Mixin: HiDPI mixin.
// Description: Default value set to 1.3 to target Google Nexus 7
// (http://bjango.com/articles/min-device-pixel-ratio/).
//
// Example usage: @include hidpi($ration) { ... }
@mixin hidpi($ratio: 1.3) {
@media only screen and (-webkit-min-device-pixel-ratio: $ratio),
only screen and (min--moz-device-pixel-ratio: $ratio),
only screen and (-o-min-device-pixel-ratio: #{$ratio}/1),
@andreruffert
andreruffert / getAllStyles.js
Last active March 22, 2019 08:08
Get all the applied CSS rules of an element and its child elements.
console.log((function(selector){
var parent = document.querySelectorAll(selector),
childs = parent[0].querySelectorAll('*'),
// Make a array of `parent` and `childs` NodeList.
elements = Array.prototype.slice.call(parent).concat(Array.prototype.slice.call(childs)),
styles = [];
var i = elements.length,
matchedCSSRules,
@andreruffert
andreruffert / lazyeval.html
Created August 30, 2013 11:40
Lazy evaluating JavaScript.
<html>
<body>
<a href="#" onclick="lazyEval('js-module')">lazyEval</a>
<script id="js-module">
/*
alert('lazyEval');
*/
</script>
@andreruffert
andreruffert / gist:5796191
Last active December 18, 2015 14:19
Sublime Text 2 - Useful Shortcuts (Mac OS X)

Sublime Text 2 - Useful Shortcuts (Mac OS X)

General

  • ⌘T go to file
  • ⌘⌃P go to project
  • ⌘R go to methods
  • ⌃G go to line
  • ⌘KB toggle side bar
  • ⌘⇧P command prompt

Debugging & Profiling Node.js

This is a maintained listing of all the different ways to debug and profile Node.js applications. If there is something missing or an improvement, post a comment! :)

Interactive Stack Traces with traceGL - Shareware

  1. Guide here
var express = require('express');
var oauth = require('oauth');
var oa;
var app = express.createServer();
app.get('/', function (req, res) {
res.end('<!DOCTYPE html><meta charset=utf-8><form action=/authorize><label>Client ID: <input type=text name=client_id required autofocus></label><br><label>Client Secret: <input type=text name=client_secret required></label><br><label>Scope: <input type=text name=scope required></label><br><input type=submit>');
});
app.get('/authorize', function (req, res) {
@andreruffert
andreruffert / index.html
Created February 6, 2013 23:48
slider-bar
<div id="bar">
<div id="top">
<div class="background"></div>
</div>
<div id="front">
<div class="background"></div>
</div>
</div>
<div id="slider"></div>