Skip to content

Instantly share code, notes, and snippets.

View afzafri's full-sized avatar
🎯
Focusing

Afif Zafri afzafri

🎯
Focusing
View GitHub Profile
@afzafri
afzafri / ImagePixelCoordinate.html
Last active July 29, 2024 02:25
Image Pixel Coordinate Generator. A simple Javascript web application for my Smartwatch Watch Face website, use to find the pixel coordinate in a photo, for watch face making purpose.
<p>Choose your clock_bg Photo</p>
<!-- choose image file, on choose, automatically set to the canvas -->
<input type="file" id="imageLoader" name="imageLoader"/>
<!-- hide the tool, only show once file is choosen -->
<div id="toolArea" style="display: none;">
<p>Click on the image to place a marker<br> The markers on the image will show the coordinates value in decimal, while the table below will show the coordinates in Hex value.</p>
<!-- draw image and markers on the canvas here -->
<canvas id="Canvas" width="240" height="240"></canvas>
@afzafri
afzafri / datatabledemo.php
Last active May 16, 2023 10:57
Example usage of DataTables jQuery table plugin with Bootstrap
<!DOCTYPE html>
<html>
<head>
<title>Datatables Study Demo</title>
<!-- jQuery -->
<script
src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
@afzafri
afzafri / fbpostscrape.php
Last active March 31, 2023 20:15
Fetch/Scrape Facebook Page posts contents without using Facebook API
<?php
/* Facebook Page Posts Scrapper API created by Afif Zafri.
Fetch/Scrape posts contents of a page without using Facebook API
Usage: http://site.com/api.php?username=CODE , where CODE is the page username
*/
if(isset($_GET['username']))
{
@afzafri
afzafri / courseTotalTime.js
Created January 20, 2022 04:31
Calculate total course time for Alibaba Cloud Certificate
var dates = document.getElementsByClassName("date");
var totalTime = '00:00:00';
for(var i=0;i<dates.length;i++) {
totalTime = formatTime(timestrToSec(totalTime) + timestrToSec('00:'+dates[i].innerText));
}
console.log("Total Time: "+totalTime);
function timestrToSec(timestr) {
var parts = timestr.split(":");
@afzafri
afzafri / fbthumb.php
Created November 23, 2020 06:49
Scrape Facebook Video Thumbnail
<?php
$video_url = $_GET['video_url'];
echo get_fb_thumbnail($video_url);
function get_fb_thumbnail($video_url) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $video_url,
CURLOPT_RETURNTRANSFER => true,
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@afzafri
afzafri / strip_scripts.php
Created January 17, 2020 01:43
Replace all occurrences of JS script tags in string. Quick way but not the best to prevent XSS
<?php
$attack = "<script>alert('boom');</script>";
$sanitized = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $attack);
echo $sanitized;
?>
@afzafri
afzafri / coordinate.html
Created October 15, 2019 02:09
Image Coordinate Generator for Smartwatch Background
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Image Coordinates Generator</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="robots" content="noindex, nofollow">
<meta name="googlebot" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1">
@afzafri
afzafri / states_cities_geocodes.json
Created September 11, 2019 02:08
List of States and Citites in Malaysia with zip codes and geocodes fetched with OpenCage Geocoder API https://opencagedata.com/api
{
"Johor": [
{
"city": "Ayer Baloi",
"zip": "82100",
"lat": 1.587094,
"lng": 103.339187
},
{
"city": "Ayer Hitam",