Skip to content

Instantly share code, notes, and snippets.

View SOHELAHMED7's full-sized avatar

Sohel Ahmed Mesaniya SOHELAHMED7

View GitHub Profile
@cebe
cebe / Makefile
Last active January 25, 2023 09:49
How to run docker commands as your local user, not root
# This is a Makefile that implements helpers for a docker stack
#
# This example shows how to run a bash in a docker-compose container as your local user,
# so files are created owned by that user instead of root.
#
# For this to work, the user inside the container must have the same ID as the user outside.
# The name does not matter much but to avoid confusion it is helpful to make them have the same user name.
# You get a users ID by running the `id -u` command, and the users name is `whoami`.
#
# How it works:
@poing
poing / laravel_facades.md
Last active May 14, 2024 12:36
Laravel Facades

Understanding Facades in Laravel

What's a Facade?

The Laravel explination, shown below is confusing.

Facades provide a "static" interface to classes that are available in the application's service container. Laravel ships with many facades which provide access to almost all of Laravel's features. Laravel facades serve as "static proxies" to underlying classes in the service container, providing the benefit of a terse, expressive syntax while maintaining more testability and flexibility than traditional static methods.

Many examples use Cache::get('key') to demonstrate how a Facade works. Comparing the following code to the utility that a Facade provides.

@tkrotoff
tkrotoff / FrontendFrameworksPopularity.md
Last active July 26, 2024 06:41
Front-end frameworks popularity (React, Vue, Angular and Svelte)
-- Cleans up IPB 3 database before importing it into another forum engine
-- tbl_* are project specific, could be removed
-- Remove banned members and members with no posts
delete m
from ipb_members m
left join tbl_user u on u.id = m.member_id
where
(
member_banned = 1
@ziluvatar
ziluvatar / token-generator.js
Last active July 24, 2024 16:53
Example of refreshing tokens with jwt
/**
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken
* It was requested to be introduced at as part of the jsonwebtoken library,
* since we feel it does not add too much value but it will add code to mantain
* we won't include it.
*
* I create this gist just to help those who want to auto-refresh JWTs.
*/
const jwt = require('jsonwebtoken');
@soxofaan
soxofaan / README.md
Last active January 19, 2024 17:48
Simple pretty CSV and TSV file viewer.
@arubacao
arubacao / latlong.php
Last active February 10, 2024 00:55
Latitude Longitude Regular Expression Validation PHP
<?php
/**
* Validates a given latitude $lat
*
* @param float|int|string $lat Latitude
* @return bool `true` if $lat is valid, `false` if not
*/
function validateLatitude($lat) {
return preg_match('/^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,6})?))$/', $lat);
@joemaller
joemaller / webhook_validate.php
Last active November 20, 2021 12:29
Validate Github webhook signatures with PHP
<?php
$sig_check = 'sha1=' . hash_hmac('sha1', Request::getContent(), $_ENV['github_webhook_secret']);
if ($sig_check === Request::header('x-hub-signature')) { // php >=5.6 and above should use hash_equals() for comparison
// sigs match, do stuff
}
@staltz
staltz / introrx.md
Last active July 27, 2024 04:59
The introduction to Reactive Programming you've been missing