Skip to content

Instantly share code, notes, and snippets.

View remoharsono's full-sized avatar

Remo Harsono remoharsono

View GitHub Profile
@remoharsono
remoharsono / get_num_days.php
Created November 15, 2020 04:46
PHP | Get number of days
<?php
/**
* Source: https://stackoverflow.com/questions/2040560/finding-the-number-of-days-between-two-dates
* Saksham Gupta
*/
function getNumDays($dateStart, $dateEnd) {
$vDateStart = new DateTime($dateStart);
$vDateEnd = new DateTime($dateEnd);
$diff = $vDateEnd->diff($vDateStart)->format("%a");
@remoharsono
remoharsono / uuid_generator.php
Created November 10, 2020 02:14
RFC 4122-compliant UUID Generator
<?php
/*-
* Copyright (c) 2008 Fredrik Lindberg - http://www.shapeshifter.se
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
@remoharsono
remoharsono / scraping.php
Last active October 6, 2020 05:51
answering question on twitter
<?php
// https://twitter.com/the_paTiku/status/1276075890812878848
require 'vendor/autoload.php';
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\Request;
use DiDom\Document;
@remoharsono
remoharsono / backup_mysqldb.sh
Created April 12, 2020 12:36 — forked from skarllot/backup_mysqldb.sh
Bash script to backup all mysql databases thru mysqldump
#!/bin/bash
# Destiny folder where backups are stored
DEST=/tmp/bacula/server01
CURRDATE=$(date +"%F")
# Hostname where MySQL is running
HOSTNAME="srv-mysql"
# User name to make backup
USER="root"
@remoharsono
remoharsono / modern_js.md
Created March 26, 2020 00:04 — forked from gaearon/modern_js.md
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
@remoharsono
remoharsono / get_first_last_day.php
Created March 19, 2020 06:25
Get first day and last day of current month
<?php
$start_date_month = new DateTime("first day of this month");
$end_date_month = new DateTime("last day of this month");
echo $start_date_month->format('Y-m-d')."\n";
echo $end_date_month->format('Y-m-d');
@remoharsono
remoharsono / curl.md
Created March 6, 2020 07:11 — forked from btoone/curl.md
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API.

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@remoharsono
remoharsono / Artis
Created January 31, 2020 04:01
Artis
<?php
require __DIR__ . '/../vendor/autoload.php';
use Symfony\Component\Console\Application;
use Artis\App\Commands\CreateProject;
use Artis\App\Commands\CreateController;
use Artis\App\Commands\CreateModel;
use Artis\App\Commands\CreateView;
@remoharsono
remoharsono / htaccess
Created December 11, 2019 22:15
Code Igniter .htaccess Rewrite Rule
RewriteEngine On
# if the file with the specified name in the browser doesn’t exist,
# or the directory in the browser doesn’t exist then procede to the rewrite rule below
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# this is the last rule
RewriteRule ^(.*)$ index.php/$1 [L]
@remoharsono
remoharsono / simple_file_upload.php
Last active December 4, 2019 09:27
PHP :: Simple File Upload
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>.</title>
</head>
<body>
<?php
// namespace Remo\Upload;