Skip to content

Instantly share code, notes, and snippets.

View ariona's full-sized avatar
🏠
Working from home

Rian Ariona ariona

🏠
Working from home
View GitHub Profile
@ariona
ariona / php-webscraping.md
Last active June 26, 2018 08:07 — forked from anchetaWern/php-webscraping.md
web scraping in php

Have you ever wanted to get a specific data from another website but there's no API available for it? That's where Web Scraping comes in, if the data is not made available by the website we can just scrape it from the website itself.

But before we dive in let us first define what web scraping is. According to Wikipedia:

Web scraping (web harvesting or web data extraction) is a computer software technique of extracting information from websites. Usually, such software programs simulate human exploration of the World Wide Web by either implementing low-level Hypertext Transfer Protocol (HTTP), or embedding a fully-fledged web browser, such as Internet Explorer or Mozilla Firefox.

So yes, web scraping lets us extract information from websites. But the thing is there are some legal issues regarding web scraping.

@ariona
ariona / Waktu Sholat Arah Kiblat.md
Created June 28, 2018 04:39 — forked from siswadi/Waktu Sholat Arah Kiblat.md
Waktu Sholat & Arah Kiblat w/ HTTP/JSON API

Waktu Sholat & Arah Kiblat

Informasi Waktu

https://time.siswadi.com/
https://time.siswadi.com/Asia/Jakarta
https://time.siswadi.com/help
https://time.siswadi.com/?help
https://time.siswadi.com/?timezone=Asia/Jakarta
function isCharacterKeyPress(evt) {
if (typeof evt.which == "undefined") {
// This is IE, which only fires keypress events for printable keys
return true;
} else if (typeof evt.which == "number" && evt.which > 0) {
// In other browsers except old versions of WebKit, evt.which is
// only greater than zero if the keypress is a printable key.
// We need to filter out backspace and ctrl/alt/meta key combinations
return !evt.ctrlKey && !evt.metaKey && !evt.altKey && evt.which != 8;
}
@ariona
ariona / index.js
Created July 18, 2020 12:45
Async function inside loop
(async () => {
await Promise.all(Array.from(
{ length: 5 },
(_, i) => new Promise(res => setTimeout(() => {
console.log(i);
res();
}, i * 1000))
));
console.log("loop/timeout is done executing");
})();
@ariona
ariona / index.js
Created October 9, 2020 10:43
toBase64 from URL
/* make sure the target URL CORS is allowed */
function toDataUrl(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
var reader = new FileReader();
reader.onloadend = function() {
callback(reader.result);
}
reader.readAsDataURL(xhr.response);
};
@ariona
ariona / function.php
Last active October 13, 2020 21:59
Fix CORS issue on WP REST API
<?php
// ....
add_action('rest_api_init', function() {
remove_filter('rest_pre_serve_request', 'rest_send_cors_headers');
}, 15);
@ariona
ariona / package.json
Created October 21, 2020 12:02
Frontend Dev starter for non JS Framework
{
"name": "mandiri-syariah",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"dev": "concurrently 'browser-sync start --server --watch' 'postcss ./source/tailwind.css -o ./assets/css/style.css -w'",
"build": "NODE_ENV=production postcss ./source/tailwind.css -o ./assets/css/style.css"
},
"devDependencies": {
@ariona
ariona / .gitlab-ci.yml
Last active August 8, 2022 01:52
Deploying Next.js App to GitLab pages
image: node
before_script:
- npm install --force
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
- .next/cache/
@ariona
ariona / readme.md
Last active October 5, 2022 13:41
Developing React-native App on MIUI

If you are developing React native based Android App and using XIAOMI/MIUI Device, this tips might help you to get rid some headache when debugging the app

Enabling Developer Menu

To enable Developer Menu, you need to tag 7 times on MIUI Version under About Phone Setting menu instead of Build Number. The Developer Menu can be found on Additional Settings

Can't Install Debug APK? "...Failed to establish session"?

  1. enable developer mode - In your phone, go to Settings, About phone and click on MIUI version 7 times. You’ll see a pop up which says you are a developer now.
  2. Go back to Settings, Additional settings, Developer options and enable USB Debugging.
  3. Connect your phone to your PC/Mac and on the phone authorize your computer
@ariona
ariona / proportional-scale.js
Created November 25, 2015 07:52
Proportionally Scale Any HTML Content
var $el = $("#very-specific-design");
var elHeight = $el.outerHeight();
var elWidth = $el.outerWidth();
var $wrapper = $("#scaleable-wrapper");
$wrapper.resizable({
resize: doResize
});