Open in app

Sign In

Write

Sign In

Praj Basnet
Praj Basnet

1 Follower

Home

About

Nov 26, 2020

Git pull and automatically detect the current branch

Handy little shortcut I use when I run git pull so I don’t have to specify the current branch: git pull origin $(git rev-parse --abbrev-ref HEAD) I make this an alias of git pull so that I always get the branch first.

Git

1 min read

Git pull and automatically detect the current branch
Git pull and automatically detect the current branch
Git

1 min read


Nov 26, 2020

Remove multiple deleted files in git

Sometimes when you are committing changes in git you’ll find that a number of files have been deleted. You could manually set these files to delete by individually issuing the command: git rm filename However, there is a shortcut. If you issue the command: git ls-files --deleted It will return…

Git

1 min read

Remove multiple deleted files in git
Remove multiple deleted files in git
Git

1 min read


Nov 26, 2020

Batch undo git modifications

The following command can be used to find and checkout (undo) all files with modifications: git checkout $(git ls-files -m) This is effectively an “undo” of all modifications in the given branch (but it doesn’t impact added or deleted files).

Git

1 min read

Batch undo git modifications
Batch undo git modifications
Git

1 min read


Nov 26, 2020

PHP error logging checklist

Here’s a list of things you can check if you aren’t getting anything written to the PHP error log on your server: In php.ini, do you have error_reporting set to E_ALL ? In php.ini, do you have log_errors enabled? In php.ini, do you have track_errors enabled? Have you specified a…

PHP

1 min read

PHP error logging checklist
PHP error logging checklist
PHP

1 min read


Nov 26, 2020

MySQL Group Concat Function

The group_concat() function in MySQL is really nifty. It concatenates all rows that match your group by statement into a single, comma separated string. Essentially, it transposes rows to columns. Take this example. Say you have a table that stores a set of locations by country, state and city. You…

MySQL

1 min read

MySQL Group Concat Function
MySQL Group Concat Function
MySQL

1 min read


Nov 25, 2020

MySQL / MariaDB Storage Engine

To see what storage engine is used by the server by default you can use the following command in the MySQL/MariaDB shell: show variables like '%storage_engine'; You can view a list of supported engines using: show engines\G; To find out what storage engine your tables are using by schema use…

Database

1 min read

MySQL / MariaDB Storage Engine
MySQL / MariaDB Storage Engine
Database

1 min read


Nov 25, 2020

Allow PHP in HTML files to execute

By default on Apache web servers, PHP code will not execute in a file that does not have a .php (or similar) extension. So even though you can embed PHP into a HTML file, it won’t execute when the file extension is .html, .htm etc. To change this, you can…

Apache

1 min read

Allow PHP in HTML files to execute
Allow PHP in HTML files to execute
Apache

1 min read


Nov 24, 2020

Find and remove specific files via the command line.

For example, on a Mac, you’ll often find .DS_Store files. To find and remove these you can run the following command to search for and remove every instance: $ find . -type f -name ".DS_Store" -exec rm {} ; This will find all files (-type f) called .DS_Store and execute…

Command Line

1 min read

Find and remove specific files via the command line.
Find and remove specific files via the command line.
Command Line

1 min read


Nov 22, 2020

Make sure your data conversion SQL is easily identifiable/reversible

If you work with databases, sooner or later you’ll need to write SQL to “fix” data in a database table (or tables). One key piece of advice is to make sure that the SQL script you come up with is reversible, just in case you need to change things back…

Database

2 min read

Make sure your data conversion SQL is easily identifiable/reversible
Make sure your data conversion SQL is easily identifiable/reversible
Database

2 min read


Nov 22, 2020

Put files/folders you delete using rm into your Mac Trash Bin.

The following addition to your .bash_profile is super handy if you regularly use the command line/console on your Mac. Instead of simply deleting files forever it will instead put them into the .Trash folder in a unique sub-folder so you can recover them until you empty your bin. Very handy…

Mac

1 min read

Put files/folders you delete using rm into your Mac Trash Bin.
Put files/folders you delete using rm into your Mac Trash Bin.
Mac

1 min read

Praj Basnet

Praj Basnet

1 Follower

Help

Status

Writers

Blog

Careers

Privacy

Terms

About

Text to speech

Teams