This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'java' | |
apply plugin: 'eclipse' | |
apply plugin: 'idea' | |
buildscript { | |
repositories { jcenter() } | |
dependencies { | |
/* check jruby-gradle.org for the latest release */ | |
classpath "com.github.jruby-gradle:jruby-gradle-jar-plugin:1.0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apt-get -y update | |
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev | |
cd /tmp | |
wget http://ftp.ruby-lang.org/pub/ruby/2.3/ruby-2.3.0.tar.gz | |
tar -xvzf ruby-2.3.0.tar.gz | |
cd ruby-2.3.0/ | |
./configure --prefix=/usr/local | |
make | |
make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget https://opscode-omnibus-packages.s3.amazonaws.com/el/7/x86_64/chefdk-0.10.0-1.el7.x86_64.rpm | |
rpm -i chefdk-0.10.0-1.el7.x86_64.rpm | |
if [ ! -d /var/chef/cache/ ]; then mkdir -p /var/chef/cache/; fi | |
if [ ! -d /var/chef/cookbooks/ ]; then mkdir -p /var/chef/cookbooks/; fi | |
if [ ! -d /var/chef/checksums/ ]; then mkdir -p /var/chef/checksums/; fi | |
if [ ! -d /etc/chef ]; then mkdir -p /etc/chef; fi | |
if [ ! -d /var/chef/backup ]; then mkdir -p /var/chef/backup; fi | |
if [ ! -d /var/chef/environments ]; then mkdir -p /var/chef/environments; fi | |
if [ ! -f /var/chef/environments/production.rb ]; then mkdir -p /var/chef/environments/production.rb; fi | |
cat << EOF > /etc/chef/solo.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
yum install -y java | |
wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo | |
rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key | |
yum install -y jenkins | |
yum install -y git | |
service jenkins start/stop/restart | |
chkconfig jenkins on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def next_id(arr) | |
return 0 if arr && arr.size == 0 | |
return 1 if arr.inject(&:+) == 0 | |
arr = arr.uniq.sort | |
arr.each_with_index do |n, i| | |
return i unless n == i | |
end | |
arr.last + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# repository | |
cd /tmp | |
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm | |
rpm -Uvh epel-release-6-8.noarch.rpm | |
# system update | |
yum -y update | |
yum -y groupinstall "Development Tools" | |
yum -y install libxslt-devel libyaml-devel libxml2-devel gdbm-devel libffi-devel zlib-devel openssl-devel libyaml-devel readline-devel curl-devel openssl-devel pcre-devel git memcached-devel valgrind-devel mysql-devel ImageMagick-devel ImageMagick |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://codility.com/demo/results/demoJ2Q7MX-R8M/ | |
# 100% performance and correctness | |
def solution(a) | |
return 1 unless a && a.size > 0 | |
length = a.length + 1 | |
sum1 = 0 | |
sum2 = 0 | |
sum1 = a.inject(&:+) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Prelude> let factorial n = product [1..n] | |
Prelude> factorial 2 | |
2 | |
Prelude> factorial 3 | |
6 | |
Prelude> factorial 4 | |
24 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# using first order functions | |
def factorial(n) | |
(1..n).inject(:*) || 1 | |
end | |
factorial(4) | |
=> 24 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Initial solution, test passing, 0% scores: | |
(1..a.size-2).each {|i| p (a.slice(i,a.size).inject(:+) - a.slice(0, i).inject(:+)) }.min | |
I found this on internet, 100% scores, very long: | |
puts "tape_equilibrium: " | |
return 0 if a.empty? | |
# Example data: N=5, P(1-4), A[3,1,2,4,3] | |
# P1: |