Skip to content

Instantly share code, notes, and snippets.

View dwihujianto's full-sized avatar
🌴
On vacation

Dwi Hujianto dwihujianto

🌴
On vacation
View GitHub Profile
@dwihujianto
dwihujianto / nginxproxy.md
Created January 29, 2017 14:39 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@dwihujianto
dwihujianto / gist:920be3fede06620ecb8dc80f98b0c138
Created February 10, 2017 12:06 — forked from kapkaev/gist:4619127
MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error. Resque
$ redis-cli
> config set stop-writes-on-bgsave-error no
@dwihujianto
dwihujianto / convert.js
Created March 21, 2017 05:54
NodeJs convert minutes to day,hour and minute
const convert = (minute) => {
const MINS_PER_DAY = 24 * 60
let minutes = minute
let days = Math.floor(minute / MINS_PER_DAY)
let hour = minutes - days * MINS_PER_DAY
hour = Math.floor(hour / 60)
minutes = minutes - (hour * 60) - days * MINS_PER_DAY
<?php
function convert_to_object($array) {
$object = new stdClass();
foreach ($array as $key => $value) {
if (is_array($value)) {
$value = convert_to_object($value);
}
<?php
$app = new TestApplication;
$app->run();
class TestApplication
{
public function run()
{
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;
class APIResponse
{
<?php
$number = '1.345.679';
$number = str_replace('.', '', $number);
$output = '';
$length = strlen($number) - 1 ;
<?php
use Carbon\Carbon;
function prettyDate($date)
{
setlocale(LC_TIME, 'id_ID.UTF-8');
return (new Carbon($date, config('app.timezone')))->formatLocalized('%A, %e %B %Y');
}
( 6371 * acos( cos( radians('" . $currentGpsLatitude . "') ) * cos( radians(gps_latitude) ) * cos( radians(gps_longitude) - radians('" . $currentGpsLongitude . "') ) + sin( radians('" . $currentGpsLatitude . "') ) * sin( radians(gps_latitude) ) ) ) AS distance")
<?php
namespace App\Services;
use App\Models\Project;
use App\Models\User;
use LaravelFCM\Facades\FCM;
use LaravelFCM\Message\OptionsBuilder;
use LaravelFCM\Message\PayloadDataBuilder;
use LaravelFCM\Message\PayloadNotificationBuilder;