Skip to content

Instantly share code, notes, and snippets.

@snetty
snetty / gist:97938d415c2c722f7f1bba88f9774a15
Created July 27, 2016 11:00 — forked from GreatPotato/gist:5445303
Gets the security details of a LS installation (including encryption key)
<?php
print_r( Phpr_SecurityFramework::create()->get_config_content() );
?>
@snetty
snetty / helper.php
Created March 3, 2016 12:00
adds git_hash helper for laravel
function http_build_url(array $parsed) {
$get = function ($key) use ($parsed) {
return isset($parsed[$key]) ? $parsed[$key] : null;
};
$pass = $get('pass');
$user = $get('user');
$userinfo = $pass !== null ? "$user:$pass" : $user;
$port = $get('port');
$scheme = $get('scheme');
@snetty
snetty / after.sh
Created October 21, 2015 08:58
Increase max_nesting_level in Laravel Homestead to cater for Pyro CMS (amongst others)
#!/bin/sh
# If you would like to do some extra provisioning you may
# add any commands you wish to this file and they will
# be run after the Homestead machine is provisioned.
xdebug="xdebug.max_nesting_level=300"
echo "$xdebug" > "/etc/php5/mods-available/xdebug.ini"
<?php
class My_Module extends Core_ModuleBase
{
public function subscribeEvents()
{
Backend::$events->addEvent('shop:onExtendCustomerModel', $this, 'extend_customer_model');
}

Keybase proof

I hereby claim:

  • I am snetty on github.
  • I am snetty (https://keybase.io/snetty) on keybase.
  • I have a public key whose fingerprint is D28B B2A5 BDC5 7341 72EF 02F6 5449 C89C F0AD F6FB

To claim this, I am signing this object:

@snetty
snetty / MyController.php
Created April 13, 2014 16:59
example laravel controller with ajax detection
public static function view($view){
return 'base.' . (Request::ajax() ?: 'ajax.') . $view;
}
public function create()
{
return View::make(self::view('create'), $this->viewVars());
}
<? $parents = $this->page->navigation_parents(false); ?>
<div class="breadcrumbs hidden-print">
<div class="container">
<ol class="breadcrumb">
<? $why = array(); $home = CMS_Page::findByUrl('/', $why); ?>
<li><a href="<?= $home->url ?>"><?= $home->navigation_label() ?></a></li>
<? foreach ($parents as $parent) : ?>
<li><a href="<?= $parent->url ?>"><?= $parent->navigation_label() ?></a></li>
<? endforeach; ?>
@snetty
snetty / blog:archive
Created November 8, 2013 09:59
lemonstand pagination usage
<?
$page_index = $this->request_param(-1, 1) - 1;
$records_per_page = 5;
$pagination = $posts->paginate($page_index, $records_per_page);
$posts = $posts->find_all();
?>
<? if($posts->count() != 0) : ?>
<div class="post_list">
<? foreach ($posts as $post): ?>
<? $this->render_partial('blog:post', array('post' => $post, 'base_url'=>$base_url, 'post_designation' => $post_designation)); ?>
@snetty
snetty / pagination
Created November 8, 2013 09:57
Lemonstand Pagination for Bootstrap
<?
$curPageIndex = $pagination->getCurrentPageIndex();
$pageNumber = $pagination->getPageCount();
$suffix = isset($suffix) ? $suffix : null;
?>
<? if($pageNumber != 1) : ?>
<div class="text-center">
<ul class="pagination">
<li>
<a href="#" class="disabled">
@snetty
snetty / extended_activerecord.php
Created May 21, 2013 12:09
Import form fields and columns from one model to another
<?php
class Extended_ActiveRecord extends Db_ActiveRecord{
public function import_column_definitions(Db_ActiveRecord $model, $context=null){
My_Helper::import_column_definitions($model, $this, $context);
}
public function import_form_field_definitions(Db_ActiveRecord $model, $context=null, $force_tab=null){
My_Helper::import_form_field_definitions($model, $this, $context, $force_tab);
}