Skip to content

Instantly share code, notes, and snippets.

View antoniputra's full-sized avatar
🏠
Working from home

Antoni Putra antoniputra

🏠
Working from home
View GitHub Profile
@saninmersion
saninmersion / axios_interceptor_in_vue_app_component.js
Last active January 7, 2020 15:15
Axios Interceptor in vue js main app component
new Vue({
el: "#app",
mounted() {
this.enableInterceptor()
},
data: {
isLoading: false,
axiosInterceptor: null,
},
methods: {
<?php
/**
* Example of useless Repository abstraction for Eloquent.
* From "Architecture of complex web applications" book.
* https://adelf.tech/2019/architecture-of-complex-web-applications
*/
interface PollRepository
{
//... some other actions
<?php
require __DIR__ . '/vendor/autoload.php';
$dsn = 'mysql:dbname=db1;host=127.0.0.1';
$user = 'root';
$password = '(disensor)';
try {
$dbh = new PDO($dsn, $user, $password);
@achmadfatoni
achmadfatoni / ssl_nginx.conf
Last active December 26, 2017 21:15
letsencrypt laravel configuration
## http://domain.com and http://www.domain.com redirect to https://www.domain.com
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name domain.com www.domain.com;
include /etc/nginx/snippets/letsencrypt.conf;
location / {
return 301 https://www.domain.com$request_uri;
@achmadfatoni
achmadfatoni / Laravel PHP7 LEMP and Mysql
Last active September 24, 2019 08:43 — forked from santoshachari/Laravel PHP7 LEMP AWS.md
Laravel 5.x on Ubuntu 16.x, PHP 7.x, Nginx 1.9.x and Mysql
#Steps to install latest Laravel, LEMP on AWS Ubuntu 14.4 version.
This tutorial is the improvised verision of this [tutorial on Digitalocean](https://www.digitalocean.com/community/tutorials/how-to-install-laravel-with-an-nginx-web-server-on-ubuntu-14-04) based on my experience.
## Install PHP 7 on Ubuntu
Run the following commands in sequence.
```
sudo apt-get install -y language-pack-en-base
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install zip unzip
@vluzrmos
vluzrmos / paginate.php
Created July 20, 2016 14:31
Laravel Paginate Collection or Array
<?php
/**
* Gera a paginação dos itens de um array ou collection.
*
* @param array|Collection $items
* @param int $perPage
* @param int $page
* @param array $options
*
* @return LengthAwarePaginator
@antoniputra
antoniputra / README.md
Created February 11, 2016 16:23 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@learncodeacademy
learncodeacademy / webpack.config.js
Created January 8, 2016 03:55
Sample Basic Webpack Config
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
module.exports = {
context: __dirname,
devtool: debug ? "inline-sourcemap" : null,
entry: "./js/scripts.js",
output: {
path: __dirname + "/js",
filename: "scripts.min.js"
@arryanggaputra
arryanggaputra / FirstImage.php
Last active September 3, 2015 09:34
Get first image, if there's no image give the default Image URL
<?php
preg_match_all('~<img ([^>]+)>~i', $yourLongArticle, $matches);
$images = [];
foreach ($matches[1] as $str) {
preg_match_all('~([a-z]([a-z0-9]*)?)=("|\')(.*?)("|\')~is', $str, $pairs);
$images[] = array_combine($pairs[1], $pairs[4]);
}
if (!empty($images[0])) {
return $images[0]['src'];
}