Skip to content

Instantly share code, notes, and snippets.

View fulgorek's full-sized avatar

Alejandro Torres fulgorek

View GitHub Profile

Keybase proof

I hereby claim:

  • I am fulgorek on github.
  • I am fulgorek (https://keybase.io/fulgorek) on keybase.
  • I have a public key ASDPjjHlLkufnjQm59hGcuRcUDKbdrKGULJAPbZkCNdXZAo

To claim this, I am signing this object:

@fulgorek
fulgorek / ask.sh
Created January 12, 2019 12:29
Bash General-Purpose Yes/No Prompt Function ("ask")
# This is a general-purpose function to ask Yes/No questions in Bash, either
# with or without a default answer. It keeps repeating the question until it
# gets a valid answer.
ask() {
# https://gist.github.com/davejamesmiller/1965569
local prompt default reply
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
@fulgorek
fulgorek / basic.sh
Created June 22, 2018 21:11
bash basic
#1. print the first 10 lines of /var/log/syslog
head -n 10 /var/log/syslog
#2. print the last 10 lines of /var/log/syslog
tail -n 10 /var/log/syslog
#3. print the Nth line of /var/log/syslog
sed "100q;d" /var/log/syslog (replace 100 for the line number you want to)
#4. print username, uid, gid fields from /etc/passwd
@fulgorek
fulgorek / install-packer-on-mac-os.sh
Created April 19, 2017 13:07 — forked from akora/install-packer-on-mac-os.sh
Install packer on Mac OS
curl -O -L https://dl.bintray.com/mitchellh/packer/packer_0.7.5_darwin_amd64.zip
unzip packer_0.7.5_darwin_amd64.zip
sudo mv packer_0.7 /usr/local/packer
sudo chown $USER /usr/local/packer/
# then update your .bash_profile with the new path e.g.:
# export PATH="/usr/local/git/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/local/packer:$PATH"
# Machine name.
function box_name {
[ -f ~/.box-name ] && cat ~/.box-name || echo $HOST
}
# Directory info.
# local current_dir='${PWD/#$HOME/~}'
local current_dir='[%c]'
# VCS
@fulgorek
fulgorek / manage-etc-hosts.sh
Created May 14, 2016 13:51 — forked from irazasyed/manage-etc-hosts.sh
Bash Script to Manage /etc/hosts file for adding/removing hostnames.
#!/bin/sh
# PATH TO YOUR HOSTS FILE
ETC_HOSTS=/etc/hosts
# DEFAULT IP FOR HOSTNAME
IP="127.0.0.1"
# Hostname to add/remove.
HOSTNAME=$1
@fulgorek
fulgorek / structure.txt
Created May 10, 2016 03:12 — forked from kwilczynski/structure.txt
Terraform structure
.
├── common
│   └── s3-buckets
├── environments
│   ├── ci
│   ├── management
│   │   ├── files
│   │   │   └── user-data.sh
│   │   ├── templates
│   │   │   └── script.sh.tpl
@fulgorek
fulgorek / list.txt
Last active May 6, 2016 03:31
To do in Itamae
ntp ✓
ntpdate ✓
sysstat
molly-guard
rsyslog
ssh (the SSH server) ✓
clamav
freshclam (service should be disabled)
locales ✓
time zone (TZ) ✓
@fulgorek
fulgorek / loop.js
Created December 19, 2015 18:02
Simple loop iteration with multiples
//Write a program that prints the numbers from 1 to 100. with the following conditions:
//For multiples of three [3] print “Hello” instead of the number.
//For the multiples of five [5] print “World” instead of the number.
//For numbers which are multiples of both three [3] and five[5] print “Hello World” instead of the number.
// we create a loop which iterate 100 times
for (i=0; i<100; i++){
if(i % 15 == 0){