Skip to content

Instantly share code, notes, and snippets.

View marcogrueter's full-sized avatar

Marco Grüter marcogrueter

  • CH - Steinhausen
View GitHub Profile
// zuerst data attribute an felder anhängen, dann parsley initialisieren
// vorname muss eingegeben werden und mind. 3 zeichen enthalten
$('#contact_vorname').data('parsleyRequired', 'true');
$('#contact_vorname').data('parsleyMinlength', 3);
// init parsley
$('#form').parsley();
@marcogrueter
marcogrueter / seeder.php
Last active August 29, 2015 14:27
seeding with faker in pyrocms
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/*
* Use faker in pyrocms:
* 1. create composer.json in installation root
* content:
* {
* "require-dev": {
* "fzaninotto/Faker": "dev-master"
* }
<?php defined('BASEPATH') or exit('No direct script access allowed');
/**
* PyroStreams Text Field Type
*
* extended field type based on the basic text field type, mgr
*
* @package PyroStreams
* @author PyroCMS Dev Team
* @copyright Copyright (c) 2011 - 2013, PyroCMS
@marcogrueter
marcogrueter / helpers.php
Created April 10, 2014 09:46
helpers.php - output instead of yields for laravel 3
<?php
/**
* Convert HTML characters to entities.
*
* The encoding specified in the application configuration file will be used.
*
* @param string $value
* @return string
*/
@marcogrueter
marcogrueter / blade.php
Created April 10, 2014 09:45
blade.php - output instead of yield
<?php namespace Laravel; use FilesystemIterator as fIterator; use Closure;
class Blade {
/**
* All of the compiler functions used by Blade.
*
* @var array
*/
protected static $compilers = array(
@marcogrueter
marcogrueter / section.php
Created April 10, 2014 09:44
section.php - with output instead of yield
<?php namespace Laravel;
class Section {
/**
* All of the captured sections.
*
* @var array
*/
public static $sections = array();
@marcogrueter
marcogrueter / progress-cmd-line.php
Created October 18, 2013 07:38
Percentage progress bar on cmd line in php
$data = getData();
$step = 100 / count($data);
$percent = 0;
echo 'Doing stuff with data: '; //padding at the end for the number
foreach($data as $row)
{
// do stuff
@marcogrueter
marcogrueter / exce_column.php
Created September 19, 2013 14:45
get the correct excel style column name
// $c=1 -> A
// $c=27 -> AA
// combine with the row index to get the correct cell identifier,
// e.g.
// $column = _excel_column(26);
// $cell = $columns . '3'; // = Z3
public function _excel_column($c)
{
@marcogrueter
marcogrueter / excel.php
Created September 19, 2013 14:19
php excel library
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once SHARED_ADDONPATH."modules/[DEIN MODUL]/libraries/[PFAD UND SO HALT]/PHPExcel.php";
class Excel extends PHPExcel {
// $this->load->library('Excel');
// dann:
// benutzern mit $this->excel->[PHPExcel Funktionen und so]
@marcogrueter
marcogrueter / sort-array
Created September 17, 2013 15:16
sort any array in php with strnatcasecmp
// just make sure the $sort_by key exists in $data
public function sort_entries(&$data, $sort_by = false)
{
if( ! $sort_by )
{
$sort_by = 'sort';
}
usort($data, function($a, $b) use($sort_by) {
return strnatcasecmp($a[$sort_by], $b[$sort_by]);