Skip to content

Instantly share code, notes, and snippets.

View vlkv's full-sized avatar
🏠
Working from home

Vitaly Volkov vlkv

🏠
Working from home
  • none
  • Georgia
View GitHub Profile
0 = Success
1 = Operation not permitted
2 = No such file or directory
3 = No such process
4 = Interrupted system call
5 = Input/output error
6 = No such device or address
7 = Argument list too long
8 = Exec format error
@vlkv
vlkv / keybindings.json
Last active February 8, 2022 08:45
My vscode keybindings
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "alt+i",
"command": "workbench.files.action.focusFilesExplorer"
},
{
"key": "alt+i",
"command": "workbench.action.focusActiveEditorGroup",
"when": "filesExplorerFocus"
@vlkv
vlkv / DivideChocolateSolution.java
Last active July 15, 2020 10:19
Divide chocolate problem from leetcode
/*
From: https://leetcode.com/problems/divide-chocolate/
NOTE: very similar to: https://leetcode.com/problems/split-array-largest-sum/solution/
You have one chocolate bar that consists of some chunks. Each chunk has its own
sweetness given by the array sweetness.
You want to share the chocolate with your K friends so you start cutting the chocolate
bar into K+1 pieces using K cuts, each piece consists of some consecutive chunks.
Being generous, you will eat the piece with the minimum total sweetness and give the
other pieces to your friends.
Find the maximum total sweetness of the piece you can get by cutting the chocolate bar optimally.
@vlkv
vlkv / cmd_args.sh
Created May 19, 2020 19:31
HOWTO Command line parameters for a shell script
#!/bin/bash -ex
# Taken from https://unix.stackexchange.com/a/353639
CONFIG="default.json"
REBUILD="false"
for ARGUMENT in "$@"
do
KEY=$(echo $ARGUMENT | cut -f1 -d=)
VALUE=$(echo $ARGUMENT | cut -f2 -d=)

Un-checkout

To "un-checkout" some <path> from working directory:

svn update --set-depth exclude <path>

More on this: svn update --set-depth exclude

@vlkv
vlkv / Solution.java
Last active April 9, 2020 09:23
Vestigium
import java.lang.*;
import java.util.*;
// https://codingcompetitions.withgoogle.com/codejam/round/000000000019fd27/000000000020993c
public class Solution {
public static void main(String[] args) {
Matrix[] ms = null;
try (Scanner sc = new Scanner(System.in)) {
int T = sc.nextInt();
ms = new Matrix[T];
@vlkv
vlkv / Solution.java
Created April 9, 2020 09:22
Nesting Depth
import java.lang.*;
import java.util.*;
// https://codingcompetitions.withgoogle.com/codejam/round/000000000019fd27/0000000000209a9f
public class Solution {
public static void main(String[] args) {
String[] strs = null;
try (Scanner sc = new Scanner(System.in)) {
int T = sc.nextInt();
sc.nextLine();
@vlkv
vlkv / Solution.java
Last active April 9, 2020 09:22
Parenting Partnering Returns
import java.lang.*;
import java.util.*;
// https://codingcompetitions.withgoogle.com/codejam/round/000000000019fd27/000000000020bdf9
public class Solution {
public static void main(String[] args) {
Case[] cases = null;
try (Scanner sc = new Scanner(System.in)) {
int T = sc.nextInt();
cases = new Case[T];
@vlkv
vlkv / Solution.java
Last active April 10, 2020 06:23
ESAb ATAd
import java.lang.*;
import java.util.*;
/** Compile and run it with a command:
$ javac Solution.java && python interactive_runner.py python local_testing_tool.py 0 -- java Solution
Use 0, 1, 2 - different test sets.
Source https://codingcompetitions.withgoogle.com/codejam/round/000000000019fd27/0000000000209a9e
*/
public class Solution {
private enum Fluct {

Vim cheatsheet

Modes

  • i insert mode, a - insert mode (append to the right of cursor)
  • o insert a new line after cursor line
  • O insert a new line before the cursor line
  • Esc normal/command mode