Skip to content

Instantly share code, notes, and snippets.

View cmbirk's full-sized avatar

Chris Birk cmbirk

View GitHub Profile
@cmbirk
cmbirk / dbsync
Last active December 10, 2015 23:08
Bash command to help sync local db with remote server
#!/bin/bash -x
usage()
{
cat << EOF
usage: $0 options
OPTIONS:
-h Show this message
@cmbirk
cmbirk / Git ignore locally removed directory
Last active October 13, 2015 20:27
Git Ignore Locally removed directory (wp-admin)
find wp-admin -type f -print0 | git update-index --assume-unchanged -z --stdin
@cmbirk
cmbirk / Global WP Site Options
Last active October 8, 2015 17:18
Global WP Site Options
/** Global Site Options */
!defined('WP_SITEURL') && define('WP_SITEURL', "http://{$_SERVER['HTTP_HOST']}");
!defined('WP_HOME') && define('WP_HOME', WP_SITEURL);

Contract Killer

The popular open-source contract for web designers and developers by Stuff & Nonsense

  • Originally published: 23/12/2008
  • Revised date: 15/12/2013
  • Original post

@cmbirk
cmbirk / gist:f3c528a7707beccbaa76
Created April 8, 2015 20:54
Laravel display all queries
//Thanks to http://laravel-tricks.com/tricks/display-all-sql-executed-in-eloquent
//Put this in your routes.php file
// Display all SQL executed in Eloquent
Event::listen('illuminate.query', function($query)
{
var_dump($query);
});
@cmbirk
cmbirk / gist:dc352ac20d3869cc8b71
Created January 13, 2015 20:30
Angular ui-router Loading Indicator
A fairly simple and generic solution would be determining currently resolved ui-view by element hierarchy.
Create a directive and assign it to your ui-view elements. Example:
<div ui-view state-loader>
<div ui-view state-loader></div>
</div>
The directive will use the $stateChangeStart events to decide whether current ui-view is the one being resolved and add relevant classes. Example:
angular.module('myApp')
.directive('stateLoader', function stateLoader() {
return {
@cmbirk
cmbirk / gist:a34b7020c3a15ada7ff0
Created January 13, 2015 20:30
Angular ui-router Loading Indicator
A fairly simple and generic solution would be determining currently resolved ui-view by element hierarchy.
Create a directive and assign it to your ui-view elements. Example:
<div ui-view state-loader>
<div ui-view state-loader></div>
</div>
The directive will use the $stateChangeStart events to decide whether current ui-view is the one being resolved and add relevant classes. Example:
angular.module('myApp')
.directive('stateLoader', function stateLoader() {
return {
<?php
/*
* Translate a non-standard object into an associative array object.
* Super-useful for dealing with simplexml objects.
*/
function simpleXML_to_object($obj)
{
$data = new StdClass();
if(
(is_object($obj) && get_class($obj) == 'SimpleXMLElement')
@cmbirk
cmbirk / gist:e5b39ea77aee1e1c49aa
Created July 10, 2014 19:11
Trying to combine multiple ManyToMany Relationships
public function sponsor()
{
$sponsor = $this->belongsToMany('Group')->first();
if(!$sponsor) {
return $this->belongsToMany('User');
}
return $this->belongsToMany('Group');
@cmbirk
cmbirk / friday.js
Created February 22, 2014 19:10 — forked from krusynth/friday.js
function friday(e) {
if(e) {
// Not doin' nothin', it's Friday.
e.preventDefault();
}
/************$~I**************************Z*********************************
***********O,7.++O$+********************O,..ZI******************************
***********$..$.78.$******************$...7+. ~Z*******************+********
***********.Z.~.7D.O****************O,...,+. ....+Z*************7O+77I*+****