Skip to content

Instantly share code, notes, and snippets.

@jigar-dhulla
jigar-dhulla / scroll_toggle.sh
Created February 6, 2024 05:28
Shell Script to toggle Natural Scroll setting in MacBook/iOS
#!/bin/bash
# Check the current status of natural scrolling
current_status=$(defaults read -g com.apple.swipescrolldirection)
# Toggle the natural scrolling setting
if [ "$current_status" -eq 0 ]; then
defaults write -g com.apple.swipescrolldirection -bool true
echo "Natural scrolling enabled."
else
@jigar-dhulla
jigar-dhulla / README.md
Last active December 2, 2023 02:50
Not working: Dynamic Tries

Worker

php artisan queue:work --tries=1

Dispatch Jobs in Bulk

> for($i = 1; $i <= 10; $i++) Bus::dispatch(new App\Jobs\TestRetry());

@jigar-dhulla
jigar-dhulla / gist:80be2c48e7f99ec8f74d41f1ab709633
Last active September 16, 2022 05:34
[Experiment] Template for Sharing Tips on Twitter
🔥<Topic> Tip: Get Audience Attention
Actual Tip
[If more characters left] How it will be helpful
Attach Image with Examples explaing the Tip
[Linked Thread]
How the tip will be helpful
@jigar-dhulla
jigar-dhulla / RelationAware.php
Created April 14, 2022 11:56
Laravel - Get Relations of Eloquent Model without eager loading
<?php
use Illuminate\Database\Eloquent\Relations\Relation;
use ReflectionClass;
use ReflectionMethod;
use ReflectionType;
trait RelationAware
{
/**
@jigar-dhulla
jigar-dhulla / helpers.php
Created November 15, 2018 10:40
PHP Helper Functions
/**
* Get Client Public IP Address
* @return type
*/
function getIp(){
$clientIp = null;
foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key){
if (array_key_exists($key, $_SERVER) === true){
foreach (explode(',', $_SERVER[$key]) as $ip){
$ip = trim($ip); // just to be safe
function parseArguments()
{
array_shift($argv);
$out = array();
foreach($argv as $arg)
{
if(substr($arg, 0, 2) == '--')
{
$eqPos = strpos($arg, '=');
if($eqPos === false)