Skip to content

Instantly share code, notes, and snippets.

View evdokimovm's full-sized avatar

Mikhail Evdokimov evdokimovm

View GitHub Profile
@evdokimovm
evdokimovm / install-mongodb.md
Created August 6, 2016 20:31 — forked from adamgibbons/install-mongodb.md
Install MongoDB on Mac OS X 10.9

Install MongoDB with Homebrew

brew install mongodb
mkdir -p /data/db

Set permissions for the data directory

Ensure that user account running mongod has correct permissions for the directory:

If you are still on Trusty you'll need a modern gcc toolchain.

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo add-apt-repository ppa:ubuntu-lxc/lxd-stable
sudo apt-get update
sudo apt-get install build-essential git scons libssl-dev gcc-6 g++-6 
sudo apt-get install libboost-filesystem-dev libboost-program-options-dev libboost-system-dev libboost-thread-dev
sudo apt-get install python-pymongo 
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 1
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 1
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
bash -c zsh
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>Hello</h1>
<img src="<%= data[0].path %>" alt="">
</body>
@evdokimovm
evdokimovm / app.js
Created December 4, 2017 07:36 — forked from raddeus/app.js
Basic Express 4.0 Setup with connect-flash
var express = require('express');
var session = require('express-session');
var cookieParser = require('cookie-parser');
var flash = require('connect-flash');
var app = express();
app.use(cookieParser('secret'));
app.use(session({cookie: { maxAge: 60000 }}));
app.use(flash());
@evdokimovm
evdokimovm / gist:08f34089f0d032f2d7364fc1de9d70da
Created November 25, 2018 06:33 — forked from AndrewRayCode/gist:3784055
jQuery plugin for shift + click to select multiple checkboxes
// Usage: $form.find('input[type="checkbox"]').shiftSelectable();
// replace input[type="checkbox"] with the selector to match your list of checkboxes
$.fn.shiftSelectable = function() {
var lastChecked,
$boxes = this;
$boxes.click(function(evt) {
if(!lastChecked) {
lastChecked = this;
@evdokimovm
evdokimovm / euclidean_distance.py
Created February 24, 2019 08:05
euclidean distance
def euclidean_distance(pt1, pt2):
distance = 0
for i in range(len(pt1)):
distance += (pt1[i] - pt2[i]) ** 2
return distance ** 0.5
print(euclidean_distance([1, 2], [4, 0]))
print(euclidean_distance([5, 4, 3], [1, 7, 9]))
@evdokimovm
evdokimovm / distance.py
Created February 24, 2019 08:30
distance formulas euclidean manhattan hamming
def euclidean_distance(pt1, pt2):
distance = 0
for i in range(len(pt1)):
distance += (pt1[i] - pt2[i]) ** 2
return distance ** 0.5
def manhattan_distance(pt1, pt2):
distance = 0
for i in range(len(pt1)):
distance += abs(pt1[i] - pt2[i])
@evdokimovm
evdokimovm / copy.sh
Last active March 11, 2020 09:23
copy all files with specific extension using grep. supports files with spaces in their titles also.
ls | grep "png" | xargs -d "\n" cp -t $target_dir
@evdokimovm
evdokimovm / getpermissions.sh
Created May 29, 2020 15:18
Get octal file permissions number
# Get octal file permissions number
# https://www.cyberciti.biz/faq/get-octal-file-permissions-from-command-line-on-linuxunix/
stat -c '%a' /etc/passwd