Skip to content

Instantly share code, notes, and snippets.

View mgks's full-sized avatar
:shipit:
let's ship it.

Ghazi mgks

:shipit:
let's ship it.
View GitHub Profile
@mgks
mgks / firebase_push_notification.php
Created December 1, 2024 07:55
PHP client script to push firebase notifications using cURL.
<?php
//client script
$FCM_KEY = "__YOUR_FIREBASE_AUTH_KEY__";
function fcm_push($token, $title, $text, $uri, $img='', $custom_data=[]){
global $FCM_KEY;
$url = 'https://fcm.googleapis.com/fcm/send';
$headers = array('Content-Type: application/json', 'Authorization: key='.$FCM_KEY);
@mgks
mgks / web3_functions_declaration.js
Created May 13, 2023 17:54
Simple smart contract using Solidity and then interact with it using web3.js
// Following git demonstrates the use of decentralized applications and blockchain technology using web3.js.
// Here's an example of a simple smart contract that stores and returns a message.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract MessageContract {
string private message;
function setMessage(string memory newMessage) public {
@mgks
mgks / php_image_extract.php
Last active May 7, 2023 10:54
Extracting information out of an image using PHP's internal libraries.
<?php
// loading image: using PHP's GD library to load the image from its file or URL
$img = imagecreatefromjpeg('image.jpg');
// getting image size: using getimagesize() function to get the width and height of the image
list($width, $height) = getimagesize($img);
// extracting image metadata: using exif_read_data() function to extract the image metadata, including camera settings, location, and time
$exif = exif_read_data($img);
@mgks
mgks / credit_card_validation.js
Last active December 1, 2024 08:06
Validating different string types with RegEx in JavaScript.
// following regex lets you validate credit cards and their types (including Visa, Mastercard, American Express and Discover cards)
^(?:4[0-9]{12}(?:[0-9]{3})? // Visa
| 5[1-5][0-9]{14} // Mastercard
| 3[47][0-9]{13} // American Express
| 6(?:011|5[0-9]{2})[0-9]{12} // Discover
)$
@mgks
mgks / facebook_pages_unliker.js
Last active December 1, 2024 07:58
Bulk remove liked pages from facebook via JavaScript console (last rev. 2019, may not work anymore).
// first select all liked buttons
var buttons = document.getElementsByClassName('PageLikedButton');
// launch pop for liked button
for(let button of buttons){
button.click();
};
// select unlike button parent to prevent timeline button clicks
var unlikes = document.getElementsByClassName('InterestListMenuDisconnect');