Skip to content

Instantly share code, notes, and snippets.

View Guibzs's full-sized avatar

Joffrey Guibzs

View GitHub Profile
@Guibzs
Guibzs / rgar.php
Last active December 3, 2017 09:13
PHP ~ Returns a value within an array
## Function
function rgar( $array, $name )
{
if ( isset($array[$name]) )
{
return $array[$name];
}
return '';
}
@Guibzs
Guibzs / connection
Last active October 10, 2018 12:34
SSH commands
ssh username@hostname
@Guibzs
Guibzs / search
Created November 12, 2018 08:25
Bash ~ Search in files
@Guibzs
Guibzs / views.sql
Last active January 25, 2019 13:07
MySQL ~ Views
CREATE OR REPLACE VIEW table_name AS
SELECT p.title, c.name FROM post AS p INNER JOIN category AS c ON p.category_id = c.ID;
@Guibzs
Guibzs / hide_show
Last active March 4, 2019 22:09
Hide/Show files & folders on macOS
defaults write com.apple.finder AppleShowAllFiles YES
defaults write com.apple.finder AppleShowAllFiles NO
@Guibzs
Guibzs / permisssions
Last active March 6, 2019 13:33
Bash ~ Change file permissions and ownership
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
chown -R root:root *;
sudo chown -R $(whoami) .
sudo chmod -R 777 .
@Guibzs
Guibzs / backup
Last active August 27, 2019 08:11
Shell ~ Work with mysql backups
# Making a new backup
mysqldump database_name > database_name.sql
mysqldump --databases database_one database_two > two_databases.sql
mysqldump --all-databases > all_databases.sql
# Restoring from a backup
mysql database_name < database_name.sql
mysql --one-database database_name < all_databases.sql
# Working with tables
@Guibzs
Guibzs / tar_gzip
Last active August 27, 2019 08:11
Bash ~ Compress and Extract files
# Compress
tar -cvf folder.tar folder/
gzip folder.tar
# Extract
tar -xvf folder.tar
gzip -d folder.tar.gz
@Guibzs
Guibzs / replace.sql
Last active August 27, 2019 09:09
MySQL ~ Replace
UPDATE table
SET column = REPLACE(column, ‘search’, ‘replace’);
@Guibzs
Guibzs / .htaccess
Created February 7, 2020 20:23
HTACCESS - HTPASSWD
AuthName "Protected"
AuthType Basic
Require valid-user
AuthUserFile /ABSOLUTE_URL/.htpasswd