Skip to content

Instantly share code, notes, and snippets.

Working from home

Achmad Fatoni achmadfatoni

Working from home
View GitHub Profile
achmadfatoni /
Created Jul 30, 2020 — forked from bradtraversy/
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months)

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

View generate_ssh_key
ssh-keygen -t rsa -b 4096 -C "achmadfatoni(replace with name)"
View fisher-yates-shuffle.php
* It's an algorithm for generating a random permutation of a finit sequence - in plain terms, the algorithm shuffles the sequence.
* Reference:
function MyShuffle(&$arr) {
achmadfatoni / ssl_nginx.conf
Last active Dec 26, 2017
letsencrypt laravel configuration
View ssl_nginx.conf
## and redirect to
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
include /etc/nginx/snippets/letsencrypt.conf;
location / {
return 301$request_uri;
View guzzle_raw_post_request.php
$client = new Client();
$array = [];
$res = $client->request('POST', $url, [
'body' => json_encode($array),
'headers' => [
'Content-Type' => 'application/json',
View delete_post
public function delete($id)
$post = Post::find($id);
if ($post) {
return response()->json([
'message' => 'Post has been deleted'
View simple_api_lumen_model
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
protected $table = 'posts';
achmadfatoni / simple_api_lumen_update_controller
Created Aug 18, 2017
View simple_api_lumen_update_controller
public function update(Request $request, $id)
$post = Post::find($id);
if ($post) {
return response()->json([
'message' => 'Post has been updated'
achmadfatoni / simple_api_lumen_single_controller
Created Aug 18, 2017
View simple_api_lumen_single_controller
public function show($id)
$post = Post::find($id);
if (! $post) {
return response()->json([
'message' => 'post not found'
return $post;
View simple_api_lumen_delete_route
$app->delete('/posts/{id}', 'PostController@delete');
You can’t perform that action at this time.