Skip to content

Instantly share code, notes, and snippets.

@Daniyal-Javani
Daniyal-Javani / cavity-map.php
Created January 2, 2016 20:41
hackerrank.com
<?php
//https://www.hackerrank.com/challenges/cavity-map
$handle = fopen ("php://stdin","r");
fscanf($handle,"%d",$n);
$grid = array();
for($grid_i = 0; $grid_i < $n; $grid_i++)
fscanf($handle,"%s",$grid[]);
for ($i = 1; $i < $n -1 ; ++$i){
for ($j = 1 ; $j < $n -1 ; ++$j){
@Daniyal-Javani
Daniyal-Javani / receiver.php
Last active March 16, 2018 08:47
Upload using curl and receive it locally in php
<?php
echo "<pre>";
echo 'in upload.php<br/>';
print_r($_FILES);
print_r($_REQUEST);
move_uploaded_file($_FILES["file_contents"]["tmp_name"], "upload/".$_FILES["file_contents"]["name"]);
((\+98|0)[\d -]{9,13})|([\d]{8})
@Daniyal-Javani
Daniyal-Javani / proxychainsMultipleIP
Last active April 27, 2018 19:54
Run Proxychains with multiple tor IP
#!/bin/bash
start=64000
mkdir temp
for (( i=1; i<=6; i+=2))
do
socksPort=$((i+start))
sControlPort=$((i+start-1))
cp /etc/proxychains4.conf temp/p$i
sed -i -e "s/socks5 127.0.0.1 9050/socks5 127.0.0.1 $socksPort/g" temp/p$i
cp /etc/tor/torrc temp/t$i
@Daniyal-Javani
Daniyal-Javani / failover.sh
Last active July 17, 2019 12:23 — forked from Apsu/failover.sh
An example failover script for dual WAN, using a ping healthcheck and managing default routes appropriately
#!/bin/bash
# Set defaults if not provided by environment
CHECK_DELAY=${CHECK_DELAY:-4}
CHECK_IP=${CHECK_IP:-8.8.8.8}
PRIMARY_IF=${PRIMARY_IF:-eth0} PRIMARY_GW=${PRIMARY_GW:-192.168.1.1}
BACKUP_IF=${BACKUP_IF:-wlan0}
BACKUP_GW=${BACKUP_GW:-192.168.43.1}
# Compare arg with current default gateway interface for route to healthcheck IP
@Daniyal-Javani
Daniyal-Javani / clear
Last active December 11, 2021 13:10
Laravel Clear Cache
sudo rm -rf storage/framework/cache/data/*
sudo rm -rf bootstrap/cache/*
composer dump-autoload
php artisan clear
php artisan debugbar:clear
php artisan cache:clear-compiled
php artisan auth:clear-resets
php artisan config:clear
php artisan route:clear
php artisan view:clear
@Daniyal-Javani
Daniyal-Javani / Fan speed handler for HP 4530s
Last active November 22, 2018 07:52
Fan speed handler for HP 4530s
#!/bin/bash
LOGFILE=/var/log/fanspeed.log
ECFILE=/home/vahid/.4530s/FanControl/probook_ec.pl
COUNTER=60
######################################################
initOff()
{
setFan 80
@Daniyal-Javani
Daniyal-Javani / chromium-browser.desktop
Created December 10, 2018 07:07
Chromium .desktop with proxy
[Desktop Entry]
Version=1.0
Name=Chromium Web Browser
Name[ast]=Restolador web Chromium
Name[bg]=Уеб четец Chromium
Name[bn]=ক্রোমিয়াম ওয়েব ব্রাউজার
Name[bs]=Chromium web preglednik
Name[ca]=Navegador web Chromium
Name[ca@valencia]=Navegador web Chromium
Name[da]=Chromium netbrowser
@Daniyal-Javani
Daniyal-Javani / config
Created February 16, 2019 05:04
SSh config to use proxy for certain host ~/.ssh/config
Host gitlab.com
User git
ProxyCommand nc -x 127.0.0.1:1080 %h %p
@Daniyal-Javani
Daniyal-Javani / xmrig.service
Created April 18, 2019 17:58
xmrig systemd
[Unit]
Description=XMRig Daemon
After=network.target
[Service]
Type=simple
GuessMainPID=no
ExecStart=/home/vahid/xmrig/build/xmrig -a cryptonight -o stratum+tcp://xmr.pool.minergate.com:45700 -u [email protected] -p x -t 2 --donate-level 1
Restart=on-failure