Windows 10 WSL Ubuntu Common Commands and hacks

In C:\Windows\System32\drivers\etc\hosts 127.0.0.1 test.tld ::1 test.tld #::1 is really important sometimes Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\0408F7A3] "AppFullPath"="C:\\Windows\\System32\\wsl.exe" "PermittedLspCategories"=dword:80000000 Save the above as a .reg file and run it to update registry Powershell script=> save as .ps1 file If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { $arguments = "& '" + $myinvocation.mycommand.definition + "'" Start-Process powershell -Verb runAs -ArgumentList $arguments Break } $remoteport = bash.exe -c "ifconfig eth0 | grep 'inet '" $found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'; if( $found ){ $remoteport = $matches[0]; } else{ echo "The Script Exited, the ip address of WSL 2 cannot be found"; exit; } #[Ports] #All the ports you want to forward separated by coma $ports=@(80,443,3306); #[Static ip] #You can change the addr to your ip config to listen to a specific address $addr='0.0.0.0'; $ports_a = $ports -join ","; #Remove Firewall Exception Rules iex "Remove-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' "; #adding Exception Rules for inbound and outbound Rules iex "New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' -Direction Outbound -LocalPort $ports_a -Action Allow -Protocol TCP"; iex "New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock' -Direction Inbound -LocalPort $ports_a -Action Allow -Protocol TCP"; for( $i = 0; $i -lt $ports.length; $i++ ){ $port = $ports[$i]; iex "netsh interface portproxy delete v4tov4 listenport=$port listenaddress=$addr"; iex "netsh interface portproxy add v4tov4 listenport=$port listenaddress=$addr connectport=$port connectaddress=$remoteport"; } netsh interface portproxy show v4tov4 check if your proxy is working ...

April 1, 2022 · 2 min · Harshvardhan Malpani

Remove zone.identifier files in windows

find . -name "*:Zone.Identifier" -type f -delete Usually seen in wsl issues https://github.com/microsoft/WSL/issues/7456 and https://github.com/microsoft/WSL/issues/4609

March 21, 2022 · 1 min · Harshvardhan Malpani

S3 notes – how to make all s3 images public

aws configure --profile myproject // to test if it works or not aws s3 ls --profile myproject aws s3 cp \ --exclude "*" \ --include "*.jpeg" \ --content-type="image/jpeg" \ --metadata-directive="REPLACE" \ --recursive \ --acl public-read \ s3://myproject/ \ s3://myproject/ \ --dryrun --profile myproject aws s3 cp \ --exclude "*" \ --include "*.jpg" \ --content-type="image/jpeg" \ --metadata-directive="REPLACE" \ --recursive \ --acl public-read \ s3://myproject/ \ s3://myproject/ \ --dryrun --profile myproject aws s3 cp \ --exclude "*" \ --include "*.jpeg" \ --content-type="image/jpeg" \ --metadata-directive="REPLACE" \ --recursive \ --acl public-read \ s3://myproject/ \ s3://myproject/ \ --dryrun --profile myproject // not needed aws s3 sync . s3://my-bucket/path --acl public-read Dont forget to remove dryrun flag once you are sure.

October 7, 2021 · 1 min · Harshvardhan Malpani

prevent sticky header jumping in css or js

jQuery(document).ready(function(){var header=jQuery("header .fusion-header");var headerHeight=0; var shouldWrite=1; jQuery(window).on("scroll",function(){ headerHeight=header.height(); console.log(headerHeight); if(shouldWrite && headerHeight!==undefined){ jQuery("#headerjumpfixer").html(".fusion-header-wrapper.fusion-is-sticky{padding-top:"+headerHeight + "px}"); shouldWrite=0;} }); jQuery(window).on("resize",function(){shouldWrite=1;}); }); <style id="headerjumpfixer">.fusion-header-wrapper.fusion-is-sticky{padding-top:88px}</style>

April 12, 2021 · 1 min · Harshvardhan Malpani

This unique date 02 02 2020 will come after 1010 years – WRONG MATH

In dd/mm/yyyy format, 2nd February 2020 (02 02 2020) is a palindrome In really common beliefs, whatsapp forwards were filled with this number being so rare and unique. However it would be stupid to say that such a rare date will occur only after 1010 years. Here is how: In whole millennium (1000 years), first few years of first few centuries have many of such dates. Even if you consider MM/DD/YYYY format, you can find a lot of such numbers in first few centuries. ...

February 2, 2020 · 1 min · Harshvardhan Malpani

10 tips for better freelancing

How to improve yourself as a freelancer? Here are 10 points to take care of: Communication Skills – convincing power Make yourself a brand, your ethics will define your future in freelancing. This will help you in scaling also Consistency, Focus and Dedication Productivity is Gold, know your value, do math and target for a monthly number Read!! know clients requirements in depth, if it is small task, fix already without getting the project. This approach will consume time without paying, but would probably make you better keep challenging yourself, keep improving Stay away from template bids, no body wants to know which app you did 4 years ago if the project not about an app Keep your portfolio updated Take care of clock, predict and quote project timelines intelligently Exceed expectations of your Client, under-promise and over-deliver

January 22, 2020 · 1 min · Harshvardhan Malpani

SQL Notes

CREATE TABLE `clients` ( `id` int(4) NOT NULL AUTO_INCREMENT, `name` varchar(11) NOT NULL, `associate` varchar(100) NOT NULL, `revenue` int(12) NOT NULL, `profit` int(12) NOT NULL, PRIMARY KEY (`id`), FOREIGN key (`associate`) references `emp`(`emp_code`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; alter table `emp` add COLUMN `phone` int(12) not null after `name` alter table `emp` add COLUMN `phone` int(12) null after `name` alter table `emp` modify `phone` int(12) null alter table `emp` drop column `phone` ALTER TABLE `emp` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `emp_code` (`emp_code`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `emp` -- ALTER TABLE `emp` MODIFY `id` int(4) NOT NULL AUTO_INCREMENT; COMMIT;

February 18, 2019 · 1 min · Harshvardhan Malpani

SSL certification setup: Cloudflare.

This article will guide you to set your SSL certification using Cloudflare. Cloudflare is an internet security company which provides content delivery network service. You can get free SSL certification as well as paid one from Cloudflare. A breif discussion on SSL certification and https redirection. So, Let’s start the process. Steps: Step1 Signup and Login to cloudflare. There you will get an option to add your site url. Do it and proceed. ...

February 1, 2019 · 2 min · Harshvardhan Malpani

Magento File Directory

/app The etc folder contains the di.xml configuration file The di.xml file contains class mapping and interface preferences Contains the design folder for themes. /bin The directory contains the magento file or a Command Line Interface script /dev Magento 2 testing and development tools are placed in this folder. /lib The internal and web subfolders are located here The internal directory contains server-side libraries and several font files; The web subfolder contains client-side libraries, jquery, modernizr, requirejs, prototype, scriptaculous ...

July 27, 2018 · 1 min · Harshvardhan Malpani

Rakit library for PHP validation

To enable hastle free validation, use raket library. First install composer and then run “composer require rakit/validation” in your project directory. Edit the names according to your input field names. You can also create your own validation file. For further reference, visit https://github.com/rakit/validation

July 22, 2018 · 1 min · Harshvardhan Malpani