Skip to content

Instantly share code, notes, and snippets.

View sime's full-sized avatar
🔒
Trezor

Simon Males sime

🔒
Trezor
View GitHub Profile
@sime
sime / delete_cookie.js
Created July 15, 2011 02:49
Delete a cookie with JS
@sime
sime / schema.php
Created February 26, 2012 15:01
Possible example of using the CakePHP Schema callback `after` to insert content in the database
<?php
// Possible example of using the CakePHP Schema callback `after`
// to insert content in the database.
// Inspiration: https://github.com/majna/schema
// Copy schema.php to app/Config/Schema
// Run: ./Console/cake schema create
App::uses('ClassRegistry', 'Utility');
class AppSchema extends CakeSchema {
@sime
sime / database.php.pagoda
Created March 22, 2012 04:07
Pagoda Boxfile for CakePHP
<?php
// Source: http://help.pagodabox.com/customer/portal/articles/174049-cakephp#setting-global-server-variables-in-database-php
define("DB_HOST", $_SERVER['DB1_HOST']);
define("DB_NAME", $_SERVER['DB1_NAME']);
define("DB_USER", $_SERVER['DB1_USER']);
define("DB_PASS", $_SERVER['DB1_PASS']);
define("DB_PORT", $_SERVER['DB1_PORT']);
class DATABASE_CONFIG {
@sime
sime / AppController.php
Created August 27, 2012 21:58
Basic Auth in CakePHP on json request
class AppController extends Controller
{
public $components = array(
'RequestHandler',
'Auth',
);
public function beforeFilter() {
$this->__setupAuth();
@sime
sime / paradigm_startups.txt
Created October 17, 2012 03:26
Paradigm for Startups
Ideas are worthless without execution
Execution is worthless without traction
Traction is worthless without revenue
Revenue is worthless without profit
@sime
sime / canidothisbetter.rb
Created October 24, 2012 10:01
Am I this this in a nicer way?
if employee_skills.has_key?(skill_name) then
employee_skills[skill_name] += 1
else
employee_skills[skill_name] = 1
end
@sime
sime / gist:4490017
Created January 9, 2013 02:23
Build native MySQL gem extension when using MacPorts
$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql2 -- --with-mysql-config=/opt/local/lib/mysql55/bin/mysql_config
@sime
sime / core.php
Last active December 12, 2015 08:39
When running CakePHP on Heroku, by default you'll see file permission errors. The Heroku filesystem is read-only, but '/tmp' and '/log' are writable. To remove the errors update Config::config() in core.php
<?php
// Heroku Read-only Filesystem https://devcenter.heroku.com/articles/read-only-filesystem
/**
* Configure the cache used for general framework caching. Path information,
* object listings, and translation cache files are stored with this configuration.
*/
Cache::config('_cake_core_', array(
'engine' => $engine,
'prefix' => $prefix . 'cake_core_',
@sime
sime / gist:5079460
Last active December 14, 2015 11:28
Activemerchant requires older version of builder, which conflicts which activemodel?
$ ruby main.rb
/opt/local/lib/ruby1.9/1.9.1/rubygems/specification.rb:1637:in `raise_if_conflicts': Unable to activate activemodel-3.2.12, because builder-3.2.0 conflicts with builder (~> 3.0.0) (Gem::LoadError)
from /opt/local/lib/ruby1.9/1.9.1/rubygems/specification.rb:746:in `activate'
from /opt/local/lib/ruby1.9/1.9.1/rubygems/specification.rb:780:in `block in activate_dependencies'
from /opt/local/lib/ruby1.9/1.9.1/rubygems/specification.rb:766:in `each'
from /opt/local/lib/ruby1.9/1.9.1/rubygems/specification.rb:766:in `activate_dependencies'
from /opt/local/lib/ruby1.9/1.9.1/rubygems/specification.rb:750:in `activate'
from /opt/local/lib/ruby1.9/1.9.1/rubygems/custom_require.rb:51:in `block in require'
from /opt/local/lib/ruby1.9/1.9.1/rubygems/custom_require.rb:50:in `each'
from /opt/local/lib/ruby1.9/1.9.1/rubygems/custom_require.rb:50:in `require'
@sime
sime / migration.php
Created April 19, 2013 10:26
Migrating from string to integer primary keys in CakePHP
<?php
App::uses('AppShell', 'Console/Command');
class UserIdFromVarcharToInt extends CakeMigration {
public $description = '';
public $migration = array(
'up' => array(
'alter_field' => array(
'users' => array(