Skip to content

Instantly share code, notes, and snippets.

View victorpotasso's full-sized avatar
🔥

Victor Potasso victorpotasso

🔥
View GitHub Profile
@victorpotasso
victorpotasso / event-dispatcher.coffee
Created October 24, 2015 18:16
Event dispatcher with Coffeescript
# Event
class Event
type:null
callback:null
target:null
currentTarget:null
data:null
constructor:(p_type,p_callback)->
@type = p_type
@callback = p_callback
@victorpotasso
victorpotasso / apply-function.coffee
Created October 24, 2015 18:15
Apply function with CoffeeScript
class Test
constructor:()->
test1 = ["Apply", "Testing apply with coffeescript"]
test2 = "Testing apply with coffeescript"
@trace1.apply(@, [].concat(test1))
@trace2.apply(@, [].concat(test2))
trace1:(p_arg1, p_arg2)->
console.log(p_arg1, p_arg2)
@victorpotasso
victorpotasso / GoogleAnalytics.coffee
Created September 12, 2014 14:40
A simple interface for Google Analytics JS API made in CoffeeScript
class GoogleAnalytics
constructor:(p_id)->
`(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');`
ga('create', p_id, 'auto')
#
# toggle-file-symbols
#
'.platform-darwin .editor':
'shift-cmd-o': 'symbols-view:toggle-file-symbols'
'.platform-win32 .editor':
'shift-ctrl-o': 'symbols-view:toggle-file-symbols'
#
#!/bin/bash
APACHE_DIR=/etc/apache2
APACHE_USERS="$APACHE_DIR/users"
DOMAIN=$1
WORK_DIR=$2
HOSTS=/private/etc/hosts
LOCALHOST=127.0.0.1
clear
@victorpotasso
victorpotasso / Nice Print
Created April 16, 2014 06:32
Get a beautiful print
echo nl2br("<pre>".print_r($variable, true)."</pre>");
@victorpotasso
victorpotasso / Grid with modulo
Created April 16, 2014 02:29
Create a multidimensional grid using just a loop with modulo
var rows = 4;
var cols = 5;
var total = rows * cols;
var i = 0;
while(i<total)
{
var posX = Math.floor(i/rows);
var posY = i % rows;