Skip to content

Instantly share code, notes, and snippets.

View remoharsono's full-sized avatar

Remo Harsono remoharsono

View GitHub Profile
@remoharsono
remoharsono / Excel VBA - Send GET Request
Created August 28, 2014 05:51
Using Excel VBA to Send HTTP GET Request to Web Server
Private Sub cmdKirimGET_Click()
Dim strResult As String
Dim objHTTP As Object
Dim URL As String
Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
URL = "http://localhost/search.php"
objHTTP.Open "GET", URL, False
objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
objHTTP.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
objHTTP.send ("keyword=php")
@remoharsono
remoharsono / request.php
Created February 10, 2019 03:00
PHP cURL - Set User Agent as Google Bot
<?php
// taken from: https://github.com/izniburak/google-bot-curl/blob/master/google-bot.php
function googleBot($url)
{
$header = array();
$header[] = 'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5';
$header[] = 'Cache-Control: max-age=0';
$header[] = 'Content-Type: text/html; charset=utf-8';
$header[] = 'Transfer-Encoding: chunked';
@remoharsono
remoharsono / mysql-import.txt
Created December 11, 2022 02:45
MySQL - Import SQL via console
mysql -u root -p
SET FOREIGN_KEY_CHECKS=0;
use database_name;
SOURCE data.sql;
SET FOREIGN_KEY_CHECKS=1;
exit;
@remoharsono
remoharsono / my.ini
Created December 11, 2022 02:36
Optimize MySQL / MariaDB for Import
innodb_buffer_pool_size = 4G
innodb_log_buffer_size = 256M
innodb_log_file_size = 1G
innodb_write_io_threads = 16
innodb_flush_log_at_trx_commit = 0
@remoharsono
remoharsono / selectROI.py
Last active November 21, 2022 04:36
OpenCV: Select ROI
import cv2
image = cv2.imread("image.png")
x = cv2.selectROI("Select area", image, fromCenter=False)
print("Selected box: ", format(x))
@remoharsono
remoharsono / cropExtractText.py
Created November 21, 2022 01:15
Crop image and extract text from cropped image
from PIL import Image
from pytesseract import pytesseract
path_to_tesseract = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
pytesseract.tesseract_cmd = path_to_tesseract
img = Image.open("original_image.png")
# img.show()
box = (297, 10, 584, 50)
@remoharsono
remoharsono / Excel VBA - Compress a file
Last active March 26, 2022 03:40
Using Excel VBA to Zip compress a file
' Add reference to:
' 1. Microsoft Scripting Runtime
' 2. Microsoft Shell Controls and Automation
' From Tools > Reference
Option Explicit
Option Base 0
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMiliseconds As Long)
@remoharsono
remoharsono / get_dom_path.js
Last active September 12, 2021 14:25
get dom path in pure js that return a jQuery path
/*
sample usage:
var path = getDomPath(element);
console.log(path.join(' > '));
output:
body > section:eq(0) > div:eq(3) > section#content > section#firehose > div#firehoselist > article#firehose-46813651 > header > h2 > span#title-46813651
taken from:
http://stackoverflow.com/questions/5728558/get-the-dom-path-of-the-clicked-a
@remoharsono
remoharsono / express-part2-express-with-nodemon.txt
Last active November 27, 2020 09:18
Express with Pug and Nodemon
// no changes to express-part1
npm init
npm install --save express
npm install --save pug
npm install --save-dev nodemon
> vi package.json
---------------------
package.json [before]
@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");