Skip to content

Instantly share code, notes, and snippets.

View aleGpereira's full-sized avatar
😎
Enjoying

Alejandro Pereira aleGpereira

😎
Enjoying
  • Vancouver, BC, Canada
View GitHub Profile
@aleGpereira
aleGpereira / axios-catch-error.js
Created September 4, 2019 21:01 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@aleGpereira
aleGpereira / gist:09f7d4ac1a31127b2b8fcfca8935a35b
Last active June 19, 2019 14:42
Spotify Player controls shortcuts Ubuntu 16.04
Play/Pause toggle:
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
Previous:
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous
Next:
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next
@aleGpereira
aleGpereira / gist:bfd107ccc249570fb99c8c49f777a69f
Created May 24, 2019 01:45
venv + git branch prompt (ubuntu)
# Git bash + venv
# bash_prompt
# The various escape codes that we can use to color our prompt.
RED="\[\033[0;31m\]"
YELLOW="\[\033[1;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[1;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
@aleGpereira
aleGpereira / venvwrapper_premkvirtualenv.txt
Last active February 19, 2019 12:44
VirtualenvWrapper go to project folder postactivate
#!/bin/bash
# This hook should go to $WORKON_HOME/premkvirtualenv
typeset repo_name=${1}
typeset repo_path="path/to/your/${repo_name}"
echo "cd $HOME/$repo_path" >> "$WORKON_HOME/$repo_name/bin/postactivate"
echo "if [ \$? -eq 0 ]; then" >> "$WORKON_HOME/$repo_name/bin/postactivate"
echo " clear" >> "$WORKON_HOME/$repo_name/bin/postactivate"
echo "else" >> "$WORKON_HOME/$repo_name/bin/postactivate"
echo " echo \"No directory found. Is the venv name equal to project name?\"" >> "$WORKON_HOME/$repo_name/bin/postactivate"
echo "fi" >> "$WORKON_HOME/$repo_name/bin/postactivate"
{
"Resources" : {
"CFVPC": {
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": "10.0.0.0/16",
"EnableDnsSupport": "true",
"EnableDnsHostnames": "true",
"InstanceTenancy": "default"
}
{
"Resources" : {
"CFVPC": {
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": "10.0.0.0/16",
"EnableDnsSupport": "true",
"EnableDnsHostnames": "true",
"InstanceTenancy": "default"
}
@aleGpereira
aleGpereira / xmodmap
Created June 3, 2016 05:52
Key Swaps
!
! Swap Caps_Lock with Shift_L and Shift_L with Ctrl_L. Also swap
! pgup with home and pgdown with end.
!
remove Shift = Shift_L
remove Control = Control_L
remove Lock = Caps_Lock
keycode 66 = Shift_L
keycode 50 = Control_L
keycode 110 = Prior