Skip to content

Instantly share code, notes, and snippets.

View ykushch's full-sized avatar
🎯
Focusing

Yuri ykushch

🎯
Focusing
View GitHub Profile
@ykushch
ykushch / CustomCronExpression
Created October 12, 2014 21:11
Implemented missing getTimeBefore(); Method by default return null. The key issue was in getting the previous run time when quartz-task hasn't yet been executed.
public class CustomCronExpression extends CronExpression {
private static final String DELIMITER = " ";
/**
* Constructs a new <CODE>CronExpression</CODE> based on the specified
* parameter.
*
* @param cronExpression String representation of the cron expression the
* new object should represent
* @throws java.text.ParseException if the string expression cannot be parsed into a valid
* <CODE>CronExpression</CODE>
@ykushch
ykushch / latency.markdown
Created December 7, 2015 16:18 — forked from valadan/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@ykushch
ykushch / System Design.md
Created April 23, 2016 07:00 — forked from vasanthk/System Design.md
System Design Cheatsheet

#System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

##Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@ykushch
ykushch / gist:962f96485b6e97993f6fbcc37a93a3c4
Created April 24, 2016 10:52 — forked from carlosmcevilly/gist:2221249
fix git commit with wrong email address in git config, before pushing
If:
- you add and commit with the wrong email address in git, and
- your remote has a hook set up to prevent you from pushing with the bad address
Then you need to amend the author of your commit before push can succeed:
1. fix your email address in git config:
$ git config user.name "Your Name"
@ykushch
ykushch / Dockerfile
Last active June 7, 2016 17:43
Docker file to install base image and Java 8 image (Oracle). Also this script contains build.sh file to simplify build process.
# image that solves PID 1 issue
FROM phusion/baseimage:0.9.17
# make sure that package repository is up to date
RUN \
sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \
apt-get update && \
apt-get -y upgrade && \
locale-gen en_US.UTF-8
FROM ykushch/java8
ENV TOMCAT_MAJOR_VERSION 8
ENV TOMCAT_MINOR_VERSION 8.0.20
ENV CATALINA_HOME /opt/tomcat
RUN apt-get update && \
apt-get install -yq --no-install-recommends pwgen ca-certificates && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
@ykushch
ykushch / .bashrc
Created August 13, 2016 09:13 — forked from vsouza/.bashrc
Golang 1.5 setup in Mac OSX with HomeBrew. Set `GOPATH` and `GOROOT` variables in zshell or bash.
# Set variables in .bashrc file
# don't forget to change your path correctly!
export GOPATH=$HOME/golang
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
df -PH | grep -vE '^Filesystem|none|cdrom' | awk '{ print $5 " " $1 }' | while read -r output;
do
echo "$output"
usep=$(echo "$output" | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo "$output" | awk '{ print $2 }' )
if [ "$usep" -ge 90 ]; then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
mail -s "Alert: Almost out of disk space $usep%" -r system@server sendto@email.com
@ykushch
ykushch / gist:0a1055387ece5c2cf0d6295de37883f2
Created August 23, 2017 07:29 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@ykushch
ykushch / Solution.java
Last active May 30, 2024 08:30
Second task of HackerRank
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Solution {
public static int[] counts(int[] nums, int[] maxes) {
Arrays.sort(nums);
List<Integer> result = new ArrayList<>();
for (int m : maxes) {