Skip to content

Instantly share code, notes, and snippets.

@evgenii-malov
evgenii-malov / docker.md
Last active October 14, 2016 23:04
docker workflow

Docker workflow

example Dockerfile

Dockerfile
FROM davidjfelix/python3.5
RUN pip3 install aiohttp
RUN pip3 install aiomysql
ADD . /seo_server
WORKDIR /seo_server
CMD python seo_server.py

sudo mysqld_safe --user=mysql --skip-grant-tables #mysql without auth

CREATE DATABASE mydatabase CHARACTER SET utf8 COLLATE utf8_general_ci;

show processlist;

show create table <name>;

Mount remote server

sshfs root@engine:/ /home/se7en/mount_servers/

Ssh with no password

Execute these two commands:

ssh-keygen

Then you'll need to copy the new key to your server:

@evgenii-malov
evgenii-malov / ab
Last active September 28, 2016 22:51
ab -c 20 -n 2000 http://127.0.0.1:8080/
ab -c 20 -n 2000 -C 'AIOHTTP_SESSION="{\"session\": {\"user_id\": [17]}\054 \"created\": 1475102992}"' http://127.0.0.1:8080/
*Partial в javascript
function f(param1,param2)
{
}
bf = f.bind(this,param1,param2);
bf()
async def insert_one(pool, sql, params):
async with pool.acquire() as conn:
async with conn.cursor() as cur:
try:
await cur.execute(sql, params)
value = await cur.fetchone()
except Exception as e:
await conn.rollback()
-- see video for description: https://www.youtube.com/watch?v=4mrBrJw_tVc&feature=youtu.be
-- (Nodes must be uniq)
import Data.Set
import Data.List.Split (chunksOf)
data Btree a = Leaf a | Node a (Btree a) (Btree a) deriving Show
tr :: Btree Integer
tr_l = Node 1 (Leaf 2) (Leaf 3)
tr_r = Node 4 (Leaf 5) (Leaf 6)
tr = Node 7 tr_l tr_r
@evgenii-malov
evgenii-malov / haskell_binary_tree_traversal .hs
Created January 18, 2021 21:33
haskell binary tree traversal - inorder, postorder, preorder
-- see video https://youtu.be/sv9y04GHvmY
data Btree a = Leaf a | Node a (Btree a) (Btree a) deriving Show
tr :: Btree Integer
tr_l = Node 1 (Leaf 2) (Leaf 3)
tr_r = Node 4 (Leaf 5) (Leaf 6)
tr = Node 7 tr_l tr_r
pre_order :: Btree a -> [a]
-- see video https://www.youtube.com/watch?v=j8r17UrWSyE&t=319s
data Btree a = Leaf a | Node a (Btree a) (Btree a) deriving Show
tr :: Btree Integer
tr_l = Node 1 (Leaf 2) (Leaf 3)
tr_r = Node 4 (Leaf 5) (Leaf 6)
tr = Node 7 tr_l tr_r
all_paths :: Btree a -> [[a]]
all_paths (Leaf a) = [[a]]
@evgenii-malov
evgenii-malov / bitcoin_monitor2.hs
Created January 18, 2021 21:53
Bitcoin price monitor in haskell
-- see video https://youtu.be/M4_OW2_zXQo
import Network.HTTP.Conduit
import Text.JSON.JPath
import Data.ByteString.Lazy.Char8 (unpack)
import Control.Concurrent
import Control.Exception
import Control.Applicative
import Control.Monad.Loops
u = "https://api.bittrex.com/api/v1.1/public/getticker?market=USD-BTC"