Skip to content

Instantly share code, notes, and snippets.

View stefanoortisi's full-sized avatar

Stefano Ortisi stefanoortisi

View GitHub Profile
@stefanoortisi
stefanoortisi / Revert
Created June 13, 2013 14:40
Revert a branch to a previous commit
# To revert to a commit further back than the most recent commit--------
git reset 56e05fced #resets index to former commit; replace '56e05fced' with your commit code
git reset --soft HEAD@{1} #moves pointer back to previous HEAD
git commit -m "Revert to 56e05fced"
git reset --hard #updates working copy to reflect the new commit
@stefanoortisi
stefanoortisi / tweener.coffee
Last active December 21, 2015 05:19
Tweener Coffescript Class
###
An utility object which allows to create different animations with different keyframes.
The get_value method return the interpolated value of the selected animation depending on time parameter.
###
class Tweener
constructor: ->
@keyframes = new Object()
@stefanoortisi
stefanoortisi / mixin.styl
Created August 21, 2013 09:58
Stylus Mixins
border-radius(n)
-webkit-border-radius n
-moz-border-radius n
border-radius n
// Math
// ------------------------------
floor(n){math(n, 'floor')}
// $('img.photo',this).imagesLoaded(myFunction)
// execute a callback when all images have loaded.
// needed because .load() doesn't work on cached images
// Modified with a two-pass approach to changing image
// src. First, the proxy imagedata is set, which leads
// to the first callback being triggered, which resets
// imagedata to the original src, which fires the final,
// user defined callback.
localise_routes: ( ) ->
# Deep clone the default routes
old_routes = _.cloneDeep @Routes.routes
# Create a brand new routes object
@Routes.routes = {}
# Copy the utility routes
@Routes.routes[ "/pages" ] = old_routes[ "/pages" ]
fs = require("fs")
http = require("http")
socketio = require("socket.io")
public_path = "#{__dirname}/../public"
server = http.createServer((req, res) ->
res.writeHead 200, "Content-type": "text/html"
res.end fs.readFileSync "#{public_path}/index.html"
).listen(8765)
@stefanoortisi
stefanoortisi / log
Created May 21, 2014 15:51
Log function
// usage: log('inside coolFunc', this, arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
log.history = log.history || []; // store logs to an array for reference
log.history.push(arguments);
arguments.callee = arguments.callee.caller;
if(this.console) console.log( Array.prototype.slice.call(arguments) );
};
### Keybase proof
I hereby claim:
* I am stefanoortisi on github.
* I am ortisi (https://keybase.io/ortisi) on keybase.
* I have a public key whose fingerprint is 4FE9 7C3C BA96 125E 2D1A 0681 2BC5 8974 F5CB 29CE
To claim this, I am signing this object:
@stefanoortisi
stefanoortisi / scroll-to-close.js
Created April 21, 2023 08:46
Script to automatically close the mobile menu when the user scroll the page (siraloe.it)
/*
- siraloe.it
Script to automatically close the mobile menu when the user scroll the page
*/
document.addEventListener("DOMContentLoaded", () => {
const handlers = document.querySelectorAll(".hfe-nav-menu__toggle");
let isOpen = false;
if (handlers.length < 2) {
return;
}