Skip to content

Instantly share code, notes, and snippets.

View evdokimovm's full-sized avatar

Mikhail Evdokimov evdokimovm

View GitHub Profile
@evdokimovm
evdokimovm / RubySimpleParseJSON.rb
Created January 6, 2016 01:19
Ruby Simple Parse JSON file
require 'json'
pets = File.open("file.json", "r")
doc = ""
pets.each do |line|
doc << line
end
pets.close
@evdokimovm
evdokimovm / histogram.rb
Created January 24, 2016 00:45
Simple Ruby Histogram
puts "Text please: "
text = gets.chomp
words = text.split(" ")
frequencies = Hash.new(0)
words.each { |word| frequencies[word] += 1 }
frequencies = frequencies.sort_by {|a, b| b }
frequencies.reverse!
@evdokimovm
evdokimovm / CRUD.rb
Created January 26, 2016 01:47
Simple Ruby CRUD Movies
movies = {
Memento: 3,
Primer: 4,
Ishtar: 1
}
puts "What would you like to do?"
puts "-- Type 'add' to add a movie."
puts "-- Type 'update' to update a movie."
puts "-- Type 'display' to display all movies."
@evdokimovm
evdokimovm / copy.js
Last active April 25, 2016 11:35
Copy files from multiple directories into one directory with Node.js, graceful-fs https://www.npmjs.com/package/graceful-fs and graceful-ncp package https://www.npmjs.com/package/graceful-ncp
var fs = require('graceful-fs');
var ncp = require('graceful-ncp').ncp;
// var FileQueue = require('filequeue');
// var fq = new FileQueue(100);
ncp.limit = 16;
fs.readdir(__dirname, function(err, files) {
for (var i = 0; i < files.length; i++) {
ncp(files[i], 'C:/path/to/output/folder', function(err) {
if (err) {
return console.error(err);
@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
@evdokimovm
evdokimovm / File Icons.sublime-settings
Last active January 31, 2017 18:30
My Sublime Text 3 User Settings File
{
"force_override": true,
"size": 11
}
<!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;