Skip to content

Instantly share code, notes, and snippets.

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:

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

#!/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
@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

from Crypto.Cipher import AES
import random
MIN_CIPHER = 1000000000000000
MAX_CIPHER = 1000000000010000
PLAIN_TEXT = 'test some plain text here'.rjust(32)
### encrypt ###
def generate_ciphers(ciphers_len):

hellinger-distance-criterion

virtualenv

Assumes that python3.5 installed on the machine

git clone https://github.com/EvgeniDubov/hellinger-distance-criterion.git
cd hellinger-distance-criterion/
virtualenv dev  -p /usr/bin/python3.5 --no-site-packages
@eeddaann
eeddaann / find_pid_by_port.md
Last active January 3, 2019 22:02
find pid by port

find pid by port

lsof -wni tcp:3000
@eeddaann
eeddaann / calsium.js
Last active January 16, 2019 06:40
calsium wip
var viewer = new Cesium.Viewer('cesiumContainer', {
terrainProviderViewModels : [], //Disable terrain changing
infoBox : false, //Disable InfoBox widget
selectionIndicator : false //Disable selection indicator
});
//Enable lighting based on sun/moon positions
viewer.scene.globe.enableLighting = true;
//Use STK World Terrain
import pandas as pd
# Create dummy Data Frame
df = pd.DataFrame({
'A': [1,2,-3],
'B': [2,-4,6],
'C': [3,5,-7]
})
print(df.corr().unstack().sort_values().drop_duplicates())
<!doctype html>
<html>
<head>
<title>Hello Webpack</title>
</head>
<body>
<textarea name="" id="input" cols="130" rows="10">a AND b OR c</textarea>
<div>
<button type="button" id="submit">Submit</button>
</div>