Skip to content

Instantly share code, notes, and snippets.

View andreruffert's full-sized avatar

André Ruffert andreruffert

View GitHub Profile
@andreruffert
andreruffert / hasEmojiSupport.js
Last active November 22, 2017 13:14
Detect support for emoji character sets
/**
* Detects support for emoji character sets.
*
* Based on the Modernizr emoji detection.
* https://github.com/Modernizr/Modernizr/blob/347ddb078116cee91b25b6e897e211b023f9dcb4/feature-detects/emoji.js
*
* @return {Boolean} true or false
* @example
*
* hasEmojiSupport()
@andreruffert
andreruffert / scp-deploy.sh
Last active August 29, 2015 14:26
Deploy all the stuff with scp
##
# Deploy all the stuff
##
keyfile="path/to/id_rsa"
username="user"
hostname="example.com"
remotePath="/my/remote/path"
folders="to-deploy/*"
@andreruffert
andreruffert / README.md
Last active August 29, 2015 14:25
ZOMG
@andreruffert
andreruffert / package.json
Last active March 5, 2018 03:12
using `npm run` to build and watch with node-sass and browserify
{
"name": "my-app",
"version": "0.0.0",
"devDependencies": {
"browserify": "^10.2.4",
"watchify": "^3.2.3",
"node-sass": "^3.2.0",
"uglify": "^2.4.23",
"mkdirp": "^0.5.1",
"parallelshell": "^1.2.0",
@andreruffert
andreruffert / pre-commit
Last active August 29, 2015 14:22
.gitshots - take a selfie every time u commit
#!/bin/sh
# Run `chmod +x pre-commit` to make it executable then put it into .git/hooks/.
##
# gitshots
#
# Requires imagesnap from https://github.com/alexwilliamsca/imagesnap (brew install imagesnap)
# Create a .gitshots directory at the same level as the .git directory.
# To assemble the video use http://www.dayofthenewdan.com/projects/tlassemble
@andreruffert
andreruffert / page.html
Created April 10, 2015 15:17
Passing data to assemble partials
---
myPartial:
cssClass: myPartialCssClass
---
{{> partial myPartial}}
@andreruffert
andreruffert / getAge
Created February 23, 2015 13:25
Get age from a dateString
function getAge(dateString) {
var today = new Date();
var birthDate = new Date(dateString);
var age = today.getFullYear() - birthDate.getFullYear();
var m = today.getMonth() - birthDate.getMonth();
if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
age--;
}
return age;
}
@andreruffert
andreruffert / selectContent
Last active August 29, 2015 14:14
Select all the content of an element. Supported in IE 9+
function selectContent(el) {
var range = document.createRange();
var selection = window.getSelection();
range.selectNodeContents(el);
selection.removeAllRanges();
selection.addRange(range);
}
var el = document.getElementById("elementId");
selectContent(el);