Skip to content

Instantly share code, notes, and snippets.

View gbili's full-sized avatar

gbili gbili

View GitHub Profile
@gbili
gbili / nav
Created April 4, 2013 08:31
top nav
<a class="brand" href="<?php echo $this->url('home') ?>"><?php echo $this->translate('Miner Application') ?></a>
<div class="nav-collapse collapse">
<?php echo $this->navigation('Navigation')
->menu()
->setMinDepth(0)
->setMaxDepth(1)
->setUlClass('nav')
->render() ?>
<?php /*<ul class="nav">
<li class="active"><a href="<?php echo $this->url('home') ?>"><?php echo $this->translate('Home') ?></a></li>
@gbili
gbili / nav output
Created April 4, 2013 08:36
html in browser
<li class="active">
<a href="/engine">Engine</a>
<ul>
<li>
<a href="/engine/install">Install</a>
</li>
<li>
<a href="/engine/uninstall">Uninstall</a>
</li>
@gbili
gbili / bread
Created April 6, 2013 12:47
bread
<ul class="breadcrumb">
<?php $lastPageKey = count($this->pages) - 1?>
<?php var_dump($this->pages) //blank page?>
<?php foreach ($this->pages as $key => $page): // iterate through the pages?>
<li><?php get_class($pages) //error, expects object array given?></li>
<li>
<?php if ($key < $lastPageKey): // if this isn't the last page, add a link and the separator?>
<a href="<?= $page->getHref() ?>"><?= $page->getLabel() ?></a>
<span class="divider">/</span>
<?php else: // otherwise, just output the name ?>
@gbili
gbili / nav config
Last active December 15, 2015 21:29
navigation config array
<?php
return array(
'navigation' => array(
// The DefaultNavigationFactory we configured in (1) uses 'default' as the sitemap key
'default' => array(
// And finally, here is where we define our page hierarchy
'engine' => array(
'label' => 'Engine',
@gbili
gbili / AbstractContainer
Created April 6, 2013 14:20
AbstractContainer Trying to get all the branch of the current active page (all parent pages too)
<?php
class Zend\Navigation\AbstractContainer
...
public function getActiveBranch()
{
$found = array();
@gbili
gbili / get active pages
Created April 6, 2013 14:49
Error argument to getActive($active->getChildren()) is NULL whereas $active->hasChildren() is true :/
<ul class="breadcrumb">
<?php
function getActive(array $level) {
$activeInLevel = array_filter($level, function ($page) {
return $page->isActive(true);
});
return $activeInLevel[0];
}?>
<?php $p = $this->pages ?>
<?php $active = getActive($p); echo get_class($active); ?>
@gbili
gbili / gist:5501490
Last active December 16, 2015 21:39
<?php
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
$values = array_map(function($val) {
return "'".$val."'";
}, $this->values);
return "ENUM(".implode(", ", $values).") COMMENT '(DC2Type:".$this->name.")'";
}
@gbili
gbili / gist:5503007
Last active December 16, 2015 21:50
this is the script that im trying to run
<?php
use Gbili\Miner\BluePrint,
Gbili\Miner\BluePrint\Action\Extract\Savable as ExtractSavable,
Gbili\Miner\BluePrint\Action\GetContents\Savable as GetContentsSavable,
Gbili\Vid\Savable\Lexer;
$a = array();//actions
$b = new BluePrint\Savable();
$b->setHost('myhost.com');
$b->setBasePath('./../');

Connect with PHP PDO

`$pdo = new \PDO('odbc:MYMSSQL', 'myusername', 'mypass'); $pdostmt = $pdo->prepare('SELECT TOP 10 FROM dbo.MyTableName'); if (!$pdostmt) { throw new Exception('There was an error'); } if (false === $pdostmt->execute()) { throw new Exception('The pdo statement did not execute successfully'); }

function print() {
const filename = 'ThisIsYourPDFFilename.pdf';
html2canvas(document.querySelector('#nodeToRenderAsPDF')).then(canvas => {
let pdf = new jsPDF('p', 'mm', 'a4');
pdf.addImage(canvas.toDataURL('image/png'), 'PNG', 0, 0, 211, 298);
pdf.save(filename);
});
}