Skip to content

Instantly share code, notes, and snippets.

View HazemNoor's full-sized avatar

Hazem Noor HazemNoor

View GitHub Profile
@danilopolani
danilopolani / Controller.php
Created June 29, 2023 09:09
Zendesk webhook signature validation with Laravel
<?php
// $request comes from your Controller method, but you can adjust with whatever framework you use
$signature = $request->header(ZendeskSupport::WEBHOOK_SIGNATURE_HEADER),
$timestamp = $request->header(ZendeskSupport::WEBHOOK_SIGNATURE_TIMESTAMP_HEADER),
$rawBody = $request->getContent();
$computedSignature = base64_encode(hash_hmac(
'sha256',
@FeepingCreature
FeepingCreature / youre_doing_json_apis_wrong.md
Last active January 7, 2024 19:33
You Are Doing JSON APIs Wrong

You are doing JSON APIs wrong.

When you use JSON to call an API - not a REST API, but something like JSON-RPC - you will usually want to encode one of several possible messages.

Your request body looks like this:

{
 "type": "MessageWithA",
@DarkGhostHunter
DarkGhostHunter / log-levels.csv
Last active March 12, 2022 04:38
Log levels table
Property / Log Level Debug Info Notice Warning Error Critical Alert Emergency
Disposable X
Statistical X X X X X X X
Relevant X X X X X X
Undersired X X X X X
Unstable X X X X
Stateful X X X
Unsecure X X
Unfixable X
@cybertiwari
cybertiwari / calculateDistance.php
Created October 31, 2021 16:14
Calculate distance between two latitude and longitude in php using the Great-circle distance formulae
<?php
function calculateDistance($firstLatitude, $firstLongitude, $secondLatitude,$secondLongitude)
{
//get polar angle θ (theta) (angle with respect to polar axis)
$theta = $firstLongitude - $secondLongitude;
$radians = sin(
deg2rad($firstLatitude)
) * sin(
@kelgendy1204
kelgendy1204 / ab-testing.js
Last active June 2, 2021 15:08
A/B testing 2 different approaches
function createSamples(name, createVariation) {
const sampleCount = 10000;
const variations = [];
for (let i = 0; i < sampleCount; i++) {
variations.push(createVariation());
}
const countData = variations.reduce((accum, curr) => {
if (accum[curr]) {
@TheAhmedGad
TheAhmedGad / utf8-arabic-ci.md
Last active November 27, 2023 23:10
Add Arabic utf8 arabic case insensitive Collation to MYSQL ENGINE

Support Arabic CI Collation

To make mysql understand Arabic letters synonyms like "أ" and "إ"

  • Run This to get Collation Path SHOW VARIABLES LIKE 'character_sets_dir';

  • in /collation/path/Index.xml add this to <charset name="utf8"> section

@AnatomicJC
AnatomicJC / android-backup-apk-and-datas.md
Last active May 19, 2024 18:41
Backup android app, data included, no root needed, with adb

Backup android app, data included, no root needed, with adb

Note: This gist may be outdated, thanks to all contributors in comments.

adb is the Android CLI tool with which you can interact with your android device, from your PC

You must enable developer mode (tap 7 times on the build version in parameters) and install adb on your PC.

Don't hesitate to read comments, there is useful tips, thanks guys for this !

@khanzadimahdi
khanzadimahdi / data-uri-regex-rfc2397.md
Last active February 22, 2024 08:51
regex pattern base64 data uri according to RFC 2397

pattern:

^data:((?:\w+\/(?:(?!;).)+)?)((?:;[\w\W]*?[^;])*),(.+)$

test this pattern on regexr: https://regexr.com/4inht

regex pattern to match RFC 2397 data URL

@RohitAwate
RohitAwate / concurrency.go
Created May 2, 2019 13:36
Code from the YouTube video: Concurrency in Golang: A Simple, Practical Example (https://youtu.be/3atNYmqXyV4)
package main
import (
"fmt"
"log"
"net/http"
"os"
"sync"
)