Skip to content

Instantly share code, notes, and snippets.

View menjaraz's full-sized avatar

Menjanahary menjaraz

View GitHub Profile
@menjaraz
menjaraz / Excel.php
Last active August 29, 2015 14:00 — forked from barryvdh/Excel.php
<?php
use Illuminate\Support\Contracts\ArrayableInterface;
use Illuminate\Support\Contracts\JsonableInterface;
class Excel implements ArrayableInterface, JsonableInterface{
protected $objPHPExcel;
public function __construct($file){
<?php
require_once(VENDORS_PATH.DS.'PHPExcel'.DS.'PHPExcel.php');
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setCreator("Oka Prinarjaya")
->setLastModifiedBy("Oka Prinarjaya")
->setTitle("Test Export Data ke Dokumen Microsoft Excel");
$style = array(
@menjaraz
menjaraz / parse.php
Last active August 29, 2015 14:00 — forked from clouddueling/parse.php
<?php
// Turn XLS file into an array
require_once 'bundles/laravel-phpexcel/PHPExcel/IOFactory.php';
$objPHPExcel = PHPExcel_IOFactory::load($file_path);
$rows = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
// get the column names
$xls_fields = isset($rows[1]) ? $rows[1] : array();
if (! empty($xls_fields))

FiniteAuditTrail Trait

Support for keeping an audit trail for any state machine, borrowed from the Ruby StateMachine audit trail gem. Having an audit trail gives you a complete history of the state changes in your model. This history allows you to investigate incidents or perform analytics, like: “How long does it take on average to go from state a to state b?”, or “What percentage of cases goes from state a to b via state c?”

Requirements

  1. PHP >= 5.4
  2. Laravel 4 framework
<?php
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
class ViewsCommand extends Command {
/**
* The console command name.
*
* @var string
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ /public/$1 [L]
// blade extension for correct price formatting
// @money('15000');
Blade::extend(function($view, $compiler){
$pattern = '/@money\s?(\(.+?\)+)/is';
$replacement = "<?php echo (is_numeric(trim($1, '()')) ? number_format(trim($1, '()'), 0, '.', '\'') : trim($1, '()')); ?>";
return preg_replace($pattern, $replacement, $view);
});
<h1>About</h1>
module HTML {
export function elem(tag:string, content:string){
return "<" + tag + ">" + content + "</" + tag + ">"
}
export function div(inner:string[]){
return elem("div",inner.join(""))
}
export function p(content:string){
return elem("p",content)
require('typescript-require')({nodeLib: true});
require("./gulpfile.ts");