Skip to content

Instantly share code, notes, and snippets.

@AlexandroPerez
AlexandroPerez / terminal-config.md
Last active June 8, 2021 05:14
Windows Terminal oh-my-zsh theme configuration

Before using the following steps set Ubuntu's color scheme to Tango Dark, which is included in Windows Terminal color schemes. This is the best scheme to match the following setup.

  1. First install zsh and curl in wsl terminal. Also git if not installed yet, else omit.

$ sudo apt-get install zsh curl git

  1. Install oh-my-zsh. >When prompted to set zsh as your default shell type Yes
@AlexandroPerez
AlexandroPerez / responsive-images-newer.gulpfile.babel.js
Created July 22, 2018 07:26
Example of gulp-responsive and gulp-newer when doing 1:many images
import gulp from 'gulp';
import responsive from 'gulp-responsive';
import newer from 'gulp-newer';
import rename from 'gulp-rename';
/**
* NOTE: this has a flaw, as if one of the multiple images is deleted,
* gulp-newer will only check against one of them, so it will not
* create the missing image(s). Use only as a way to process new images
* only, not as a foolproof way to have all your responsive images always
@AlexandroPerez
AlexandroPerez / .gitconfig
Last active June 4, 2018 21:46
Favorite git aliases, color and core configurations for a Linux environment
[alias]
co = checkout
ci = commit
st = status
br = branch
hist = log --pretty=format:'%Cgreen%h %Creset%ad | %Cblue%s%Cred%d %Creset[%an]' --graph --date=short
type = cat-file -t
dump = cat-file -p
[color]
ui = auto
input[type=text]:focus, input[type=password]:focus, input[type=email]:focus, input[type=tel]:focus, input[type=date]:focus, input[type=month]:focus, input[type=week]:focus, input[type=time]:focus, input[type=number]:focus, input[type=search]:focus, input[type=url]:focus, textarea:focus {
color: black !important;
}
button, input[type=button], input[type=submit], .give-final-total-amount, input[type=text], input[type=password], input[type=email], input[type=tel], input[type=date], input[type=month], input[type=week], input[type=time], input[type=number], input[type=search], input[type=url], textarea {
color: black !important;
}
@AlexandroPerez
AlexandroPerez / .bashrc
Last active June 15, 2018 08:59
Cygwin and WSL colored bash prompt that shows current git branch if the folder is a git repo.
git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1]/'
}
# NOTE: The dollar sign ($) has to be escaped so that the above function is executed every time the prompt is shown
# like this: \$(git_branch)
export PS1="\[\e]0;\w\a\]\n\[\e[36m\]CygWin:\[\e[33m\]\w\[\e[0m\] \[\e[32m\]\[\e[1m\]\$(git_branch)\[\e[0m\]\n$ "
# For WSL
git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1]/'
@AlexandroPerez
AlexandroPerez / autosync.sh
Last active July 14, 2020 03:55
Auto Sync shell script for Cygwin. For requirements see: https://gist.github.com/AlexandroPerez/c6122b1f8648273f83b894e5c4436e6a
#!/bin/bash
# This script is meant to run in cygwin as a way to sync a Windows host to a Guest Vagrant Machine
# So you can edit your code in the host, sync changes to your vagrant machine, and let node/npm
# run in a local folder (no more symlink problems!)
#
# For requirements see: https://gist.github.com/AlexandroPerez/c6122b1f8648273f83b894e5c4436e6a
#
# Usage: autosync.sh user@host:/path/to/remote/folder
#
# Optional but recommended: add a .syncignore file to your folder, and add
@AlexandroPerez
AlexandroPerez / rsync_inotifywait_cigwin_-_host_to_vagrant_box.md
Last active March 14, 2018 14:45
Sync from windows host to vagrant box using cygwin, rsync and inotifywait

Requirements

You need to have cygwin and its following packages installed

  • make (Devel group -> make)
  • rsync (Net group -> rsync)
  • ssh (Net group -> openSSH)

NOTE: You may already have ssh installed due to git shell, or other shell installation, but make sure you install the cygwin version of ssh (openSSH)

@AlexandroPerez
AlexandroPerez / nginx_node_provision.sh
Created March 11, 2018 11:55
Script for installing latest nginx and node LTS. Can be used as a Vagrant provision script, or as a Google Cloud Startup Script
echo "Adding nginx deb and deb-src packages to /etc/apt/sources.list"
echo "deb http://nginx.org/packages/ubuntu/ xenial nginx" >> /etc/apt/sources.list
echo "deb-src http://nginx.org/packages/ubuntu/ xenial nginx" >> /etc/apt/sources.list
echo "Downloading nginx_signing.key..."
curl -Os https://nginx.org/keys/nginx_signing.key
echo "Adding it to the apt program keyring"
apt-key add ./nginx_signing.key
echo "Installing nginx..."
myPromise.then(function() {
// Some error may happen
throw('An exception that would be caught');
}).catch(function() {
console.log('error');
});
// Is the same as this, the errHandle tries to catch any unhandled error
// from previous result.
myPromise.then(func, null).then(null, errHandle);
@AlexandroPerez
AlexandroPerez / memory-optimization#using-hashes-to-abstract-a-very-memory-efficient-plain-key-value-store-on-top-of-redis.md
Last active January 14, 2020 03:38
Explaining the code: Using hashes to abstract a very memory efficient plain key-value store on top of Redis