Skip to content

Instantly share code, notes, and snippets.

View HazemNoor's full-sized avatar

Hazem Noor HazemNoor

View GitHub Profile
@khanzadimahdi
khanzadimahdi / data-uri-regex-rfc2397.md
Last active March 22, 2025 13:33
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 October 17, 2024 19:09
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.
@Pierstoval
Pierstoval / _PHP is_a() vs is_subclass_of().md
Last active March 11, 2025 10:27
`is_a()` vs `is_subclass_of()`

PHP is_a() vs is_subclass_of()

To compute the results, just use Melody and run the script:

melody run https://gist.github.com/Pierstoval/ed387a09d4a5e76108e60e8a7585ac2d
@bittercoder
bittercoder / convert.sh
Last active December 4, 2024 17:25
Convert .heic files to .jpg on linux (coming from an iOS11 device over USB)
# download release from github: https://github.com/monostream/tifig/releases and install at ~/tools/tifig
# then run these commands in the folder (just to keep things simple we normalize the file extension case before proceeding).
for f in *.HEIC; do mv "$f" "`echo $f | sed s/.HEIC/.heic/`"; done
for file in *.heic; do echo "~/tools/tifig -v -p $file ${file/%.heic/.jpg}"; done
@AhmedKamal20
AhmedKamal20 / subl_last_commit.sh
Created February 24, 2018 01:49
Open all modified files of the last commit with Sublime Text
git diff-tree --no-commit-id --name-only -r HEAD | xargs subl
@sliceofbytes
sliceofbytes / txt-to-google-keep-notes.py
Created February 14, 2018 22:16
Add Text Files as Google Keep Notes
#Import a directory of text files as google keep notes.
#Text Filename is used for the title of the note.
import gkeepapi, os
username = '[email protected]'
password = 'your app password'
keep = gkeepapi.Keep()
success = keep.login(username,password)
@pablorsk
pablorsk / CorsMiddleware.php
Last active August 15, 2020 20:23
CORS middleware for Lumen and PSR-7
<?php
namespace App\Http\Middleware;
use Closure;
class CorsMiddleware
{
/**
* Handle an incoming request.
@maxivak
maxivak / __upload_file.md
Last active January 30, 2025 19:11
PHP upload file with curl (multipart/form-data)

We want to upload file to a server with POST HTTP request. We will use curl functions.


// data fields for POST request
$fields = array("f1"=>"value1", "another_field2"=>"anothervalue");

// files to upload
$filenames = array("/tmp/1.jpg", "/tmp/2.png");