Skip to content

Instantly share code, notes, and snippets.

View boulama's full-sized avatar
💭
69 + 42

Boulama K. boulama

💭
69 + 42
View GitHub Profile
@boulama
boulama / php-html-css-js-minifier.php
Created January 1, 2018 07:20 — forked from Rodrigo54/php-html-css-js-minifier.php
PHP Function to Minify HTML, CSS and JavaScript
<?php
/**
* -----------------------------------------------------------------------------------------
* Based on `https://github.com/mecha-cms/mecha-cms/blob/master/system/kernel/converter.php`
* -----------------------------------------------------------------------------------------
*/
// HTML Minifier
function minify_html($input) {
@boulama
boulama / gist:5df75e706e2ffacb39e645f3bec662f5
Created May 2, 2018 00:14 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

source key.sh
function get_background(){
if [[ `wget -S --spider $1 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then
echo "image is available";
wget -O $2 $1
fi
}
PRG="$BASH_SOURCE"
progname=`basename "$BASH_SOURCE"`
@boulama
boulama / s.php
Last active November 5, 2021 06:37
simple php script that saves a base64 image to png and keeps the alpha channels.
<?php
// generate a random integer for our saved image name
$image_no=rand(0,9);
// our base 64 string
$base64String = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAADICAMAAABlASxnAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAABPlBMVEUAAAD/AAD/AAD/AAD/AAD/AAAAADMAADMuLmEzM2YzM2YAAAAAAACnQAD/YQAAADMzM2YAAAD/mQAAADMAADMICDtJSXwzM2YICBAAAACLUwD/mQD/mQAzM2YAADMAADMAADM5OWwzM2YzM2YAADMAABwAABoODkEAABoAABoAABoAADMAABoAABoAABgAACoAAAEAABoAAAEAAAEAABgAABoAABr/AAD/YQAAADMuLmEzM2YAAACLUwD/mQAXF0owMGNCQnVKSn0JCTxTU4ZmZplhYZRLS35YWItdXZBjY5ZBQXRGRnk8PG8ICDszM2ZERHdiYpU4OGsAABwAACcEBDcFBTgiIlUzM2Y0NGcAABoAACUgIFMAAB0AACEAACQJCTwODkEAAB8AABwAAC4AACoAABEAABkAAAEAABgbxDGTAAAAN3RSTlMActGYi7keoqKilIWi1bku6NG5NXSN8nSHi4uLZS4zRppnRiC5ubl0VHSzjUqis/cu6CbR0dG+Ls1rrwAAAAFiS0dEAIgFHUgAAAAHdElNRQfkBgYMOjIPTi/VAAACS0lEQVR42u3dZ1JVQRCAUUxgRuUp5oQJc1YwICgoZjGLignD/jfgCvqWMzXcefLOt4Cp7lP981bdvj5JkiRJkiRJUi+2YmXYqtqzdV2rr4WtqT1b1wUrIVgJwUoIVkKwEoKVEKyEYCUEKyFYCcFKCFZCsBKClRCshLoGq
import math
import numpy as np
# integration interval
a = 0
b = 1
Width = b - a
# points to sample
@boulama
boulama / iptc.php
Created November 5, 2021 06:43
Simple php function that writes IPTC data in a JPG image.
<?php
/*
Simple php function that writes IPTC data in a JPG image.
Details here: https://www.iptc.org/std/photometadata/specification/IPTC-PhotoMetadata
https://www.php.net/manual/en/function.iptcembed.php
*/
function write_iptc($rec, $data, $value)
{
$length = strlen($value);
@boulama
boulama / FleschReadingEase.js
Created December 5, 2021 22:55
JavaScript Implementation of the Flesch Reading-Ease algorithm to determine how difficult a passage in English is to understand.
/**
* Copyright (c) 2021
*
* JavaScript Implementation of the Flesch Reading-Ease algorithm to determine how difficult a passage in English is to understand.
* Reference: https://en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_readability_tests
* @summary Flesch Reading-Ease algorithm to determine how difficult a passage in English is to understand.
* @author Boulama K. <boulama@otimbi.com>
*/
@boulama
boulama / separateSentences.php
Created January 4, 2022 16:48
Efficiently cut sentences in PHP using RegEx
<?php
separateSentences($text) {
$split_sentences = '%(?#!php/i split_sentences Rev:20160820_1800)
# Split sentences on whitespace between them.
# See: http://stackoverflow.com/a/5844564/433790
(?<= # Sentence split location preceded by
[.!?] # either an end of sentence punct,
| [.!?][\'"] # or end of sentence punct and quote.
) # End positive lookbehind.
@boulama
boulama / worker.js
Created March 28, 2022 03:03 — forked from izuolan/worker.js
Custom domain for your Craft.do pages. Demo: https://note.zuolan.me and Tutorial: https://zuolan.me/craft_custom_domain_en
// Your domain name
const MY_DOMAIN = 'note.example.com'
// Website language
const LANG = 'en'
// Favicon url
const FAVICON_URL = 'https://example.com/favicon.ico'
// Your config page link
@boulama
boulama / feedbucket-tinq-webhook.php
Created April 26, 2022 08:40
feedbucket webhook
<?php
use GuzzleHttp\Client;
$client = new Client();
$data = json_decode($request->getContent(), true);
$action = $data['action'];
$feedback = $data['feedback'];
$project = $feedback['project'];
$reporter = $feedback['reporter'];