Skip to content

Instantly share code, notes, and snippets.

View brutuscat's full-sized avatar

Mauro Asprea brutuscat

View GitHub Profile
import base64
from django.utils import simplejson
import urllib
from google.appengine.api import urlfetch
def track(event, properties=None):
"""
A simple function for asynchronously logging to the mixpanel.com API on App Engine
(Python) using RPC URL Fetch object.
@param event: The overall event/category you would like to log this data under
@coolaj86
coolaj86 / node_reinstall.sh
Last active September 24, 2015 16:17
Install Node.JS on Mac OS X or Linux
NUMBER_OF_CPU_CORES=2
BASHRC=~/.bashrc # use .bash_profile on OS X
# Remove old Node.JS installation
rm ~/local/*/node* -rf
rm ~/.node_libraries -rf
sudo rm /usr/local/*/node* -rf
sudo rm /usr/*/node* -rf
@brutuscat
brutuscat / ExceptionThrower.php
Created February 17, 2011 09:38
Utility for catching PHP errors, warnings and notices, then converting them (throwing) to an exception that can be caught at runtime @author Jason Hinkle - http://verysimple.com/2010/11/02/catching-php-errors-warnings-and-notices/ @copyright 1997-20
<?php
/**
* Utility for catching PHP errors and converting them to an exception
* that can be caught at runtime
* @author Jason Hinkle
* @copyright 1997-2011 VerySimple, Inc.
* @license http://www.gnu.org/licenses/lgpl.html LGPL
* @version 1.0
*/
class ExceptionThrower
@NuarHaruha
NuarHaruha / blogspot-template.xml
Created September 10, 2011 18:21
SEO friendly TITLE for blogspot.com
<b:if cond='data:blog.url == data:blog.homepageUrl'>
<title><data:blog.title/> - blog description </title>
<b:else/>
<b:if cond='data:blog.pageType == &quot;index&quot;'>
<title><data:blog.pageName/> - <data:blog.title/> - blog description </title>
<b:else/>
<b:if cond='data:blog.pageType == &quot;static_page&quot;'>
<title><data:blog.pageName/> - <data:blog.title/></title>
<b:else/>
<b:if cond='data:blog.pageType == &quot;item&quot;'>
@ashleydw
ashleydw / PostProcess.php
Created October 18, 2011 09:04
Zend Framework Controller Plugin to allow post output processing
<?php
/**
* Zend Framework Controller Plugin to allow post output processing
*
* @version 1
* @author Ashley White, http://www.needathinkle.com/
* @license http://creativecommons.org/licenses/by-sa/3.0/
*/
final class Thinkle_Controller_Plugin_PostProcess extends Zend_Controller_Plugin_Abstract {
@johnkary
johnkary / WSSoapClient.php
Created June 27, 2012 20:08
WS-Security for PHP SoapClient
<?php
/**
* Copyright (c) 2007, Roger Veciana
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
@fousa
fousa / content.rb
Created July 12, 2012 15:09
Devise Generate Token
Devise.friendly_token
@woods
woods / enable_trim.sh
Created August 12, 2012 20:19
Enable TRIM support for 3rd Party SSDs. Works for Mountain Lion.
#!/bin/bash
#
# Enable TRIM support for 3rd Party SSDs. Works for Mountain Lion
#
# Source: http://digitaldj.net/2011/07/21/trim-enabler-for-lion/
set -e
set -x
# Back up the file we're patching
@mudge
mudge / gist:4111082
Created November 19, 2012 14:53
Capistrano task to use relative symlinks instead of absolute.
require "pathname"
namespace :deploy do
task :create_symlink, :except => { :no_release => true } do
deploy_to_pathname = Pathname.new(deploy_to)
on_rollback do
if previous_release
previous_release_pathname = Pathname.new(previous_release)
relative_previous_release = previous_release_pathname.relative_path_from(deploy_to_pathname)
@mscoutermarsh
mscoutermarsh / application.rb
Created December 15, 2012 18:35
CORS - rails/grape
# Add this to your application.rb
config.middleware.use Rack::Cors do
allow do
origins '*'
# location of your API
resource '/api/*', :headers => :any, :methods => [:get, :post, :options, :put]
end
end