Skip to content

Instantly share code, notes, and snippets.

View rizqidjamaluddin's full-sized avatar

Rizqi Djamaluddin rizqidjamaluddin

  • Jakarta, Indonesia
View GitHub Profile
@rizqidjamaluddin
rizqidjamaluddin / SomeDistantApiGateway.php
Created May 13, 2015 12:02
Laravel API gateway classes with a service provider and config file
<?php
class SomeDistantApiGateway {
public function __construct($apiKey) {
$this->apiKey = $apiKey;
}
public function getSomeData() {
// whatever API request over guzzle or something
@rizqidjamaluddin
rizqidjamaluddin / gist:61cd7f61ca36cf5c2d5a
Last active February 19, 2020 22:01
Run a bunch of phpunit tests in sequence via Laravel 4's artisan CLI
<?php
use Illuminate\Console\Command;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class RunTests extends Command
{
import {expect} from "chai";
import {PandoraContainer} from "../../src/container/pandora.container";
import {BindingNotFoundException} from "../../src/container/support/binding-not-found.exception";
import {Inject} from "../../src/container/inject";
export function start(): PandoraContainer {
return new PandoraContainer;
}
export class Foo {
FROM php:7.1-fpm
RUN apt-get update && apt-get install -y \
curl \
libssl-dev \
zlib1g-dev \
libicu-dev \
libmcrypt-dev \
libmagickwand-dev \
libmagickcore-dev
<?php
$file = fopen("src.txt", 'r');
$out = fopen("result.csv", 'w');
fputcsv($out, ['first_name', 'last_name', 'address', 'city', 'state', 'zip']);
$buffer = [];
$counter = 0;

Contract Elements

Description of Services

  • List services rendered
  • Explicitly state that services are limited to the following deliverables, and any change to either services or deliverables will necessitate a new or appended contract

Deliverables

  • List every kind of deliverable: digital files, media files etc
<?php
// this is another kind of user.
class Admin extends Model {
protected $fillable = ['public_key'];
public function identity() {
return $this->morphMany(Identity::class, 'identifiable');
}
SOME_API_KEY=12345
@rizqidjamaluddin
rizqidjamaluddin / ArticleRepository.php
Last active December 21, 2015 13:12
Generic Eloquent repository example
<?php
class ArticleRepository {
/**
* Because of how Eloquent works, an instance of a model is also a starting point to
* execute queries on it. This class should be instantiated by Laravel's IoC (e.g.
* constructor injection on a higher class, or App::make) so you never actually should
* need to do "new ArticleRepository(new Article)".
*
@rizqidjamaluddin
rizqidjamaluddin / User.php
Created October 26, 2015 03:49
Base set of classes for more complex features - NOT a "pattern" to be followed like you will be cursed for not adhering to, if you use an unnecessary factory I will hunt you down with a super soaker
<?php
/**
* @property int $id
* @property string $email
* @property string $password
* @property Carbon $created_at
*/
class User extends Model {