Skip to content

Instantly share code, notes, and snippets.

View alephart's full-sized avatar
🏠
Working from home

Juan Carlos Pulido S alephart

🏠
Working from home
View GitHub Profile
@alephart
alephart / permissions.md
Last active May 14, 2023 13:17
About linux permissions

About linux permissions

Examples:

drwxr-xr-x 755

-rw-r--r-- 644

@alephart
alephart / rsync.sh
Last active April 26, 2023 13:42
Utilizando rsync para copiar un folder y/o archivos
# Copiando folder desde server a local, con permisos de superusuario:
rsync -avz -e "ssh -i /ruta/del/archivo.pem" --rsync-path="sudo rsync" usuario_remoto@direccion_ip_remota:/ruta/del/folder/remoto /ruta/del/folder/local
# Copiando folder desde local a server, con permisos de superusuario:
rsync -avz -e "ssh -i /ruta/del/archivo.pem" /ruta/del/archivo/local usuario_remoto@direccion_ip_remota:/ruta/del/destino/remoto
# Renombrar todos los directorios agregándo suffix _OLD
find . -maxdepth 1 -type d -not -name "." -exec bash -c 'mv "$0" "${0}_OLD"' {} \;
# Renombrar todos los directorios eliminando el suffix _OLD
@alephart
alephart / capitalize.js
Last active May 14, 2023 13:19
Capitalize the First Letter of Each Word in JavaScript
// option I
const capitalizeWords = (string) => {
return string.split(' ').map((elem => elem.charAt(0).toUpperCase() + elem.slice(1).toLowerCase())).join(' ');
}
// option II
const capitalizeWords = string => string.split(' ').map((elem => elem.charAt(0).toUpperCase() + elem.slice(1).toLowerCase())).join(' ');
// option III
const capitalizeWords = sentence => (sentence.toLowerCase().replace(/(^\w{1})|(\s+\w{1})/g, letter => letter.toUpperCase()));
@alephart
alephart / valet-plus-destroy
Created April 22, 2021 19:25 — forked from dannygsmith/valet-plus-destroy
Remove valet-plus - reboot required
#!/usr/bin/env bash
#styles
VP_NONE='\033[00m'
VP_RED='\033[01;31m'
VP_GREEN='\033[01;32m'
VP_YELLOW='\033[01;33m'
VP_PURPLE='\033[01;35m'
VP_CYAN='\033[01;36m'
VP_WHITE='\033[01;37m'
db.getCollection('myCollection').find({}).limit(N).forEach(function(doc){
db.getCollection('myCollection').remove({_id: doc._id});
});
# or
db.getCollection('myCollection').find({}).limit(N).forEach(function(doc){
db.getCollection('myCollection').deleteMany({_id: doc._id});
});
@alephart
alephart / ffmpeg-watermark.md
Created February 11, 2021 22:00 — forked from bennylope/ffmpeg-watermark.md
FFmpeg add a watermark to video

How to Add a Watermark to Video

FFMPEG filters provide a powerful way to programmatically enhance or alter videos, and it’s fairly simple to add a watermark to a video using the overlay filter. The easiest way to install ffmpeg is to download a pre-built binary for your specific platform. Then you don’t have to worry about including and installing all the right dependencies and codecs you will be using.

Once you have ffmpeg installed, adding a watermark is as easy as passing your existing source through an overlay filter like so:

ffmpeg -i test.mp4 -i watermark.png -filter_complex "overlay=10:10" test1.mp4

Basically, we’re passing in the original video, and an overlay image as inputs, then passing it through the filter, and saving the output as test1.mp4.

@alephart
alephart / install_ffmpeg.sh
Created February 11, 2021 20:51 — forked from Piasy/install_ffmpeg.sh
brew install ffmpeg with all options
brew options ffmpeg
brew install ffmpeg \
--with-chromaprint \
--with-fdk-aac \
--with-fontconfig \
--with-freetype \
--with-frei0r \
--with-game-music-emu \
--with-libass \
@alephart
alephart / ffmpeg-install.sh
Created February 11, 2021 20:50 — forked from clayton/ffmpeg-install.sh
Install FFMPEG on OS X with HomeBrew to convert Mp4 to WebM
# Installation
brew install ffmpeg --with-vpx --with-vorbis --with-libvorbis --with-vpx --with-vorbis --with-theora --with-libogg --with-libvorbis --with-gpl --with-version3 --with-nonfree --with-postproc --with-libaacplus --with-libass --with-libcelt --with-libfaac --with-libfdk-aac --with-libfreetype --with-libmp3lame --with-libopencore-amrnb --with-libopencore-amrwb --with-libopenjpeg --with-openssl --with-libopus --with-libschroedinger --with-libspeex --with-libtheora --with-libvo-aacenc --with-libvorbis --with-libvpx --with-libx264 --with-libxvid
# Easy Peasy
ffmpeg -i video.mp4 video.webm
@alephart
alephart / wordpress-valet-install.md
Created January 7, 2021 12:54 — forked from orumad/wordpress-valet-install.md
How to install Wordpress from command line in Valet

How to install Wordpress from command line in Valet

I use Valet as my local web development environment (PHP, Laravel, Wordpress, ...)

This gist is my own recipe to install Wordpress from the command line to use it with Valet. Maybe this is useful for you too.

Install 'WP-CLI' command line tool

@alephart
alephart / orderby_date.js
Last active October 3, 2020 04:43
orderBy date with javascript, moment and lodash
// require moment and lodash
import moment from 'moment';
import _ from 'lodash';
// Option 1
function sortByDate(array, element) {
const sortedArray = array.sort((a, b) => moment(a[element]).diff(moment(b[element])));
return sortedArray;
}