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 / 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 / checking_string_with_regex.js
Last active May 7, 2023 10:49
Validating string types using RegEx on JavaScript.
// let's validate some string with regex
- Credit Cards (Visa, Mastercard, American Express, Discover Card)
- Date (Check complex information for different months and leap years)
- Email
- HEX Color Code
- IP Address
- Password (With at least one uppercase & one lowercase letter, one digit, one special character, and atleast 8 characters long)
- Phone Number (For global numbers with/without country codes and separators like hyphens, dots, or spaces)
- URL Validation
@mgks
mgks / facebook_unliker.js
Last active May 7, 2023 10:52
Bulk remove liked pages from facebook with JavaScript. (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');