Skip to content

Instantly share code, notes, and snippets.

View Rendez's full-sized avatar

Luis Merino Rendez

View GitHub Profile
@Rendez
Rendez / returning-visitor.js
Created February 24, 2014 10:40
Create a 'returning visitor' or 'new visitor' property for Mixpanel.
/**
* If the mixpanel cookie exists this user was in the site before,
* we have to consider him returning, only every 24 hours, just like GA.
*/
var RETURNING_VISITOR = document.cookie.indexOf('_mixpanel') != -1;
// if the mixpanel cookie does not exists the user is considered new
if (!RETURNING_VISITOR) {
$.cookie('mp_visitor', true, { expires: 1, path: '/' });
// else the user might not be returning.
} else if ($.cookie('mp_visitor') !== null) {
@Rendez
Rendez / assets.rb
Created November 12, 2014 22:47
padrino and sinatra-assetpack rake task assets:precompile
namespace :assets do
def load_apps
require File.expand_path('config/boot.rb', Rake.application.original_dir)
Padrino.mounted_apps
end
desc "Precompile all assets"
task :precompile => 'precompile:build'
namespace :precompile do
@Rendez
Rendez / README.md
Last active August 29, 2015 14:11
Mustache extension(s) in Sprockets for Can.JS via JST

Can.js: how to register mustache templates via sprockets.

Conditions

  • Must use Sprockets for requiring mustache templates.
  • Mustache templates have to be compiled with can.mustache for compatibility with 2.0 and 3.0
  • Must expose compiled templates under a namespace, defaults to the commonly used JST variable exposed in the main object (window)

Example

@Rendez
Rendez / gist:251003
Created December 7, 2009 18:40
Number fix for values in SVG Gecko implementation
// Retuns the native constructor of its caller
function $itself(){
return function(){
return this;
}
}
// Number Fix for SVG values in Gecko
Number.implement('svg', (Browser.Engine.gecko) ? function(){ return this + 0.001; } : $itself());
Function.implement('repeat', function(number, fn, bind){
return function(){
for (var i = 1; i <= number; i++) fn.call(this, i, number);
};
});
mySillyFunction = function(){
console.log('Moo said the dog; Meow said the bird');
};
Function.prototype.append = function(){
for (var i = 0, l = arguments.length; i < l; i++) {
$extend(this.prototype, arguments[i]);
}
};
<handler pattern=”%core.config_dir%/static_files.xml” class=”StaticFilesConfigHandler”>
<validation>%core.lib_dir%/config/xsd/static_files.xsd</validation>
<transformation>%core.lib_dir%/config/xsl/static_files.xsl</transformation>
</handler>
<handler pattern=”%core.module_dir%/*/config/static_files.xml” class=”StaticFilesConfigHandler”>
<validation>%core.lib_dir%/config/xsd/static_files.xsd</validation>
<transformation>%core.lib_dir%/config/xsl/static_files.xsl</transformation>
</handler>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:routing_1_0="http://agavi.org/agavi/config/parts/routing/1.0"
xmlns="http://domain.com/config/parts/static_files/1.0"
targetNamespace="http://domain.com/config/parts/static_files/1.0"
elementFormDefault="qualified">
<xs:import namespace="http://agavi.org/agavi/config/parts/routing/1.0"
schemaLocation="../../../../../libs/agavi/config/xsd/parts/routing.xsd" />
@Rendez
Rendez / gist:763008
Created January 3, 2011 01:24
route.xml
<route name="..." output_types="html xslt email">
<?php
/**
* @package StaticFiles
*
* @author Luis Merino <mail@luismerino.name>
* @copyright Author
*/
class StaticFilesModel extends AgaviModel implements AgaviISingletonModel
{
protected $files = array();