Skip to content

Instantly share code, notes, and snippets.

View kargirwar's full-sized avatar

Pankaj Kargirwar kargirwar

View GitHub Profile
@kargirwar
kargirwar / example.go
Last active October 28, 2017 08:27
Amber example
import "github.com/eknkc/amber"
...
//path is the directory containing home.amber and header.amber
templates, err := amber.CompileDir(path, amber.DefaultDirOptions, amber.DefaultOptions)
//error handling
...
type temp struct {
Name string
@kargirwar
kargirwar / mixin.pug
Created October 28, 2017 12:15
PHP pug mixin
mixin row(c1, c2, c3, c4)
tr
td= c1
td= c2
td= c3
td= c4
@kargirwar
kargirwar / iteration.pug
Created October 28, 2017 12:19
PHP pug example
tbody
each val, index in data
+row(val['c1'], val['c2'], val['c3'], val['c4'])
@kargirwar
kargirwar / iteration.pug
Created October 28, 2017 12:19
PHP pug example
tbody
each val, index in data
+row(val['c1'], val['c2'], val['c3'], val['c4'])
@kargirwar
kargirwar / render.php
Last active November 15, 2017 16:06
PHP pug example
<?php
function getContent()
{
$pug = new \Pug\Pug([
'basedir' => __DIR__ . '/templates',
]);
return $pug->renderFile('mail.pug', [
'name' => "Example User",
'data' => [
['c1' => 'v11', 'c2' => 'v12', 'c3' => 'v13', 'c4' => 'v14'],
<?php
//Client.php
function __construct() {
# create our client object
$this->mClient = new \GearmanClient();
# add the default server (localhost)
$this->mClient->addServer();
}
<?php
public function run(string $user) {
$this->mClient->doBackground(self::JOB_TYPE_REPORT, $user);
if ($this->mClient->returnCode() != GEARMAN_SUCCESS) {
throw new \Exception("Fatal Error");
}
}
<?php
function __construct() {
# Create our worker object.
$this->mWorker = new \GearmanWorker();
# Add default server (localhost).
$this->mWorker->addServer();
$this->mWorker->addFunction(Client::JOB_TYPE_REPORT, [$this, "report"]);
}
<?php
public function run() {
while ($this->mWorker->work()) {
if ($this->mWorker->returnCode() != GEARMAN_SUCCESS) {
throw new \Exception("Fatal Error");
}
}
}
public function report(\GearmanJob $job) {
//simulate long running task
paths:
migrations: %%PHINX_CONFIG_DIR%%/db/migrations
seeds: %%PHINX_CONFIG_DIR%%/db/seeds
environments:
default_migration_table: phinxlog
default_database: development
production:
adapter: mysql
host: localhost