Skip to content

Instantly share code, notes, and snippets.

View remoharsono's full-sized avatar

Remo Harsono remoharsono

View GitHub Profile
@remoharsono
remoharsono / inotify.py
Created May 4, 2024 05:30
Using inotify to watch a folder
import inotify.adapters
def _main():
i = inotify.adapters.Inotify()
i.add_watch('tmp')
#with open('/tmp/test_file', 'w'):
# pass
@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 / 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