Skip to content

Instantly share code, notes, and snippets.

View HazemNoor's full-sized avatar

Hazem Noor HazemNoor

View GitHub Profile
@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 7, 2024 12:32
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"
)
@medhatdawoud
medhatdawoud / rules-to-write-better-commit-messages.md
Last active March 8, 2024 17:25
This gist is the summary of a video on YouTube [in Arabic] you can watch from here: https://youtu.be/BTlL-LBDCSI

Rules to write a better commit message

These are my preferences for a good commit message, feel free to fork this gist and add your own standards, or add comment here to share yours with the community.

1. Include only the files related to the feature you are implementing:

  • Don't add any file that is not related to the main issue, you can make it in a separate commit.
  • Separating files that not related is important in the revert cases.
  • Revise the whole changes always before committing and make sure to mention each change you made in the message.

2. Commit subject should be concise and reflect the essence of the commit:

  • Imagine the commit as an Email to the owner or your team mates.
  • Subject in the first and main sentence of the commit, it should be concise and to the point.
  • It shouldn't exceed 50 char.