Skip to content

Instantly share code, notes, and snippets.

View joko-wandiro's full-sized avatar
:octocat:
😄 👍

Joko Wandiro joko-wandiro

:octocat:
😄 👍
  • -
  • Jakarta, Indonesia
View GitHub Profile
<?php
header('content-type: text/plain; charset=utf-8');
// Display triangle
$str_arr=array();
for($i=1; $i<=5; $i++){
if( $i == 3 || $i == 4 ){
$str_arr[]= "#";
$result= $str_arr;
$total_str= count($result)-1;
foreach( $result as $key=>$value ){
// Laravel 5.2
### Daftarkan Events dan Listeners untuk Event dengan nama yaitu "Illuminate\Database\Events\QueryExecuted" ke EventServiceProvider
--- SOURCE CODE
app\Providers\EventServiceProvider.php
class EventServiceProvider extends ServiceProvider
{
/**
* Register any other events for your application.
*
// Laravel 5.2
### Registering Events and Listeners for Event Name is "Illuminate\Database\Events\QueryExecuted" to EventServiceProvider
--- SOURCE CODE
app\Providers\EventServiceProvider.php
class EventServiceProvider extends ServiceProvider
{
/**
* Register any other events for your application.
*
@joko-wandiro
joko-wandiro / page2.php
Created April 14, 2016 09:21
Session Lanjutan
<?php
// page2.php
session_start();
echo 'Welcome to page #2<br />';
echo $_SESSION['old_session'];
echo $_SESSION['favcolor']; // green
echo $_SESSION['animal']; // cat
<?php
// page1_use_trans_sid_true.php
// Browser Cookies di block dulu
// Settings > Content settings > Cookies > Block sites from setting any data
//ini_set('session.use_only_cookies', 0);
ini_set('session.use_trans_sid', 0);
//session_cache_expire(1);
@joko-wandiro
joko-wandiro / write_data_into_csv_file_format.php
Created March 2, 2016 06:29
Write data into CSV file format
<?php
ob_start();
$fp = fopen('php://output', 'w');
foreach ($rows as $row) {
// Add row to CSV buffer
fputcsv($fp, $row);
}
fclose($fp);
@joko-wandiro
joko-wandiro / using_ajax_on_the_laravel_form.txt
Created November 28, 2015 16:23
Using AJAX on the Laravel Form
=====================================================================================
### Using AJAX on the Laravel Form ###
=====================================================================================
### Importing or Aliasing the following Class Name using use operator
use Illuminate\Http\JsonResponse;
###
### Modify Validation Class which extends from Request
@joko-wandiro
joko-wandiro / setup_apache_virtual_host.txt
Last active November 28, 2015 12:55
Setup Apache Virtual Host
=====================================================================================
### Setup Apache Virtual Host ###
=====================================================================================
### Create new file local.conf ( Virtual Host Configuration File )
--- Go to /etc/apache2/sites-available/ ---
--- Create new file local.conf ---
@joko-wandiro
joko-wandiro / htmlentites_and_htmlspecialchars_charset.php
Last active September 29, 2023 08:32
HTML entities and HTML special characters
<?php
error_reporting(E_ALL);
$charsets = array(
"ISO-8859-1" => "Western European, Latin-1. ",
"ISO-8859-5" => "Little used cyrillic charset (Latin/Cyrillic). ",
"ISO-8859-15" => "Western European, Latin-9. Adds the Euro sign, French and Finnish letters missing in Latin-1 (ISO-8859-1). ",
"UTF-8" => "ASCII compatible multi-byte 8-bit Unicode. ",
"cp866" => "DOS-specific Cyrillic charset. ",
@joko-wandiro
joko-wandiro / number_format.php
Last active August 29, 2015 14:20
Number Format
<?php
define("CURRENCY_PREFIX", "Rp");
define("CURRENCY_SEPARATOR", ".");
define("CURRENCY_DECIMAL", ",");
$number = 1234.56;
// Change Number into Currency with thousand separator and Identifier
$indonesian_format_number = number_format($number, 2, CURRENCY_DECIMAL, CURRENCY_SEPARATOR);
$indonesianFormatNumberWithRP= CURRENCY_PREFIX . $indonesian_format_number;