Skip to content

Instantly share code, notes, and snippets.

@solomkinmv
solomkinmv / workflow-build.py
Created March 20, 2019 22:14 — forked from deanishe/workflow-build.py
Build Alfred Workflows into .alfredworkflow (zip) files
#!/usr/bin/python
# encoding: utf-8
#
# Copyright (c) 2013 deanishe@deanishe.net.
#
# MIT Licence. See http://opensource.org/licenses/MIT
#
# Created on 2013-11-01
#
@solomkinmv
solomkinmv / TravellingSalesman
Created January 7, 2016 13:20
Greedy and Brute Force algorithms to solve Travelling Salesman Problem.
package salesman;
import geography.GeographicPoint;
import java.io.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@solomkinmv
solomkinmv / .bashrc
Created December 21, 2015 23:23
Bach configuration
# Environment
# export JAVA_HOME=/usr/lib/jvm/java-8-oracle/bin/java
TIJ=/home/maxim/dev/java/thinking_in_java/ # Thinking in Java code
export CLASSPATH=.:..:$TIJ
export PATH=$PATH:/opt/mongodb/bin
export PATH=$PATH:/opt/glassfish4/bin
# export PATH=$PATH:$JAVA_HOME:/opt/mongodb/bin:
# Git
@solomkinmv
solomkinmv / .vimrc
Last active December 21, 2015 15:25
Vim configuration
" Vundle
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
static String InfixToPrefix(String infix) {
char[] array = infix.toCharArray();
LinkedList<Character> operatorsList = new LinkedList<Character>();
StringBuffer result = new StringBuffer();
for (int i = array.length - 1; i >= 0; i--) {
char ch = array[i];
if (ch > '0' && ch < '9') {
result.insert(0, ch);
} else if (ch != '(' && ch != ')') {
operatorsList.add(ch);
@solomkinmv
solomkinmv / infixtopostfix.java
Last active September 3, 2015 19:20
InfixToPostfix
static String InfixToPostfix(String infix) {
LinkedList<String> stack = new LinkedList<>();
char[] array = infix.toCharArray();
StringBuffer result = new StringBuffer();
List<Character> operators = new ArrayList<>(Arrays.asList('+', '-', '*', '/'));
for (char ch: array) {
if (ch != '(') {
if (ch == ')') {
// check if stack is empty
result.append(stack.pop());
@solomkinmv
solomkinmv / strong-connected-components.py
Created July 17, 2015 08:17
Algorithm to find connected components in directed graph.
def strong_connected_components(G):
"""
Get strong connected components.
1. Get indices of vertices. The most connected vertices will
be earlier in list. From these elements we can go further in graph.
2. Invert graph.
3. Go through vertices in indices list. Every DFSR cycle gets
one component.
:param G: graph dictionary