Skip to content

Instantly share code, notes, and snippets.

@boywijnmaalen
boywijnmaalen / CM_Telecom_send_message_in_json_format_via_gateway.php
Last active April 5, 2018 09:47
Send one or more messages via CM Telecom' Messaging Gateway. For the latest version of the docs please go to; https://docs.cmtelecom.com/bulk-sms #CodeExamples
<?php
namespace CMTelecom\Messaging;
/**
* Code Examples
*/
// initiate
$sendMessage = new CMSendMessage('<INSERT PRODUCT TOKEN HERE>', 'SenderID');
@boywijnmaalen
boywijnmaalen / Recover deleted files from git rm
Last active April 9, 2018 04:49
Recover deleted files from 'git rm' #CLI #GIT
# Recover deleted files from 'git rm'
$ git fsck --lost-found --unreachable
# PS. Recovered files are in '.git/lost-found/other'
@boywijnmaalen
boywijnmaalen / Create a new MySQL user.mysql
Last active April 9, 2018 04:52
Create a new MySQL user
-- Let’s start by making a new user within the MySQL shell:
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
-- Sadly, at this point newuser has no permissions to do anything with the databases. In fact, if newuser even tries to login (with the password, password), they will not be able to reach the MySQL shell.
-- Therefore, the first thing to do is to provide the user with access to the information they will need.
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
--The asterisks in this command refer to the database and table (respectively) that they can access—this specific command allows to the user to read, edit, execute and perform all tasks across all the databases and tables.
-- Once you have finalized the permissions that you want to set up for your new users, always be sure to reload all the privileges.
FLUSH PRIVILEGES;
@boywijnmaalen
boywijnmaalen / How to pull after a forced git push
Last active April 9, 2018 04:56
How to pull after a forced git push #CLI #GIT
$ git fetch origin
$ git reset --hard origin/master # be aware; this will destroy local work that does not ywt exist in the repository
@boywijnmaalen
boywijnmaalen / Add missing file to previous commit
Last active April 9, 2018 05:02
Add missing file to previous commit #CLI #GIT
# 1. stage the file you forgot to add to the previous commit
# 2. run the below mentiond command
$ git commit --amend –C HEAD
@boywijnmaalen
boywijnmaalen / delete files with the current directory as the 'root' directory based on a wildcard
Last active April 9, 2018 05:03
delete files with the current directory as the 'root' directory based on a wildcard #CLI #UNIX #MacOsX
# find every file in the current directory recursively based on a wildcard.
$ find . -name '._*' -type f -delete
@boywijnmaalen
boywijnmaalen / Find all files containing specific text
Last active April 9, 2018 05:03
Find all files containing specific text #CLI #UNIX
$ grep -rnw '/path/to/somewhere/' -e "pattern"
# (path/ must absolute!)
# -r or -R is recursive,
# -n is line number, and
# -w stands for match the whole word.
# -l (lower-case L) can be added to just give the file name of matching files.
# along with these, --exclude, --include, --exclude-dir or --include-dir flags could be used for efficient searching:
@boywijnmaalen
boywijnmaalen / Generate MD5 Checksum for every file in a specific path
Last active April 9, 2018 05:03
Generate MD5 Checksum for every file in a specific path #CLI #UNIX
$ find <path> -type f -exec md5sum {} + > sums.md5
@boywijnmaalen
boywijnmaalen / order directory content by size
Last active April 9, 2018 05:05
order directory content by size
# MAC
$ du -sh /directory/to/search/*/ | sort -n -r
# UNIX
$ du -hc --max-depth=1 . | sort -n -r
# du:
# -s, --summarize Display only a total for each argument.
# -h, --human-readable Append a size letter such as `M' for megabytes to each size.
# Powers of 1024 are used, not 1000; `M' stands for 1,048,576 bytes
@boywijnmaalen
boywijnmaalen / SeLinux
Last active April 9, 2018 05:05
SeLinux
# SeLinux doesn't like if files are moved from one place to another.
# if were to copy the file than SeLinux will have no problem with it whatsoever.
# If you do run into issues;
// will give you overview of all SeLinux permissions
// files need to match `httpd_sys_content_t`
$ ls -lZ
// I'm not that familiar with SeLinux BUT here is way to fix the permission for a file
$ mv <filename> /tmp