Skip to content

Instantly share code, notes, and snippets.

View loonies's full-sized avatar
👨‍💻
Working full time

loonies

👨‍💻
Working full time
View GitHub Profile
@atannus
atannus / kohana.php
Created July 6, 2013 19:38
Quick hack to allow Kohana to handle memory_limit and max_execution_time violations.
<?php defined('SYSPATH') or die('No direct script access.');
class Kohana extends Kohana_Core {
/**
* Augments the core method for two reasons:
* 1) Reserve an extra 1M memory to allow handling memory_limit violation.
* 2) Reserve more exec time to allow max_execution_time violation.
*
* Note: keep variable creation at a minimum.
@kasparsd
kasparsd / wordpress-plugin-svn-to-git.md
Last active April 17, 2024 12:35
Using Git with Subversion Mirroring for WordPress Plugin Development
@aliuygur
aliuygur / countries_list.php
Last active August 27, 2021 08:08
Function: Countries (php countries list array)
<?php
/**
* Countries List
* @return array
*/
function countries()
{
$countries = Array(
'AF' => 'Afghanistan',
@naholyr
naholyr / block-social-networks.sh
Created December 21, 2011 15:09
Bash Pomodoro using libnotify
#!/bin/bash
# Destination: ~/.pomodoro/hooks/work.d/
# Goal: block access to Twitter and Facebook while in a Pomodoro
# Note: won't work if you use Chrome, as it maintains an internal (not flushable from CLI) DNS cache. Fuck it.
# This file must be able to touch "/etc/hosts":
# The best way would be to create a group able to modify the "/etc/hosts" file:
# $ sudo addgroup host-manager
# $ sudo chgrp host-manager /etc/hosts
@loonies
loonies / 1_phpunit-api.md
Last active January 19, 2024 07:34
PHPUnit Cheat Sheet

PHPUnit API reference

  • version 3.6

TODO

Check those constraints:

$this-&gt;anything()
<?php
class Pagination {
public static function factory($total, $limit = 5, $page = 1, $adjacents = 2)
{
return new Pagination($total, $limit, $page, $adjacents);
}
public $total;
@lukemorton
lukemorton / Controller_News.php
Created September 19, 2011 09:47
Dealing with pagination in MVVM
<?php
class Controller_News {
public function action_category()
{
$category = ORM::factory('news_category', array('url' => $this->request->param('category')));
if ( ! $category->loaded())
{
@zeelot
zeelot / bla.php
Created August 21, 2011 18:03 — forked from kiall/bla.php
Valid::at_least()
<?php defined('SYSPATH') or die('No direct script access.');
class Model_Bla extends ORM {
public function rules()
{
return array(
'phone_one' => array(
array('at_least', array(':validation', 1, array('phone_one', 'phone_two', 'phone_three'))),
),
#!/bin/sh
git submodule status | awk '{ print $2 "/classes" }' | xargs ./phpcs.sh application/bootstrap.php index.php install.php | grep -F -e '| ERROR' -e '| WARNING' | wc -l
class Debug extends Kohana_Debug {
public static function vars()
{
if (func_num_args() === 0)
return;
$backtrace = debug_backtrace();
$path = $backtrace[0]['file'];
$filename = Debug::path($path);