Skip to content

Instantly share code, notes, and snippets.

View zaifastafa's full-sized avatar
:octocat:
Eat. Code. Sleep. Repeat

Huzaifa Mustafa zaifastafa

:octocat:
Eat. Code. Sleep. Repeat
View GitHub Profile
@zaifastafa
zaifastafa / Removing DEFINER from sql
Last active July 5, 2023 11:56
For removing DEFINER clause from mysql dump
sed -i 's/DEFINER=[^*]*\*/\*/g' filename.sql
@zaifastafa
zaifastafa / git-commit.txt
Created February 22, 2022 06:36
git commit optimize
gcap() {
git add . && git commit -m "$*" && git push
}
ginit() {
git add . && git commit -m "init commit" && git push -u origin master
}
gchore() {
@zaifastafa
zaifastafa / unzip.sh
Created June 8, 2021 17:19
undo unzip
unzip -l ENTER_FILENAME.zip | awk 'BEGIN { OFS="" ; ORS="" } ; { for ( i=4; i<NF; i++ ) print $i " "; print $NF "\n" }' | xargs -I{} rm -rfv {}
@zaifastafa
zaifastafa / README.md
Created March 16, 2021 09:45 — forked from nichtich/README.md
How to automatically deploy from GitHub

Deploy your site with git

This gist assumes:

  • you have an online remote repository (github / bitbucket etc.)
  • you have a local git repo
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by Apache
  • the Apache user is named www-data (may be apache on other systems)
@zaifastafa
zaifastafa / dump_mysql_triggers
Last active April 14, 2021 10:53
Dump MySQL triggers
mysqldump -uroot -p --triggers --add-drop-trigger --no-create-info --no-data --no-create-db db -h 127.0.0.1 > /tmp/triggers.sql
@zaifastafa
zaifastafa / Compare database structure
Created January 16, 2021 06:28
Compare database structure with SQL
SET @firstDatabaseName = '[first database name]';
SET @secondDatabaseName = '[second database name]';
SELECT * FROM
(SELECT
CONCAT(cl.TABLE_NAME, ' [', cl.COLUMN_NAME, ', ', cl.COLUMN_TYPE, ']') tableRowType
FROM information_schema.columns cl, information_schema.TABLES ss
WHERE
cl.TABLE_NAME = ss.TABLE_NAME AND
cl.TABLE_SCHEMA = @firstDatabaseName AND

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date: