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 / 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 / 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" {
# Zeppelin install
pkg="zeppelin-0.8.0-bin-all.tgz"
wget "http://apache.rediris.es/zeppelin/zeppelin-0.8.0/$pkg"
tar xvzf $pkg
cd zeppelin-0.8.0-bin-all
prinf "Installing interpreters... \n"
./bin/install-interpreter.sh --all
printf "Starting Zeppelin... \n"
@milnomada
milnomada / perlin-noise-classical.js
Created November 8, 2018 20:56 — forked from banksean/perlin-noise-classical.js
two Perlin noise generators in javascript. The simplex version is about 10% faster (in Chrome at least, haven't tried other browsers)
// Ported from Stefan Gustavson's java implementation
// http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
// Read Stefan's excellent paper for details on how this code works.
//
// Sean McCullough banksean@gmail.com
/**
* You can pass in a random number generator object if you like.
* It is assumed to have a random() method.
*/
@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