Skip to content

Instantly share code, notes, and snippets.

View jdecode's full-sized avatar
🦾
Automate and Chill

Jagdeep Singh Kalsi jdecode

🦾
Automate and Chill
View GitHub Profile
@jdecode
jdecode / gcp-manual-deploy-php-git-actions-steps.md
Last active July 18, 2020 05:37
Steps to run PHP code with manual code deploy (i.e. via git clone/pull) at Google Cloud Platform [GCP/GCE] : Basics++

High level actions

  1. Create a VM (Virtual Machine) - with minimal hardware specs : probably a version with 1 vCPU and less than (or equal to) 1 GB RAM
  2. Use Ubuntu as the OS (you can choose any other OS, but you have to make sure that the respective commands for any follow up actions are known and you are well versed with those).
  3. Enable/configure SSH to access the system
  4. Clone git repo (Github/Bitbucket/Gitlab etc) - and install any dependencies on the VM
  5. Configure any additional tools/services that the code is using (DB/PDO/JSON etc)
  6. Map the IP/generic-url to a domain name (if you don't have a domain, then make sure you sign-up for that - free or paid - choice is yours) - DNS management

Good to have (If not here, then where? If not now, then when?):

@jdecode
jdecode / docker-commands.md
Last active January 4, 2020 17:41
Some useful docker commands

Stop all running containers:

docker container stop $(docker container ls -aq)

Show running containers:

docker container ls -a

@jdecode
jdecode / setup-php-on-ubuntu-19-10.md
Last active July 18, 2020 05:41
Commands to install MySQL, PGSQL, PHP (multiple versions) in Ubuntu 19.10
@jdecode
jdecode / controller-request-and-response-objects.md
Last active July 18, 2020 05:32
Laravel to CakePHP conversion

Instead of Illuminate\Http\Request, use Cake\Http\ServerRequest

Find Request $request and replace with ServerRequest $request

@jdecode
jdecode / postgre-sql-commands.md
Created March 21, 2020 18:21
PostgreSQL commands

Please note the following commands:

\list or \l: list all databases

\dt: list all tables in the current database using your search_path

\dt *.: list all tables in the current database regardless your search_path

You will never see tables in other databases, these tables aren't visible. You have to connect to the correct database to see its tables (and other objects).

@jdecode
jdecode / command-to-install-postgresql-via-docker.md
Created March 21, 2020 18:25
Install PostgreSQL on localhost using Docker

Prerequisite : Docker should be installed (Google "How to install docker") duh!

  1. docker pull postgres:latest (Pick your tag if you know)

  2. mkdir -p $HOME/docker/volumes/postgres (Ubuntu/Debian/Linux based systems)

  3. docker run --rm --name pg-docker -e POSTGRES_PASSWORD=docker -d -p 5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data postgres

  4. You can connect using psql -h localhost -U postgres -d postgres - Password is docker (set in above command)

@jdecode
jdecode / cakephp-qaing.md
Created March 22, 2020 13:02
CakePHP setup using docker-compose, and other stuff
  1. Create migration for table sources : bin/cake bake migration CreateSources name:string status:boolean

  2. Create seeder for a table called sources : php vendor/bin/phinx seed:create --path=config/Seeds SourceSeeder

  3. Run migration and seeder : bin/cake migrations migrate and bin/cake migrations seed

@jdecode
jdecode / youtube-thumbnail-url-from-video-id.md
Last active July 18, 2020 05:29
youtube-thumbnail-url-from-video-id

Stackoverflow answer link - https://stackoverflow.com/a/2068371/867451

Copied the content for quick reference


Each YouTube video has four generated images. They are predictably formatted as follows:

https://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg

https://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg

@jdecode
jdecode / docker-compose-run-composer.md
Last active April 22, 2020 05:58
Run composer and other commands inside Docker using docker-compose
  1. Install composer require in docker-compose e.g. Add Sentry like this:

docker-compose run kode composer require sentry/sdk:2.1.0

  1. Run shell commands e.g. "bake" commands in CakePHP shell could be run like this:

docker-compose run kode bin/cake bake all

@jdecode
jdecode / cakue.md
Last active April 29, 2020 11:06
Install CakePHP and Vue

CakePHP + Vue Prerequisite : composer, npm, Ubuntu (same commands will run on Windows/Mac as well, if everything else is configured correctly, and you know where to run the commands).

  1. Install CakePHP composer create-project --prefer-dist cakephp/app cakue This will download and install CakePHP in the folder cakue You can call it anything, if you do not give any name, then by default folder name would be app

  2. Install Vue