Skip to content

Instantly share code, notes, and snippets.

@budnik
budnik / d1t1.rb
Last active December 24, 2019 16:29
advent2019
def move(d, l, c)
case d
when ?R then [c.first+l, c.last]
when ?L then [c.first-l, c.last]
when ?U then [c.first, c.last-l]
when ?D then [c.first, c.last+l]
end
end
@budnik
budnik / sort.rb
Created November 19, 2017 15:20
Crossover chalange sort
def rearrange(elements)
number_of_ones = Hash.new {|h, n| h[n] = n.to_s(2).each_char.count('1')}
elements.map(&:to_i).uniq.sort do |a,b|
noo_a = number_of_ones[a]
noo_b = number_of_ones[b]
if noo_a==noo_b
a<=>b
else
noo_a<=>noo_b
@budnik
budnik / keybase.md
Created August 4, 2017 10:03
keybase.md

Keybase proof

I hereby claim:

  • I am budnik on github.
  • I am d1b (https://keybase.io/d1b) on keybase.
  • I have a public key ASDUPAxNntz18-tztBGELj3Pm2I5798jj8UgJxT61DHYdgo

To claim this, I am signing this object:

def solution(a)
sum = a[0]
sum += a[-1] if a[-1] < 0
negative = []
a[1..-1].each_with_index do |el,i|
if el >= 0
sum+=el
elsif i==a.size-2 || a[i+2]>=0
chunk = (i+1).downto(1).take_while{|j| a[j]<0}
negative << a[chunk.last..chunk.first] if chunk.size>=6
ar = [:a, :b, :c]
ar.each_with_index.each do |x,xi|
p ar[xi]
end
@budnik
budnik / govbot.sh
Created June 17, 2015 08:45
Heroku config for govbot
HUBOT_GITHUB_EVENT_NOTIFIER_ROOM: #random
HUBOT_GITHUB_EVENT_NOTIFIER_TYPES: issues,issue_comment
HUBOT_GITHUB_MILESTONES_ROOMS: {"https://github.com/e-government-ua/i/milestones/Portal-FrontEnd_PHP": "#_portal-front_php",
"https://github.com/e-government-ua/i/milestones/BackEnd-ActivitiExplorer_Java-GWT": "#_back-actexp_java-gwt",
"https://github.com/e-government-ua/i/milestones/Portal-Dashboard_NodeJS-Java": "#_portal-dashboard_js",
"https://github.com/e-government-ua/i/milestones/BackEnd-REST-Activiti_Java": "#_back-rest-act_java",
"https://github.com/e-government-ua/i/milestones/Auth": "#_auth",
"https://github.com/e-government-ua/i/milestones/BA-BusinesProcess-ActivitiDesigner": "#_ba-process-actdesign",
"https://github.com/e-government-ua/i/milestones/Support_DevOps-Server-Jenkins": "#_support_devop-srv-si",
"https://github.com/e-government-ua/i/milestones/Organization_Git-BugTracking-Rules": "#_org_git-btrack-rules",
@budnik
budnik / bootstrap.sh
Last active September 28, 2017 00:37
DO dokku
#!/bin/bash
TOKEN=foo
ES_NAME=bar
EXPOSED_IP=$(ip -o -f inet addr show eth0|egrep '([0-9]{1,3}\.){3}[0-9]{1,3}' -o|head -n1)
export ELASTICSEARCH_IMAGE_VERSION="1.7.1"
# Protect ES with Firewall
sed -i '/DEFAULT_FORWARD_POLICY/s/DROP/ACCEPT/g' /etc/default/ufw
IPS_ALLOW=/var/tmp/ufw-dynamic-ips.allow
ufw allow http
@budnik
budnik / .bashrc
Created January 16, 2015 09:34
windows bashrc for cmder
alias subl="/c/Program\ Files/Sublime\ Text\ 3/sublime_text.exe"
if [[ ! -z $SSH_AGENT_PID ]] && `kill -0 $SSH_AGENT_PID` && [[ -f $SSH_AUTH_SOCK ]]
then
echo -e "\e[33m ☀ SSH agent already set up!"
else
eval `ssh-agent.exe`
ssh-add ~/.ssh/id_rsa
ssh-add ~/.ssh/*/id_rsa
conemuc //EXPORT SSH_AUTH_SOCK SSH_AGENT_PID
fi
--binary ruby-2.1.3 --trace
rvm 1.26.0 (master) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
+ 1415279224.732325211 /scripts/cli : __rvm_parse_args() 788 > [[ -z install ]]
+ 1415279224.738244234 /scripts/cli : __rvm_parse_args() 791 > [[ error == \i\n\s\t\a\l\l ]]
+ 1415279224.743916314 /scripts/cli : __rvm_parse_args() 791 > [[ 0 -eq 1 ]]
+ 1415279224.749590414 /scripts/cli : __rvm_parse_args() 791 > [[ -n '' ]]
+ 1415279224.755691794 /scripts/cli : __rvm_parse_args() 83 > [[ -n '' ]]
+ 1415279224.761267058 /scripts/cli : __rvm_parse_args() 796 > : rvm_ruby_args:0::
+ 1415279224.766911800 /scripts/cli : __rvm_parse_args() 798 > [[ -n '' ]]
+ 1415279224.776260353 /scripts/cli : rvm() 824 > result=0
curl -XPUT localhost:9200/_cluster/settings -d '{
persistent: {
index.routing.allocation.exclude.tag: "hdd"
}
}'