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 / Gordon-Schaffer.md
Created April 2, 2023 01:24
Gordon-Schaffer model as an API service

Sure, here's an example of a Python function that implements the Gordon-Schaffer model for sensitivity analysis and exposes it as a REST API using Flask:

from flask import Flask, jsonify, request
import numpy as np

app = Flask(__name__)

@app.route('/gordon-schaffer', methods=['POST'])
def gordon_schaffer_sensitivity():
@ano
ano / .htaccess
Created March 9, 2023 09:20
a .htaccess file to redirect from the folder “.forms/v12/“ to the folder “.forms/v18/“ for Machorm
RewriteEngine on
RewriteRule ^forms/v12/(.*)$ forms/v18/$1 [R=301,L]
@ano
ano / UUID.sql
Created March 6, 2023 18:37
a MySQL user defined function that takes in a number and uses it to generate a guid
# a MySQL user defined function that takes in a number and uses it to generate a guid
CREATE FUNCTION generateGuid(num INT) RETURNS CHAR(32)
BEGIN
DECLARE guid CHAR(32);
SET guid = CONCAT(
SUBSTR(SHA1(RAND()), 1, 8), '-',
SUBSTR(SHA1(RAND()), 1, 4), '-',
SUBSTR(SHA1(RAND()), 1, 4), '-',
SUBSTR(SHA1(RAND()), 1, 4), '-',
@ano
ano / uuid.php
Created March 6, 2023 18:34
A php function that takes in a number and uses it to generate a uuid
<?php
function generateUuid($number) {
$uuid = sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
// 16 bits for "time_mid"
mt_rand( 0, 0xffff ),
@ano
ano / first_sentence.php
Last active September 18, 2021 21:36
Get the first sentence from a string
// Source: https://electrictoolbox.com/get-first-sentence-php/
function first_sentence($content) {
$content = html_entity_decode(strip_tags($content));
$pos = strpos($content, '.');
if($pos === false) {
return $content;
}
else {
return substr($content, 0, $pos+1);
}
@ano
ano / ReadMe.md
Last active June 26, 2021 19:10
Machform: Filter Entries via URL Parameters

Overview

You can filter the entrie in the manage_entries.php page by passing in parameters via URL parameters

Example URL

manage_entries.php?id=47184&element_name=element_62&filter_condition=is&filter_keyword=36089

Description

@ano
ano / auth.php
Created June 20, 2021 19:00
PHP Basic Authentication
<?php
/*
* PHP-Basic-Auth
* Author: Ano Tisam
* Date: 11/10/2016
* Description: A simple basic auth script. When user tries to access a page that requires
* this script it asks for a username and password. Passwords are stored in a $users array as below.
*/
function pc_validate($user,$pass) {
/* replace with appropriate username and password checking,
@ano
ano / .htaccess
Last active July 3, 2021 02:31
Create a REST API for Machform using PHP-CRUD-API version 2 and MeekroDB
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ openapi.php/$1 [QSA,L]
</IfModule>
@ano
ano / get.js
Created December 19, 2020 22:34
JavaScript function to get URL parameters, similar to the PHP does it
/*
* Description: Get a URL parameter
* Usage:
* To get the value of the URL paramater search_term e.g. index.php?search_term=volvo
* var search = $_GET("search_term");
* console.log(search); //console output = "volvo"
*/
function $_GET(param){
const queryString = window.location.search; //console.log(queryString);
const urlParams = new URLSearchParams(queryString);
@ano
ano / ReadMe.md
Last active January 24, 2024 04:44
Formidable Forms Manage Entries Script

Introduction

A single page standalone PHP script to help manage formidable forms data in the front-end.

Usage

Add Entry

To add a see the URL below, note that

  • [z] is the id of the form