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 / 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,
@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",
# 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 / facebook_leads.md
Created February 22, 2019 06:38 — forked from tixastronauta/facebook_leads.md
Receiving Facebook Leads on a Webhook

Receiving Facebook Leads on a Webhook

1 - Create an App

Head over to developer.facebook.com and create an App

2 - Setup the webhook

On your server, create a facebook webhook that will handle facebook calls. Then create a "leadgen" webhook on you App: https://developers.facebook.com/docs/graph-api/webhooks/v2.5

@afzafri
afzafri / histogram_equalization.py
Created October 17, 2018 09:30
Simple script for calculating histogram equalization for my Image Processing course
'''
HISTOGRAM EQUALIZATION CALCULATOR
Afif Zafri
'''
from collections import Counter
# input
gray = [60,7,60,8,60,10,7,30,
30,45,15,15,7,15,60,8,