Skip to content

Instantly share code, notes, and snippets.

@gscattolin
gscattolin / installDocker.sh
Last active June 6, 2021 04:47
Install docker on Centos rel 7 offline
wget --content-disposition https://nct.onlyoffice.com/sh/Xsy # Hello world image
wget http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.107-1.el7_6.noarch.rpm
wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-19.03.5-3.el7.x86_64.rpm
wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-cli-19.03.5-3.el7.x86_64.rpm
wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-selinux-17.03.3.ce-1.el7.noarch.rpm
wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
sudo rpm -i container-selinux-2.107-1.el7_6.noarch.rpm
sudo rpm -i docker-ce-19.03.5-3.el7.x86_64.rpm docker-ce-cli-19.03.5-3.el7.x86_64.rpm docker-ce-selinux-17.03.3.ce-1.el7.noarch.rpm containerd.io-1.2.6-3.3.el7.x86_64.rpm
sudo systemctl start docker
@gscattolin
gscattolin / conf
Last active September 19, 2023 11:45
Configuration logs by file
[loggers]
keys=root,sampleLogger
[handlers]
keys=consoleHandler
[formatters]
keys=sampleFormatter
[logger_root]
@gscattolin
gscattolin / gist:b705dfc0c994c70cb3eccb7f4221c933
Last active March 25, 2021 08:00
Python installation with open ssl support
sudo yum -y update
sudo yum -y groupinstall "Development Tools"
sudo yum -y install openssl-devel bzip2-devel libffi-devel
wget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz
tar xvf Python-3.8.5.tgz
cd Python-3.8.5
./configure --with-ssl
make & make altinstall
ln -s /usr/local/bin/pip3.8 /usr/bin/pip3
ln -s /usr/local/bin/python3.8 /usr/bin/python3
@gscattolin
gscattolin / gist:fd28043e8931358631b33b9c0d2bb21c
Last active March 22, 2021 11:40
remove cached files after updating gitignore
git rm -rf --cached .
git add .
git commit -m ".gitignore caching"
push
@gscattolin
gscattolin / gist:bad761f70b7f8022fd9c533e27d2e1a4
Created March 22, 2021 11:39
Centos warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
vi /etc/environment
add these lines...
LANG=en_US.utf-8
LC_ALL=en_US.utf-8
@gscattolin
gscattolin / gist:e2ecfc9e1abb20caf048f491943907a9
Created March 2, 2021 11:40
Reset Mariadb root password
systemctl stop mysqld / systemctl stop mariadb
service mysqld stop / service mariadb stop
mysqld --skip-grant-tables --user=root &
> mysql
FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root_passowrd';
exit
@gscattolin
gscattolin / MongoCommonCommands.txt
Last active August 15, 2016 05:38
MongoDb Most common commands
db.audit.remove({"reqTime" : { $lt : new Date('01/01/2016').getTime()}}) #remove everything is older than (bad performance)
db.audit.find().sort({"createdAt" : -1}).limit(1) #get latest created
db.collection.stats() #info about collection
export collection mongo in cvs file
mongoexport -h host -d dbname -c collectionname --type=csv -f name,side,type,field --out ~/export20160426.csv
db.fs.files.aggregate([{$group: {_id: "$contentType", total : { $sum: 1 }}}]) # count type on FS Grid
@gscattolin
gscattolin / ElasticSearch queries
Last active March 14, 2021 09:01
Elastic search most common curls
curl 'localhost:9200/_cat/indices?v' => list of index
curl 'localhost:9200/_cluster/health?pretty' => health
curl -XGET 'http://localhost:9200/_mapping/twitter' => map of index twitter
curl -XPOST 'localhost:9200/bank/_search?pretty' -d '
{
"size": 0,
"aggs": {
# first make sure that the virtual machine is running
docker-machine start dev
Set environment variables to dictate that docker should run a command against a particular machine:
$ eval "$(docker-machine env dev)"
Check if environment is set:
$ env | grep DOCKER
DOCKER_HOST=tcp://192.168.99.100:2376
DOCKER_CERT_PATH=/Users/dm/.docker/machines/.client
DOCKER_TLS_VERIFY=1
get add contains next remove(0) iterator.remove
ArrayList O(1) O(1) O(n) O(1) O(n) O(n)
LinkedList O(n) O(1) O(n) O(1) O(1) O(1)
CopyOnWrite-ArrayList O(1) O(n) O(n) O(1) O(n) O(n)
add contains next notes
HashSet O(1) O(1) O(h/n) h is the table capacity
LinkedHashSet O(1) O(1) O(1)
CopyOnWriteArraySet O(n) O(n) O(1)
EnumSet O(1) O(1) O(1)