Skip to content

Instantly share code, notes, and snippets.

View samsonasik's full-sized avatar
🔥
I am doing very fast fix 🚀, sponsor me 💖 https://github.com/sponsors/samsonasik

Abdul Malik Ikhsan samsonasik

🔥
I am doing very fast fix 🚀, sponsor me 💖 https://github.com/sponsors/samsonasik
View GitHub Profile
@samsonasik
samsonasik / composer.json
Created June 10, 2016 12:49 — forked from harikt/composer.json
Get all the contributors from the repos of an organization
{
"require": {
"guzzlehttp/guzzle": "4.*"
}
}
@samsonasik
samsonasik / config
Created September 8, 2016 09:01 — forked from donnfelker/config
Watch or Unwatch a file in git
# Goes in your .git/config file
[alias]
# Temporarily stop tracking a file in git.
# usage: git unwatch path/to/file
unwatch = update-index --assume-unchanged
# Resume tracking a file in git.
# usage: git watch path/to/file
watch = update-index --no-assume-unchanged
@samsonasik
samsonasik / download-file-in-expressive.php
Created September 9, 2016 01:30 — forked from settermjd/download-file-in-expressive.php
Quick example of how to download/stream a file using Zend Expressive.
<?php
/**
* This is a quick example of how to stream a file to a client, likely a browser,
* using Zend Expressive. There are a lot of factors which it doesn't take in to
* account. But for the purposes of a quick intro, this should suffice.
*/
class ViewDocumentPageAction
{
protected function downloadFile()
{
IF (NOT EXISTS(SELECT * FROM QSYS2.SYSTABLES WHERE TABLE_SCHEMA = 'BACKUP' AND TABLE_NAME='MYTABLE')) THEN
CREATE TABLE BACKUP.MYTABLE
AS (SELECT * FROM MYLIB.MYTABLE)
WITH DATA;
ELSE
INSERT INTO BACKUP.MYTABLE
SELECT * FROM MYLIB.MYTABLE;
END IF;
<?php
copy(__DIR__ . '/music.db.original', __DIR__ . '/music.db');
include 'vendor/autoload.php';
return new Zend\Db\Adapter\Adapter(array(
// Sqlite Configuration
'driver' => 'Pdo',
'dsn' => 'sqlite:' . __DIR__ . '/music.db',
<?php
use Zend\Db\Sql\Select;
// basic table
$select0 = new Select;
$select0->from('foo');
// 'SELECT "foo".* FROM "foo"';
<?php
namespace MyFunnyValentine;
// Detect if the currently matched route belongs to this module.
// The assumption is that the controller name includes the module namespace.
class Module
{
public function onBootstrap($e)
<?php
namespace My\Modules\Authentication\Form;
use Zend\Form\Form;
use Zend\InputFilter\InputFilterProviderInterface;
class ChangePassword extends Form implements InputFilterProviderInterface
{
public function __construct()
@samsonasik
samsonasik / zenddbselectjoinunittest
Last active December 14, 2015 07:09 — forked from robertbasic/gist:5047567
Unit Test select Join Zend\Db
assume, i have a method in AlbumTable class like the following :
<?php
/////////
public function fetchAll()
{
$sqlSelect = $this->tableGateway->getSql()
->select()->columns(array('artist', 'title', 'id'))
->join('track', 'track.album_id = album.id', array(), 'left');
return $this->tableGateway->select($sqlSelect);
CREATE OR REPLACE FUNCTION public.json_append(data json, insert_data json)
RETURNS json
IMMUTABLE
LANGUAGE sql
AS $$
SELECT ('{'||string_agg(to_json(key)||':'||value, ',')||'}')::json
FROM (
SELECT * FROM json_each(data)
UNION ALL
SELECT * FROM json_each(insert_data)