Skip to content

Instantly share code, notes, and snippets.

View remoharsono's full-sized avatar

Remo Harsono remoharsono

View GitHub Profile
@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 / Api.php
Last active November 27, 2019 04:12
Reusing token in Codeception
<?php
namespace Helper;
class Api extends \Codeception\Module
{
public $credentials = array(
'username' => 'remo',
'password' => '12345678'
);
@remoharsono
remoharsono / html_purifier.php
Last active November 22, 2019 12:10
Sample script removing script and applet tag from HTML document
<?php
require 'vendor/autoload.php';
$html = "<!DOCTYPE html><html><head><title>.</title></head><body><h1>Welcome to the jungle</h1><script>var x=10;</script><script>alert('this is an alert');</script></body></html>";
$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.ForbiddenElements', array('script','applet'));
$purifier = new HTMLPurifier($config);
$clean= $purifier->purify($html);
echo $clean;
@remoharsono
remoharsono / php_adodb_hasmany.php
Created November 22, 2019 09:10
PHP ADOdb Active Record | TableHasMany
<?php
require 'adodb/adodb.inc.php';
require 'adodb/adodb-active-record.inc.php';
define("DB_DRIVER", "mysqli");
define("DB_HOST", "localhost");
define("DB_USERNAME", "root");
define("DB_PASSWORD", "");
define("DB_NAME", "test");
define("DB_CHARSET", "UTF-8");
@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;
@remoharsono
remoharsono / upload_01.php
Last active November 17, 2019 01:48
PHP :: Basic File Upload
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>.</title>
</head>
<body>
<?php
if (isset($_POST['submit'])) {
define("UPLOAD_FOLDER", "uploads");
@remoharsono
remoharsono / adodb_one_to_many.php
Created November 14, 2019 09:48
PHP ADOdb Active Record - One to Many
<?php
include('adodb/adodb.inc.php');
include('adodb/adodb-active-record.inc.php');
$driver = 'mysqli';
$server = 'localhost';
$user = 'root';
$password = 'secret';
$database = 'mydb';