Skip to content

Instantly share code, notes, and snippets.

@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 / Removing sensitive data from a repository
Last active November 5, 2018 10:57
Removing sensitive data from a repository #CLI #GIT
# source: https://help.github.com/articles/removing-sensitive-data-from-a-repository/
# these arguments will:
#
# force Git to process, but not check out, the entire history of every branch and tag
# remove the specified file, as well as any empty commits generated as a result
# overwrite your existing tags
#
# can only do one file at a time
@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 / 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 / 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 / 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 / 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
@boywijnmaalen
boywijnmaalen / locate update file location database
Last active April 16, 2018 05:06
locate update file location database
# update the file database
$ sudo /usr/libexec/locate.updatedb
# If you would like to have the command updatedb to get a more consistent behavior between your Linux and Mac environment you can symlink it to /usr/local/bin.
$ ln -s /usr/libexec/locate.updatedb /usr/local/bin/updatedb