Skip to content

Instantly share code, notes, and snippets.

@jesugmz
jesugmz / recursive-chmod-directories-and-files.sh
Last active September 5, 2016 23:21
Recursive chmod for directories and files
#!/bin/bash
#
# Recursive chmod for directories and files.
#
# all directories within the current path to 755 (-rwxr-xr-x)
find . -type d -exec chmod 755 {} \;
# all files within the current path to 644 (-rw-r--r--)
@jesugmz
jesugmz / find-files-containing-string.sh
Last active February 18, 2017 23:00
Find files containing a string
#!/bin/bash
#
# Find files containing a string
#
grep -rnw /path/to/search/ -e "<PATTERN>"
@jesugmz
jesugmz / get-interactive-bash-docker-container.txt
Last active February 18, 2017 23:01
Get an interactive bash in Docker containers
# get CONTAINER_ID with 'docker ps'
docker exec -it <CONTAINER_ID> bash
# or with docker-compose
docker-compose exec <CONTAINER_NAME> bash
@jesugmz
jesugmz / normalize-characters-js.md
Created March 6, 2018 22:35
Normalize characters in JavaScript
// replace á per a; ñ per n etc
normalizeDiacriticalMarks = (string) => {
  return string.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
}

// remove all character are not hypen minus ("-"), space or in the range a-z
sanitize = (string) => {
  string = this.normalizeDiacriticalMarks(string);
 return string.replace(/[^\u002D\u0020\u0061-\u007A]/gi, '');
@jesugmz
jesugmz / phpstorm-with-phalcon-support.md
Created April 19, 2017 22:26
PhpStorm with Phalcon support
  1. Install Phalcon Developer Tools
  2. From PhpStorm browse to View > Tool Windows > Project
  3. From the contextual menu of External Libraries click on Configure PHP Include Paths...
  4. Under the Include Path area click to add the path to phalcon/devtools/ide
@jesugmz
jesugmz / change-linux-distribution-information.md
Last active June 4, 2018 19:11
Change Linux distribution information

Especially useful for Ubuntu derivatives.

In order to change some Linux distribution information modify /etc/lsb-release file.

An example:

DISTRIB_ID="elementary"
DISTRIB_RELEASE=0.4
DISTRIB_CODENAME=loki
@jesugmz
jesugmz / fix-broken-crontab-jobs.md
Last active June 10, 2018 19:31
Fix broken crontab jobs

crontabs could not be executed if environment variables are missing. To check it:

* * * * * env > /tmp/env.output

Check the environments in the output file. Every binary that is executed by a job in the crontab should be accesible by them, if not fix missing symbolic links or add the missing environment variables before the job execution. Example:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

0 1 * * * my_command
@jesugmz
jesugmz / AnimalTypes.js
Last active June 16, 2018 20:13
Share constants (or globals) in JS
export const ANIMAL_TYPES = [
{
text: 'Perros',
value: 1,
},
{
text: 'Gatos',
value: 2,
},
];