Skip to content

Instantly share code, notes, and snippets.

View andergmartins's full-sized avatar

Anderson Grüdtner Martins andergmartins

View GitHub Profile
@andergmartins
andergmartins / scriptloader.js
Created September 28, 2012 03:59
Load external Javascript without blocking. Add an option to set a fallback URL, wich is loaded if the main URL fails.
/**
* scriptloader.js
*
* Script loader, specially for CDN fallback behavior.
* Adapted from Steve Souders code (thanks Steve) by
* Anderson G. Martins from Joomla Bamboo.
*
* Added the option to set a fallback URL, which will be used
* trying to load a local copy of the requested file.
*
@andergmartins
andergmartins / settings.py
Created October 4, 2012 15:03
Django - Fix locale.getdefaultlocale() for OS X 10.8
# Fix locale.getdefaultlocale() on OS X 10.8 - Mountain Lion
os.environ['LANG'] = 'en_US.UTF-8'
@andergmartins
andergmartins / joomla-load-menu-class-anywhere.php
Created October 14, 2012 22:59
Get Joomla menu item params anywhere
$app = JFactory::getApplication();
$menuItem = $app->getMenu()->getActive();
$pageclass_sfx = $menuItem->params->get('pageclass_sfx');
$bodyClass = !empty($pageclass_sfx) ? "class=\"item-page$pageclass_sfx\"" : '';
?>
<body <?= $bodyClass; ?>>
@andergmartins
andergmartins / fullscreen-bg-responsive.js
Created October 17, 2012 03:29
Fullscreen background image responsive
/**
* Fullscreen background image responsive
* @author Anderson G. Martins <andergmartins@gmail.com>
*/
(function ($) {
// Use image reload to fix empty dimensions
$.fn.imageSize = function(fn)
{
this.each(function() {
var img = new Image();
@andergmartins
andergmartins / podio_bigdump.py
Created November 21, 2012 23:52 — forked from gadamc/podio_bigdump.py
podio_bigdump
#!/usr/bin/env python
from pypodio2 import api
import sys, shutil, os, json
c = api.OAuthClient(sys.argv[1],sys.argv[2], sys.argv[3], sys.argv[4])
orginfo = c.transport.get(url = '/org/')
def writerawtext(filename, data):
try:
@andergmartins
andergmartins / k2-get-category-tree.php
Created January 29, 2013 18:55
K2 getCategoryTree function - Categorias recursivas
function getCategoryTree($categories){
$mainframe = &JFactory::getApplication();
$db = &JFactory::getDBO();
$user = &JFactory::getUser();
$aid = (int) $user->get('aid');
if(!is_array($categories)){
$categories = (array)$categories;
}
JArrayHelper::toInteger($categories);
$categories = array_unique($categories);
Ti.App.Properties.setList('DB_queue', []);
Ti.App.Properties.setBool('DB_locked', false);
Ti.App.Properties.setBool('DB_queue_running', false);
Ti.include('db.js', 'examples.js');
# https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-12-04
sudo apt-get update
sudo apt-get install mysql-server
sudo apt-get install nginx
sudo service nginx start
@andergmartins
andergmartins / cron.helper.php
Created March 1, 2013 17:08
Cron Job Helper - Lock, PID
<?php
/*
* From: http://abhinavsingh.com/blog/2009/12/how-to-use-locks-in-php-cron-jobs-to-avoid-cron-overlaps/
*/
define('LOCK_DIR', '/tmp/');
define('LOCK_SUFFIX', '.lock');
class CronHelper {
<form>
<div class="btn-group" data-toggle-name="is_private" data-toggle="buttons-radio" >
<button type="button" value="0" class="btn" data-toggle="button">Public</button>
<button type="button" value="1" class="btn" data-toggle="button">Private</button>
</div>
<input type="hidden" name="is_private" value="0" />
</form>