Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Rian Ariona ariona

🏠
Working from home
View GitHub Profile
@ariona
ariona / package.json
Created Oct 21, 2020
Frontend Dev starter for non JS Framework
View package.json
{
"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 / function.php
Last active Oct 13, 2020
Fix CORS issue on WP REST API
View function.php
<?php
// ....
add_action('rest_api_init', function() {
remove_filter('rest_pre_serve_request', 'rest_send_cors_headers');
}, 15);
@ariona
ariona / index.js
Created Oct 9, 2020
toBase64 from URL
View index.js
/* 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 / axios.js
Last active Oct 25, 2020
Authenticate WooCommerce RestAPI with oAuth 1.0a
View axios.js
import OAuth from 'oauth-1.0a';
import CryptoJS from 'crypto-js';
// Consumer Key
const ck = "ck_c7796f3a7c4eaedde188c78107cd907a41944ac6";
// Consumer Secret
const cs = "cs_d7a23c04e4c1939fb38fd966ea16be0dced185de";
const oauth = OAuth({
@ariona
ariona / index.js
Created Jul 18, 2020
Async function inside loop
View index.js
(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");
})();
View filter-keys.js
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 / Waktu Sholat Arah Kiblat.md
Created Jun 28, 2018 — forked from siswadi/Waktu Sholat Arah Kiblat.md
Waktu Sholat & Arah Kiblat w/ HTTP/JSON API
View Waktu Sholat Arah Kiblat.md

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
@ariona
ariona / php-webscraping.md
Last active Jun 26, 2018 — forked from anchetaWern/php-webscraping.md
web scraping in php
View php-webscraping.md

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 / slideDown.js
Created Jan 24, 2018 — forked from ludder/slideDown.js
Vanilla JavaScript slideUp and slideDown functions
View slideDown.js
/*
Element to slide gets the following CSS:
max-height: 0;
opacity: 0;
overflow: hidden;
transition: max-height 0.4s ease 0s;
*/
/**
* Like jQuery's slideDown function - uses CSS3 transitions
@ariona
ariona / README.MD
Last active Dec 14, 2017
Formatting seconds times to HH:MM:SS
View README.MD

Convert Seconds time format into HH:MM:SS.

If the seconds is less than an hour then the format returned will be MM:SS