Skip to content

Instantly share code, notes, and snippets.

@vladholubiev
vladholubiev / aliases.md
Last active August 29, 2015 14:13
My git aliases
Count lines in repository
  • alias.lines diff --shortstat 4b825dc642cb6eb9a060e54bf8d69288fbee4904
Pretty log
  • alias.lg1 log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
  • alias.lg2 log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(rese t)' --all
  • alias.lg !git lg1
@vladholubiev
vladholubiev / gist:3a1d6614162a2e7d8b6a
Created February 3, 2015 12:13
Побажання для MapKit 2015
  • При переході на список правок на вибраній території - відразу переходити на вкладку "Для відгуків"

@vladholubiev
vladholubiev / refactoring-example.md
Created February 5, 2015 01:12
Method before and after refactoring

Before

public static void addFragment(FragmentTransaction fragmentTransaction, Fragment fragment) {
    if (fragment.isAdded()) {
        for (Fragment aFragment : FragmentsKeeper.getAll()) {
            fragmentTransaction.hide(aFragment);
        }
        fragmentTransaction.show(fragment);
        fragmentTransaction.commit();
    } else {
@vladholubiev
vladholubiev / pi-guesser.java
Created February 6, 2015 09:49
Enter your approximated PI number, desired precision and find out if you guessed well.
package com.company;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
private static BufferedReader consoleReader = new BufferedReader(new InputStreamReader(System.in));
private static String fullPi = String.valueOf(Math.PI);
@vladholubiev
vladholubiev / lines-in-file.md
Created February 13, 2015 01:47
How to count all the lines of code in a directory recursively?
find . -name "*.*" -not -path "./tests*" | xargs wc -l
@vladholubiev
vladholubiev / printMostFrequentWords.java
Created February 15, 2015 22:25
10 lines - write to file most frequent words from .txt
public static void printMostFrequentWords() throws Exception {
PrintWriter fileWriter = new PrintWriter("output.txt");
List<String> words = Arrays.asList(new String(Files.readAllBytes(Paths.get("input.txt"))).split("\\s+"));
words.stream().distinct()
.map((word) -> String.join("", Arrays.asList(word.split("")).stream()
.filter((character) -> Character.isLetter(character.charAt(0)))
.collect(Collectors.toList())))
.map((word) -> new AbstractMap.SimpleEntry<>(word, Collections.frequency(words, word)))
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue()))
.forEach((entry) -> fileWriter.println(entry.getValue() + " - " + entry.getKey()));
@vladholubiev
vladholubiev / ip-extractor.java
Created February 23, 2015 16:48
Extract all IPv4 from .txt file
public static void main(String[] args) throws IOException {
System.out.println("Welcome to IP-EXTRACTOR");
System.out.println("Make sure you have ip.txt file in the same directory");
System.out.println("Press Enter to start");
Scanner scanner = new Scanner(System.in);
scanner.nextLine();
Pattern ipPattern = Pattern.compile("\\b(?:[0-9]{1,3}\\.){3}[0-9]{1,3}\\b");
@vladholubiev
vladholubiev / index.html
Created April 18, 2015 18:54
Moving bus - jsbin.com/weruqidazu/2/edit?output
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
</head>
<body>
<img style="position: fixed;" src="http://www.crk12.org/cms/lib7/DE01903180/Centricity/Domain/444/bus.gif" alt=""/>
</body>
</html>
package ua.samosfator;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
sudo su - -c "R -e \"install.packages('XML', repos='http://cran.rstudio.com/')\""