Skip to content

Instantly share code, notes, and snippets.

View davidlares's full-sized avatar
🎯
Focusing

David E Lares S davidlares

🎯
Focusing
View GitHub Profile
@davidlares
davidlares / NPM.md
Last active April 17, 2019 04:45
Node's NPM CLI commands and SemVer for software projects

NPM Commands

  1. npm init: NPM package manifest wizard
  2. npm whoami: check for the authenticated user
  3. npm adduser: add a user to the NPM session
  4. npm init --scope=<username>: add the auth user to the NPM .json manifest
  5. npm install <modulename>: installing a specific NPM module or package
  6. npm ls: dependencies listing (specific directory)
  7. npm test: run tests using the scripts located at the package.json file
@davidlares
davidlares / disallow.py
Created August 8, 2019 02:37
Python script for checking robots.txt's 'Disallow' property presence with urllib2
#!/usr/bin/python
import urllib2
class DisallowPresent(Exception):
def __init__(self, path) :
self.disallowed = path
def __str__(self) :
@davidlares
davidlares / tcpClient.py
Last active September 2, 2019 01:51
Client-Server programming using sockets (Python built-in library)
#!/usr/bin/python
# socket network module (methods and APIs)
import socket
import sys
# creating a TCP Socket -> listening to an specific port
# AF_INET -> address family , SOCK_STREAM -> Kind of socket (required)
tcpSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@davidlares
davidlares / setup.sh
Last active September 2, 2019 01:56
Rails 5.2 full environment Setup for Debian/Ubuntu OS
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install -y git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev nodejs yarn
cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
@davidlares
davidlares / data.sh
Last active September 11, 2019 19:56
Terraform's Digital Ocean instance configuration files with an Nginx Server
apt-get update && apt-get install nginx -y
@davidlares
davidlares / hosts
Last active January 2, 2020 19:41
Digital Ocean's basic droplet setup with Ansible
[server]
Here goes your Droplet IP
[server:vars]
ansible_user=root
ansible_ssh_private_key_file=~/.ssh/id_rsa.pub
@davidlares
davidlares / delete.sh
Last active January 3, 2020 22:21
Deleting/Disabling local system Linux Users
#!/bin/bash
# deleting - disabling linux accounts
readonly ARCHIVE_DIR='/archive' # program variable
usage() {
echo "Usage: ${0} [-dra] USER [USERN]"
echo "Disable a local Linux account"
echo "-d Deletes accounts instead of disabling them"
@davidlares
davidlares / ports.sh
Last active January 4, 2020 02:34
Simple script for checking open ports TCPv4 with Bash
#!/bin/bash
# this script shows the open network ports on a system
# -4 to limit TCP IPv4 ports
if [[ "${1}" = '-4' ]]
then
netstat -nutl ${1} | grep ':' | awk '{print $4}' | awk -F ':' '{print $NF}'
fi
@davidlares
davidlares / Vagrantfile
Created January 4, 2020 02:24
Remote SSH command execution with Vagrant machines
Vagrant.configure("2") do |config|
config.vm.box = "jasonc/centos7"
# first machine
config.vm.define "admin01" do |admin01|
admin01.vm.hostname = 'admin01'
admin01.vm.network "private_network", ip: "10.9.8.10"
end
# second machine
@davidlares
davidlares / script.py
Created February 1, 2020 22:04
Writing Windows System Registries and file transferring with Python 2.x
#!/usr/bin/python
import os
import shutil
import _winreg as wreg
import subprocess
# getting the cwd
path = os.getcwd().strip('\n')
# grabbing the username using a subprocess command for building the destination path
null, user = subprocess.check_output('set USERPROFILE', shell=True).split('=') # C:\Users\Administrador