Skip to content

Instantly share code, notes, and snippets.

View alfianmalik's full-sized avatar
🎯
Focusing

Alfian Maulana Malik alfianmalik

🎯
Focusing
View GitHub Profile
@alfianmalik
alfianmalik / bitbucket-pipelines.yml
Created July 11, 2018 10:43 — forked from nasrulhazim/bitbucket-pipelines.yml
Laravel BitBucket Pipeline
# This is a sample build configuration for PHP.
# Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: php:7.2.1-fpm
pipelines:
default:
- step:
<?php
# Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
# http://creativecommons.org/publicdomain/zero/1.0/
function ampify($html='') {
# Replace img, audio, and video elements with amp custom elements
$html = str_ireplace(
['<img','<video','/video>','<audio','/audio>'],
<?php
$html = preg_replace( '/<img .*? src="([^"]*)" .*?>/', '<amp-img src="$1" width="600" height="400" layout="intrinsic" alt="AMP"></amp-img>', $html) !!}
@alfianmalik
alfianmalik / gateway.config.yml
Last active March 15, 2019 04:06
Express Gateway Example with Two Services (Multiple Services) :
http:
port: 8080
admin:
port: 9876
hostname: localhost
apiEndpoints:
serviceAPI:
host: localhost
paths: '/v1/*'
accountsAPI:
@alfianmalik
alfianmalik / default.conf
Last active March 18, 2019 04:20
PHP Apps (Laravel) in a Subdirectory in Nginx
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/top/public;
index index.html index.htm index.php;
server_name _;
@alfianmalik
alfianmalik / README.MD
Last active December 11, 2021 22:59
how to install protobuf + grpc + php on ubuntu

Hello, i am try to install protobuf + grpc + php, here is how i do

sudo apt install php-dev protobuf-compiler protobuf-compiler-grpc
sudo pecl channel-update pecl.php.net
sudo pecl install grpc protobuf

sudo -i
cd /etc/php/7.1/mods-available  
echo "extension=protobuf.so" &gt; protobuf.ini
curl -v -X GET https://api.sandbox.paypal.com/v1/activities/activities?start_time=2012-01-01T00:00:01.000Z&amp;end_time=2014-10-01T23:59:59.999Z&amp;page_size=10 \
-H "Content-Type: application/JSON" \
-H "Authorization: Bearer Access-Token"
<?php
$error = true;
$message = null;
if ($error) {
$message = 'You have encountered an error';
// Original variable type of null now cast to a string
}
<?php
declare(strict_types=1);
/**
* @param bool $error
* @param null $message
* @return string
*/
function printError(bool $error, $message = null): ?string
package errors
// Short variable assignement
err := false
// Inferred type assignment
var message string
if err == false {
message = nil
//Compiler error: cannot use nil as type string in assignment