Skip to content

Instantly share code, notes, and snippets.

@eeddaann
eeddaann / test_redis.md
Created July 4, 2018 08:03
Test connection to Redis with netcat

Test connection to Redis with netcat

echo -e '*1\r\n$4\r\nPING\r\n' | nc redis.host.com 6379

#!/bin/bash
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
sudo apt-get update -y
sudo apt-get install -y mongodb-org
sudo service mongod start
wget http://worldcup.sfg.io/matches
mongoimport -d mongoaldb -c matches --type json --file matches --jsonArray
wget https://github.com/azat-co/mongoui/archive/master.zip
unzip master.zip

connect to nvidia container from AWS

start the instance

  • Go to ec2 instances console (in our case the region is Ohio)
  • Actions -> Instance State -> Start
  • Wait for the instance to start
  • copy the Public DNS (IPv4) from the instance description

Connect to the instance

to connect with ssh run the following command: ssh -i '/.../tensorrt_test.pem' ubuntu@INSTANCE_PUBLIC_DNS

def is_contained(sub,lst):
last_element_index = -1 # dummy value
if set(sub) > set(lst): # check if sub is subset of lst
return False
for i in range(len(sub)): # iterate over sub with for-loop
if sub[i] in lst: # check if element i in sub exists in lst
lst_indexes = [j for j, y in enumerate(lst) if y == sub[i]] # list of all occurrences of sub[i] in lst
if max(lst_indexes) > last_element_index + 1: # check if relevant elements are in ascending order
last_element_index = min(lst_indexes) # update last index
else:

Largest Files Windows

The following command show the 20 largest files on C:\ drive:

 dir c:\ -recurse -erroraction silentlycontinue | sort length -descending | select -first 20
@eeddaann
eeddaann / PromQL-docker-swarm-node-name.md
Last active March 2, 2021 14:11
query in PromQL to get docker swarm node names instead of node id

PromQL

Prometheus is a time-series db, it's query language called PromQL.

Here are some analogies from SQL which may help to understand the basics of PromQL better:

  • metric ~ sql table
  • label ~ sql column

example:

  • Count how many containers running on each node:
@eeddaann
eeddaann / Odometry.md
Last active November 13, 2017 22:13
Odometry - estimate errors

Odometry - estimate errors

  • N - Encoder resolution
  • r - Wheel radius
  • b - distance between wheels

The following equations are applied:

$$teta = 2*u/b u = 2*pi*r/n$$
@eeddaann
eeddaann / Grafana templating for docker service.md
Last active November 7, 2017 14:29
this gist help with creating grafana templating from docker swarm services

configure templating for docker service

  • create new variable with type Query and name it as you wish
  • under Query Options:
    • Query: container_tasks_state{state="running",container_label_com_docker_swarm_service_name=~".*_logstash"}
    • Regex: /.container_label_com_docker_swarm_service_name="(.)",container_label_com_docker_swarm_task_id=/

it will create variables for any service which ends with "logstash"

@eeddaann
eeddaann / sir_python
Last active July 14, 2021 22:12
sir model with age groups implemented in python
#!/usr/bin/env python
import numpy as np
from pylab import *
import scipy.integrate as spi
#Parameter Values
PopIn= {'g1s_young':1/12,'g1i_young':1/12,'g1r_young':1/12,'g1s_mid':1/12,'g1i_mid':1/12,'g1r_mid':1/12,'g1s_old':1/12,'g1i_old':1/12,'g1r_old':1/12,'g1s_vold':1/12,'g1i_vold':1/12,'g1r_vold':1/12}
arr = [1/12]*12
beta= 0.50