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
package main
import (
"fmt"
"math/rand"
)
func main() {
var recursiveAnonymous func(i int)
recursiveAnonymous = func(i int) {
ps aux --sort -rss | head -n5
@dwihujianto
dwihujianto / leaflet_numbered_markers.css
Created August 24, 2020 02:30 — forked from comp615/leaflet_numbered_markers.css
Numbered Markers in Leaflet (JS Mapping)
.leaflet-div-icon {
background: transparent;
border: none;
}
.leaflet-marker-icon .number{
position: relative;
top: -37px;
font-size: 12px;
width: 25px;
@dwihujianto
dwihujianto / ftp.sh
Created June 24, 2020 06:44
Deploy with ftp init
# Setup
git config git-ftp.url "ftp://ftp.example.net:21/public_html"
git config git-ftp.user "ftp-user"
git config git-ftp.password "secr3t"
# Upload all files
git ftp init
# Or if the files are already there
git ftp catchup
<?php
public function workDay()
{
$aDates = [];
$aDateRanges = \Carbon\CarbonPeriod::create('2020-01-01', '2020-01-23');
foreach ($aDateRanges->toArray() as $date) {
$aDates[] = $date->format('Y-m-d');
}
<?php
function transform_tree($categories) {
$data = [];
foreach($categories as $key => $category) {
$data[$key] = [
'name' = $category->name
];
if ($category->children) {
<?php
public function statusPerYear(string $year) : array
{
$query = "
select DATE_FORMAT(end_date, '%b-%y') month,
sum(CASE WHEN status = 4 THEN 1 ELSE 0 END) ongoing,
sum(CASE WHEN status = 8 THEN 1 ELSE 0 END) success,
sum(CASE WHEN status = 6 THEN 1 ELSE 0 END) failed,
sum(CASE WHEN status = 10 THEN 1 ELSE 0 END) cancel
from
SELECT DATE_FORMAT(merge_date,'%m-%Y') AS month FROM (
SELECT '2015-01-01' AS merge_date
UNION SELECT '2015-02-01' AS merge_date
UNION SELECT '2015-03-01' AS merge_date
UNION SELECT '2015-04-01' AS merge_date
UNION SELECT '2015-05-01' AS merge_date
UNION SELECT '2015-06-01' AS merge_date
UNION SELECT '2015-07-01' AS merge_date
UNION SELECT '2015-08-01' AS merge_date
UNION SELECT '2015-09-01' AS merge_date
@dwihujianto
dwihujianto / laravel-worker-with-pm2.sh
Created February 26, 2019 09:52
Laravel Queue with Pm2
pm2 start artisan --name laravel-worker --interpreter php -- queue:work --daemon
<?php
// model student
class Student extends Model
{
}
// user oberserver
class UserObserver
{