Skip to content

Instantly share code, notes, and snippets.

View pateketrueke's full-sized avatar

Alvaro Cabrera Durán pateketrueke

View GitHub Profile
@pateketrueke
pateketrueke / mailer.class.php
Created March 20, 2013 20:51
Mailer class for built-in PHP mail()
<?php
class Mailer
{
protected $to = array();
protected $cc = array();
protected $bcc = array();
protected $reply = array();
protected $files = array();
@pateketrueke
pateketrueke / monolog_firephp.php
Created February 19, 2013 17:24
Use Mongolog with FirePHP handler on Habanero
<?php
$log = new \Monolog\Logger('MyApplication');
$log->pushHandler(new \Monolog\Handler\FirePHPHandler(\Monolog\Logger::DEBUG));
\Sauce\Config::set('logger', $log);
@pateketrueke
pateketrueke / github-widget.html
Created January 22, 2013 08:47
Habanero GitHub WIdget
<div class="github-widget" data-repo="pateketrueke/habanero"></div>
<script src="https://raw.github.com/JoelSutherland/GitHub-jQuery-Repo-Widget/master/jquery.githubRepoWidget.min.js"></script>
@pateketrueke
pateketrueke / kup.js.coffee
Last active December 10, 2015 05:58 — forked from anonymous/kup.js.coffee
CoffeeKup? plugin for jQuery
# taken from https://github.com/mauricemach/coffeekup
(($) ->
cache = {}
params = {}
params.locals = {}
params.format = on
@pateketrueke
pateketrueke / robot.js
Created December 6, 2012 00:27
Ek' Lamat
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(100);
@pateketrueke
pateketrueke / jquery-ujs.js
Last active October 12, 2015 13:38
Basic UJS handler from Habanero; jQuery 1.9.1+
(function($, undefined) {
$ujs = {
token: $('meta[name=csrf-token]').attr('content'),
fire: function(obj, name, data) {
var evt = $.Event(name);
obj.trigger(evt, data);
return evt.result !== false;
@pateketrueke
pateketrueke / sauce.less
Last active October 12, 2015 13:38
Custom LESS mixins from Habanero
// font-face mixin
.font(@path, @family, @weight: normal, @style: normal) {
@eot: asset-path("@{path}.eot");
@woff: asset-path("@{path}.woff");
@ttf: asset-path("@{path}.ttf");
@svg: asset-path("@{path}.svg");
@font-face {
src: url('@{eot}');
src: local("☺"),
@pateketrueke
pateketrueke / deploy.sh
Created November 7, 2012 22:58
Deploying with RSync (common)
#!/bin/sh
OPTIONS='-avlzC --progress --exclude-from exclude.txt --stats'
TRANSPORT='ssh -p 22'
CONNECTION='user@host.tld'
REMOTE_PATH='/var/www'
eval "rsync $OPTIONS -e '$TRANSPORT' . $CONNECTION:$REMOTE_PATH"
@pateketrueke
pateketrueke / region.php
Created October 5, 2012 15:06
Function to retrieve the IP location (fake)
<?php
function region($from)
{
static $url = 'http://www.geoiptool.com/?IP=%s';
$html = file_get_contents(sprintf($url, $from));
$html = strip_tags($html, '<a><span>');
@pateketrueke
pateketrueke / db-specs.php
Created September 6, 2012 16:11
Fancy db-handle specs with migrations (unnamed project)
<?php
# through DSN
$db = connect(...);
$tbl = 'my_table';
$col = 'my_column';