Skip to content

Instantly share code, notes, and snippets.

View ano's full-sized avatar
🏠
Working from home

Anonga Tisam ano

🏠
Working from home
View GitHub Profile
@ano
ano / birth_certificate.php
Created February 6, 2024 18:47
PHP Birth Certificate code to create Birth Certificate
// Include the web3.php library
require 'vendor/autoload.php';
use Web3\Web3;
use Web3\Contract;
// Check if the request method is POST
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Retrieve the data from the POST request
$recipient = $_POST['recipient'];
@ano
ano / nft_birth_certificate.sol
Last active February 8, 2024 01:18
NFT Birth Certificate Solidity Code
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract BirthCertificateNFT is ERC721, Ownable {
struct BirthCertificate {
string childName;
uint256 dateOfBirth;
@ano
ano / PHPMakerFix.md
Created May 1, 2023 00:11
PHPMaker fix for PHP version 8

Convert the following to ternary:

Find

$GLOBALS["Title"] ??= $page->Title; // Title

and replace

$GLOBALS["Title"] = $GLOBALS["Title"] ?: $page->Title;
@ano
ano / OutputDDL.md
Created April 28, 2023 04:02
Php script to Output data definition language from a MySQL Database

Sure, here's a refactored version of the script that is easier to maintain for developers:

// Database configuration
$host = 'localhost';
$username = 'your_username';
$password = 'your_password';
$dbname = 'your_database_name';

// Create a new PDO object
@ano
ano / share_referral.js
Last active April 23, 2023 22:20
Code to share referral code in Govcrate
$(document).ready(function() {
const referral = `
<p>Copy & Share your referral link below to move up the waitlist:<br /><br />
<a id='referral-button' title="Copy Referral Code" class="referral-button bb_button bb_green" href='#' color="#fff">
Referral Code
</a> |
<a id="linkedin-button" title="Share to LinkedIn" class="linkedin-button bb_button bb_blue" href="#" color="#fff">
<span class="icon-fb"> </span>Share to LinkedIn
</a> |
@ano
ano / jaro_winkler_similarity.sql
Created April 15, 2023 00:07
MySQL User Defined Function: `jaro_winkler_similarity`
CREATE DEFINER=`root`@`localhost` FUNCTION `jaro_winkler_similarity`(
in1 varchar(255),
in2 longtext
) RETURNS float
DETERMINISTIC
BEGIN
#finestra:= search window, curString:= scanning cursor for the original string, curSub:= scanning cursor for the compared string
declare finestra, curString, curSub, maxSub, trasposizioni, prefixlen, maxPrefix int;
declare char1, char2 char(1);
declare common1, common2, old1, old2 longtext;
@ano
ano / Phpmaker-load-custom-scripts.md
Created April 12, 2023 16:49
PHPMAKER load your own css and js based on the page name

In PHPMaker you can use the following code in Page_Head or Page_Foot to load your own custom scripts:

$page = basename($_SERVER['PHP_SELF']);

if (file_exists("../my/code/$page.php")) { AddStylesheet("../my/code/$page.php"); // Add PHP script }

if (file_exists("../my/code/$page.css")) {

@ano
ano / cosign_similarity.sql
Last active April 8, 2023 23:00
MySQL/ MariaDB Cosign Similarity User Defined Function
To write a user-defined function in MariaDB that calculates cosine similarity between a given vector and a vector stored in a BLOB field, you can use the following code:
``` sql
DELIMITER $$
CREATE FUNCTION cosine_similarity(vector VARCHAR(255), blob_field BLOB)
RETURNS FLOAT
DETERMINISTIC
BEGIN
@ano
ano / slugify.sql
Created April 8, 2023 07:30
A MySQL user defined function called slugify() that takes in a string like “John’s a great guy” and convert it to “johns-a-great-guy”
DELIMITER //
CREATE FUNCTION slugify(input_text VARCHAR(255))
RETURNS VARCHAR(255)
DETERMINISTIC
BEGIN
DECLARE output_text VARCHAR(255);
SET output_text = LOWER(input_text);
SET output_text = REPLACE(output_text," ","-");
@ano
ano / strip_tags.sql
Last active April 8, 2023 07:32
strip_tags MySQL user defined function to remove html tags
# Code to implement the strip_tags function in MySQL:
DELIMITER $$
CREATE FUNCTION strip_tags(html TEXT) RETURNS TEXT
BEGIN
DECLARE s TEXT;
DECLARE p INT DEFAULT 0;
IF html IS NULL THEN