Skip to content

Instantly share code, notes, and snippets.

View Granze's full-sized avatar
💫
nothing to see here

Maurizio Mangione Granze

💫
nothing to see here
View GitHub Profile
@Granze
Granze / .editorconfig
Created November 27, 2013 23:53
Editor config basic template
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
@Granze
Granze / package.json
Created November 26, 2013 17:51
Basic package.json template
{
"name": "appName",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.2",
"load-grunt-tasks": "~0.2.0"
}
}
@Granze
Granze / npm list without dependecies.sh
Created November 14, 2013 10:50
npm list without dependencies function
function npmls() { npm ls -g --depth=0 "$@" 2>/dev/null }
@Granze
Granze / Automatic deploy based on git branch
Created September 27, 2012 12:44
Automatic deploy based on git branch
#!/bin/bash
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "master" == "$branch" ]; then
git --work-tree=/var/www/prod checkout -f $branch
echo 'Changes pushed live.'
fi
@Granze
Granze / Check if an image is loaded.js
Created March 25, 2012 22:40
Check if an image is loaded
$('#theImage').attr('src', 'image.jpg').load(function() {
alert('This Image Has Been Loaded');
});
@Granze
Granze / Find the index of an element in <ul>.js
Created March 25, 2012 22:36
Find the index of an element in <ul>
$("ul > li").click(function () {
var index = $(this).prevAll().length;
});
@Granze
Granze / A-Z order <ul> items
Created March 25, 2012 22:32
A-Z order <ul> items
var items = $('.to_order li').get();
items.sort(function(a,b){
var keyA = $(a).text();
var keyB = $(b).text();
if (keyA < keyB) return -1;
if (keyA > keyB) return 1;
return 0;
});
var ul = $('.to_order');
@Granze
Granze / Get URL variables (regex)
Created March 25, 2012 22:24
Get URL variables (regex)
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
@Granze
Granze / Get URL variables
Created March 25, 2012 22:12
Get URL variables
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
}
return(false);
}
@Granze
Granze / gist:2200261
Created March 25, 2012 22:02
[LESS] Rotate
.rotate (@deg) {
-webkit-transform: rotate(@deg);
-moz-transform: rotate(@deg);
-ms-transform: rotate(@deg);
-o-transform: rotate(@deg);
}