Skip to content

Instantly share code, notes, and snippets.

@AkshayHere
Last active August 29, 2022 07:59
Show Gist options
  • Save AkshayHere/c1790b40169af57a30677e8c427017cc to your computer and use it in GitHub Desktop.
Save AkshayHere/c1790b40169af57a30677e8c427017cc to your computer and use it in GitHub Desktop.
Some Tips and Tricks for Development which i came across through my career

Coding Assistance

Description

This repository contains a simple template for building Pandoc documents; Pandoc is a suite of tools to compile markdown files into readable files (PDF, EPUB, HTML...).

Scenarios

If you face issue with mongodb connection

No suitable servers found (serverselectiontryonce set): [connection timeout calling ismaster on '127.0.0.1:3306'])

WSL Setup and Config Issues

Reference

Mongodb get all record created today

{ $where: "this._id.getTimestamp() >= ISODate('2020-05-19')" }

Reference

Pull a file from another branch

git checkout master               # first get back to master
git checkout experiment -- app.js # then copy the version of app.js 
                                  # from branch "experiment"

Reference

NGINX Commands

Reference

GIT - No need password anymore

Reference

SSL Verify Issue - local git issue

Reference

Pretty show json_encode

Reference

WSL Setup and Config Issues

When the versions don't match up, composer will not install your required packagist packages. But if you add the --ignore-platform-reqs option when you run composer update, it will gracefully ignore these restrictions.

composer install --ignore-platform-reqs

GIT Squash Commits

Reference

HLAS Facade related

Reference

Issues with Cron Job not running

Check if Cron Job is there.

Configure if not properly configured

Configure for the specific user as well

Reference

HLAS Facade Tagging Tips

  1. Commit all you changes first before adding tag
  2. Change the Composer.json file to the tag u planning to created
  3. Always add v*.* etc to tags
  4. Once all the tags are committed, add the tag
  5. Once tag is added, push the tag to ur master
  6. go to the desired folder & run composer require hlas/facade

Reference

Check where this commit is from

git branch --contains <hash>

Check for file changes in all branches

gitk --all --date-order -- $FILENAME

Reference

PDF Generate in UP

1. sudo su hlas_universepress
2. $template = 'pdfs.products.BP360.basicPolicySchedule'; // sample template file
3. $data = []; // sample data
4. \App\Modules\PDF\Services\PDFGeneratorService::generatePDFV3($template,$data,"test.pdf",env("DOCUMENT_STORE_PATH",'/tmp') . '/' ."test2.pdf");

Mongodb Compare Two fields

{$where: "this.amountToCollectInCents !== this.amountCollectedInCents"}

Linux show process id

ps aux | grep <processName>

Linux add bash script to command (sample i added for log)

Make sure that this file is located in /bin/ folder

Reference

Git Squash Commits

Reference

Check if a Command Exists | Linux

command -v <the_command>

Node Js Build Error

Error: ENOENT: no such file or directory, scandir 
npm rebuild node-sass

[/home/hladmin/devdude/hlas_app/reactjs/node_modules/webpack-sources/node_modules/source-map/lib/ FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Solution

Misc

Best way to get the request body in PHP (use Illuminate\Http\Request;) In this method, you wont have backslash issue when u save data to DB json_encode($request->all()).

Composer install/require taking too long

Reference

list existing configs composer config --list --global

update config composer config --global repos.packagist composer https://repo.packagist.org

Check Where Exactly The Commits Is Made

Reference

Docker Assistance

To create an instance of docker container using ubuntu bash -- -ti : terminal intractive -- -rm : exit and delete the container after use -- -d : run in detached mode -- -c : run a command in the container

docker run -ti ubuntu:latest bash

docker run => Image to Container docker commit => Container to Image docker images docker ps (list running containers) docker ps -a (list all containers) docker ps -l (list last exited container) docker commit <image-name> <tag-name> (should do) docker tag 22d0b3b5 <tag-name> docker exec -ti <container-name> bash // let me execute a command in the container docker attach <container-name> (Same as above) docker logs <container-name> docker kill <container-name>

Exposing Docker Ports

docker run --rm -ti -p 45678:45678 -p 45679:45679 --name echo-server ubuntu bash

Running Docker From Wsl2

Initial Configuration for environment variables

OPENSSL

Reference #1

Reference #2

Reference #3

To Debug Shellscript

Add set -ex at the beginning of the file

Linux Tips

How to rest password for another user from root

Uninstall Apps

Add Users & Groups

Git Hooks

Reference #1

Simple example of usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment