Skip to content

Instantly share code, notes, and snippets.

View milnomada's full-sized avatar

milnomada milnomada

View GitHub Profile
@milnomada
milnomada / AutoSelect.js
Last active March 27, 2018 21:10
React Component for react-select module
import React from 'react';
import PropTypes from 'prop-types';
import Select from 'react-select';
const defaultValues = [
{ label: 'Chocolate', value: 'chocolate' },
{ label: 'Vanilla', value: 'vanilla' },
{ label: 'Strawberry', value: 'strawberry' },
{ label: 'Caramel', value: 'caramel' },
@milnomada
milnomada / gen.py
Last active May 20, 2018 01:51
Python password generator
import sys,random
size=8
if len(sys.argv)>1:
try:
size=int(sys.argv[1])
except ValueError:
pass
charset="!?#$%&*()_abcdefghijklmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"
print("".join(random.sample(charset,size)))
@milnomada
milnomada / runmd5.py
Last active June 2, 2018 22:53
Python md5 example
import hashlib, sys
def main(argv):
try:
_str=str(argv[0])
print(md5(_str))
except:
print("Invalid string")
@milnomada
milnomada / validate.js
Last active November 15, 2019 21:41
Javascript Validate Email
const validateEmail = (str) => {
var emailRe = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
var arr = emailRe.exec(str)
if(arr && arr.length) {
return arr[0]
}
else return false
}
@milnomada
milnomada / install-user
Created June 6, 2018 11:14
Add Ubuntu user with ssh access
# remote
user=username
host=192.168.2.2
adduser $user
sudo usermod -aG sudo $user
# local
key_name=rsa
cd .ssh
@milnomada
milnomada / iit.sh
Last active December 15, 2018 16:49
Install iptables firewall
# iptables
printf "Installing iptables-persistent..."
sudo apt-get update
sudo apt-get install iptables-persistent
printf "Setting basic rules...\n"
# sudo iptables -I INPUT -p tcp -s 10.1.1.2 --dport 22 -j ACCEPT -m comment --comment "Filter traffic to specific ip address"
@milnomada
milnomada / iue.sh
Last active December 16, 2018 03:05
Prepare uwsgi environment for Ubuntu 14.04 or 16.04
## Install pip installing
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
# Necessary gcc to install uwsgi
sudo apt-get install -y gcc git openssl
sudo pip install virtualenv
sudo apt-get install -y python3.5-dev python-dev
@milnomada
milnomada / install_logstash
Last active August 12, 2018 14:41
Install logstash and show/install plugins
# Help
# https://www.elastic.co/guide/en/logstash/current/plugins-outputs-solr_http.html
# https://www.elastic.co/guide/en/logstash/current/plugins-inputs-syslog.html
printf "Installing logstrash.."
name=logstash-6.3.2
pkg="$name.tar.gz"
wget "https://artifacts.elastic.co/downloads/logstash/$pkg"
tar -xvzf $pkg
# Solr configuration
input {
file {
path => "/var/log/syslog"
start_position => "end"
}
}
filter {
if [message] =~ "crawler" or [message] =~ "milnomada" {
version=6.6.0
printf "Installing Apache Solr $version ...\n"
name="solr-$version"
pkg="$name.tgz"
wget "https://archive.apache.org/dist/lucene/solr/$version/$pkg"
tar zxvf $pkg
cd $name
sudo add-apt-repository ppa:webupd8team/java