Skip to content

Instantly share code, notes, and snippets.

View brunoscopelliti's full-sized avatar
🙃

Bruno Scopelliti brunoscopelliti

🙃
View GitHub Profile
# Show branch name in bash prompt
```
nano ~/.bash_profile
```
Then copy/paste following code:
```
parse_git_branch() {
@brunoscopelliti
brunoscopelliti / firebug-lite.js
Created November 27, 2017 13:23
Firebug nostalgia
const script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://getfirebug.com/firebug-lite-debug.js";
document.head.appendChild(script);
@brunoscopelliti
brunoscopelliti / meters.json
Last active June 8, 2017 09:51
How much meters I've run this year (2017 edition); live @ https://brunoscopelliti.com/run
[3710, 3770, 5060, 3990, 5380, 4090, 5380, 6000, 3750, 3800, 7050, 5280, 4570]
@brunoscopelliti
brunoscopelliti / console.watch implementation
Created January 13, 2014 15:29
console.watch implementation
var foo = { bar: 'baz' };
console.watch = function(obj, prop) {
var _prop = "$_" + prop + "_$";
obj[_prop] = obj[prop];
Object.defineProperty(obj, prop, {
get: function () {
return obj[_prop];
var serialize = function(obj, prefix) {
// http://stackoverflow.com/questions/1714786/querystring-encoding-of-a-javascript-object
var str = [];
for(var p in obj) {
var k = prefix ? prefix + "[" + p + "]" : p, v = obj[p];
str.push(typeof v == "object" ? serialize(v, k) : encodeURIComponent(k) + "=" + encodeURIComponent(v));
}
return str.join("&");
}
@brunoscopelliti
brunoscopelliti / Drag&Drop touch
Last active December 28, 2015 02:29
Enable drag and drop on touch devices.
if ('ontouchstart' in window) {
var TouchDragAndDrop = function(event) {
var touch = event.changedTouches[0],
fakedEvent = document.createEvent("MouseEvent");
fakedEvent.initMouseEvent({ touchstart: "mousedown", touchmove: "mousemove", touchend: "mouseup" }[event.type], true, true, window, 1, touch.screenX, touch.screenY, touch.clientX+40, touch.clientY, false, false, false, false, 0, null);
touch.target.dispatchEvent(fakedEvent);
return false;
}
document.addEventListener("touchstart", TouchDragAndDrop, true);
document.addEventListener("touchmove", TouchDragAndDrop, true);
// Javascript Design Pattern
@brunoscopelliti
brunoscopelliti / Web Notifications
Last active December 17, 2015 03:19
This is a javascript object with some methods, that may turn useful when we deal with the new web notifications. This work is based on the W3C's draft of the 26 July 2012 ( http://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html ). You could find more info on this topic on my blog, @ http://blog.brunoscopelliti.com/start-using-web-notific…
var _notification = {
checkSupport: function() {
return (window.Notification) ? true : false;
},
requestAuthorization: function() {
if (this.checkSupport()) {