Skip to content

Instantly share code, notes, and snippets.

@dertajora
dertajora / some_script.bat
Last active July 17, 2017 11:22
Batch File I have Played with. Close all opened specified program. Delete temporary file with specific file
rem Close all cmd.exe
taskkill /F /IM cmd.exe /T
rem Delete temporary folder that contain "scope" in its name
FOR /D /R %dir% %%X IN (scope*) DO RMDIR /S /Q "%%X"
@dertajora
dertajora / decode_unicode_google_maps_api.php
Last active February 25, 2020 23:03
Decode Encoded Unicode string (field html-instruction) on Google Maps API response
<?php
// Lets say , we want to send a direction request with guidance to Google Maps API using link below.
// https://maps.googleapis.com/maps/api/directions/json?origin=-6.190109,%20106.798565&destination=-6.177596,%20106.792611&key=USEYOUR_KEY
// some of request, especially in field html-instruction would return unicode html text like this one ('Head \u003cb\u003ewest\u003c/b\u003e').
// for some reason, I just want to use the text provided there ('Head west').
// after some googling and asking, here is the best code I have (right now)
# example response
//Type A : There are 2 sentence in one single direction response
@dertajora
dertajora / BCA_API.php
Last active January 4, 2024 04:00
This is my code when learn to use BCA API for my office. This code only works on Sandbox environment and there is no confidential information here. FYI, based on my experience if you want to implement this code using real environment of BCA API, you need to do some UAT with BCA side.
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class BCAAPI extends MY_Controller {
function __construct(){
$this->api_key = "YOUR API KEY";
$this->api_secret = "YOUR API SECRET";
$this->client_id = "YOUR CLIENT ID";
@dertajora
dertajora / save_to_csv.php
Last active May 7, 2021 00:38
This script is used to generate CSV file and save it to specific folder, I implement it on Codeigniter. Please modify the location of APPPATH section if you want to save to another location
<?php
// this script would save csv file to this specified directory
// APPPATH is location of application folder in Codeigniter
$file = fopen(APPPATH . '/../upload/'.'tesaasasat.csv', 'wb');
// set the column headers
fputcsv($file, array('Column 1', 'Column 2', 'Column 3', 'Column 4', 'Column 5'));
// Sample data. This can be fetched from mysql too
$data = array(