Skip to content

Instantly share code, notes, and snippets.

View mikedfunk's full-sized avatar

Mike Funk mikedfunk

View GitHub Profile
@mikedfunk
mikedfunk / README.md
Created November 2, 2012 23:22
CodeIgniter Checkbox Helper

Checkbox Helper

Just a tiny helper to help with checkboxes. When you uncheck a checkbox, it's value does not get sent in the form values. Instead of telling CodeIgniter you want to set this value to 0, it says "don't change it." This fixes that, one by one, by setting the value of the associated $_POST array item to zero. You can also pass in an array of checkbox names and it will do each one.

Usage

$this->load->helper('checkbox');

// set post values to zero for unchecked boxes
fix_unchecked(['is_active', 'is_enabled', 'is_verified']);
@mikedfunk
mikedfunk / laravel_snippets.md
Last active May 18, 2019 19:19
Laravel Snippets

Laravel Snippets

Join a table to itself

e.g. a category that can have a parent_id which is another category

public function parent()
{
    return Category::where('id', '=', $this->category_id)->first();

Keybase proof

I hereby claim:

  • I am mikedfunk on github.
  • I am mikedfunk (https://keybase.io/mikedfunk) on keybase.
  • I have a public key ASAEZAylS80Q6A2JT9tOWkVAa_B8fUGx_xSpbAc5ba5XRgo

To claim this, I am signing this object:

@mikedfunk
mikedfunk / README.md
Last active March 28, 2019 15:48
Example satis.json.

Example Satis setup

  1. Get Composer
  2. Install satis in your localhost root: composer create-project composer/satis --stability=dev
  3. Put this satis.json file in the satis dir
  4. satis/bin/satis satis/satis.json satis/www/ to generate packages.json
  5. In your project, add the "repositories" section of composer.json above
  6. add to your require object as usual in composer.json. Dependencies will come from Satis.
  7. Browse to http://localhost/satis/www to see your local Satis package directory
<?php declare(strict_types=1);
namespace MyApp\Adapter\Repository\Couchbase;
use MyApp\Exception\DocumentIsLockedException;
class LockHandler
{
// ...
<?php declare(strict_types=1);
namespace MyApp\Adapter\Repository\Couchbase;
use CouchbaseException;
use MyApp\Exception\DocumentIsLockedException;
class CartRepository
{
<?php declare(strict_types=1);
namespace MyApp\Adapter\Repository\Couchbase;
use CouchbaseException;
class LockableRepository
{
// ....
<?php declare(strict_types=1);
namespace MyApp\Adapter\Couchbase;
use CouchbaseException;
/** Releases all couchbase locks that are tracked. */
class LockReleaser
{
// ...
#### FIRST ln -s ~/[numeric-www-folder] ~/httpdocs
# watchr
gem install watchr
# phpunit
mkdir ~/bin/
echo "bin" >> .gitignore
wget http://pear.phpunit.de/get/phpunit.phar -P ~/bin/
chmod +x ~/bin/phpunit.phar
@mikedfunk
mikedfunk / couchbase-userscript.user.js
Last active April 21, 2018 05:38
Couchbase userscript
// ==UserScript==
// @name Couchbase authentication fix
// @description Fixes couchbase's inability to save password.
// @include http://couch.local.*.com/ui/index.html*
// @include http://couch*.*.aws.*.com:*/ui/index.html*
// @version 1.0
// ==/UserScript==
function fixAutoComplete () {
setTimeout(function () {