Skip to content

Instantly share code, notes, and snippets.

View julianobarbosa's full-sized avatar
💭
I may be slow to respond.

Juliano Barbosa julianobarbosa

💭
I may be slow to respond.
View GitHub Profile
@julianobarbosa
julianobarbosa / is_port_open.py
Created February 7, 2020 10:46
Python, TCP, UDP, Port
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(2) #2 Second Timeout
result = sock.connect_ex(('127.0.0.1',80))
if result == 0:
print 'port OPEN'
else:
print 'port CLOSED, connect_ex returned: '+str(result)
@julianobarbosa
julianobarbosa / check_port.py
Created February 7, 2020 10:40
Python, TCP, UDP
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import socket
import re
import sys
def check_server(address, port):
# Create a TCP socket
s = socket.socket()
print "Attempting to connect to %s on port %s" % (address, port)
# -*- mode: ruby -*- 2 # vi: set ft = ruby : 3 4 VAGRANTFILE_API_VERSION = "2" 5 6 Vagrant.configure( VAGRANTFILE_API_VERSION) do | config | 7 # General Vagrant VM configuration. 8 config.vm.box = "geerlingguy/ centos7" 9 config.ssh.insert_key = false 10 config.vm.synced_folder ".", "/vagrant", disabled: true 11 config.vm.provider :virtualbox do | v | 12 v.memory = 256 13 v.linked_clone = true 14 end 15 16 # Application server 1. 17 config.vm.define "app1" do | app | 18 app.vm.hostname = "orc-app1. test" 19 app.vm.network :private_network, ip: "192.168.60.4" 20 end 21 22 # Application server 2. 23 config.vm.define "app2" do | app | 24 app.vm.hostname = "orc-app2. test" 25 app.vm.network :private_network, ip: "192.168.60.5" 26 end 27 28 # Database server. 29 config.vm.define "db" do | db
db.vm.hostname = "orc-db.test" 31 db.vm.network :private_network, ip: "192.168.60.6" 32 end 33 end This Vagrantfile
@julianobarbosa
julianobarbosa / run-ansible-with-any-host-without-inventory
Created November 17, 2019 22:15 — forked from lilongen/run-ansible-with-any-host-without-inventory
How to run Ansible without specifying the inventory but the host directly?
Question:
. How to run Ansible without specifying the inventory but the host directly?
. Run a playbook or command with arbitrary host not in the inventory hosts list?
. run ansible with arbitrary host/ip without inventory?
Answer:
Surprisingly, the trick is to append a ,
The host parameter preceding the , can be either a hostname or an IPv4/v6 address.
ansible all -i example.com,
@julianobarbosa
julianobarbosa / gitignore-init.md
Created August 19, 2019 14:58
Python .gitignore

Byte-compiled / optimized / DLL files

pycache/ *.py[cod] *$py.class

C extensions

*.so

Distribution / packaging

.Python

@julianobarbosa
julianobarbosa / pip-update.ps1
Created August 6, 2019 15:41
Python pip update
pip list -o | ForEach-Object { $data=$_ -split " "; python -m pip install -U $data[0]}
@julianobarbosa
julianobarbosa / vscode-settings.json
Last active August 14, 2019 15:12
vscode python settings
{
"shellLauncher.shells.windows": [
{
"shell": "C:\\Windows\\System32\\cmd.exe",
"label": "cmd"
},
{
"shell": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"label": "PowerShell 5.1"
},
@julianobarbosa
julianobarbosa / pip-update.md
Last active June 26, 2020 00:36
Python PIP Update

python -m pip list --outdated | awk '{print $1}' | xargs -n1 python -m pip install -U

@julianobarbosa
julianobarbosa / 256 colors.md
Created July 21, 2019 16:50 — forked from limingjie/256 colors.md
256 colors in putty, tmux/screen and vim

#256 colors in putty, tmux/screen and vim There is a detailed answer on stackoverflow. If you are looking for a short one, here it is.

  • putty

    Set Connection -> Data -> Terminal-type string to xterm-256color

  • tmux

Add this line to ~/.tmux.conf