Skip to content

Instantly share code, notes, and snippets.

Riccardo Tacconi rtacconi

Block or report user

Report or block rtacconi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View binary_search.rb
def binary_search(list, item)
low = 0
high = list.size - 1
return nil if list.last < item # item not in array
while low < high do
mid = (low + high) / 2
guess = list[mid]
@rtacconi
rtacconi / flatten.rb
Created Aug 7, 2016
Flatten an array without using the Ruby library
View flatten.rb
def flatten(in_array, out_array = [])
in_array.each do |a|
if a.class == Array
flatten(a, out_array)
else
out_array << a
end
end
out_array
@rtacconi
rtacconi / README.md
Created Jul 26, 2016 — forked from fnichol/README.md
Auto-enable Local HTTP Caching in Test Kitchen
View README.md

Auto-enable Local HTTP Caching in Test Kitchen

Note: total experiment and hack, looks nasty, could be awesome:

Setup

  • Drop the kitchen.local.yml into $HOME/.kitchen/config.yml
  • Install polipo (with Mac: brew install polipo, with Ubuntu: apt-get install polipo)
  • Drop polipo-start and polipo-console somewhere useful (perhaps $HOME/bin?)
@rtacconi
rtacconi / install-chef-12-6-0-amazon-linux
Last active Apr 4, 2019
Install chef server 12.6.0 on Amazon Linux
View install-chef-12-6-0-amazon-linux
echo "127.0.0.1 AWSVC009 AWSVC009" >> /etc/hosts
yum update -y
wget https://packages.chef.io/stable/el/5/chef-server-core-12.6.0-1.el5.x86_64.rpm
rpm -Uvh chef-server-core-12.6.0-1.el5.x86_64.rpm
chef-server-ctl reconfigure
mkdir /home/ec2-user/cookbooks
chown ec2-user /home/ec2-user/cookbooks
mkdir /home/ec2-user/.chef
chown ec2-user /home/ec2-user/.chef
View unzip-l-working-zip-aws-lambda
Archive: build/distributions/aws-lambda-jruby/Archive.zip
Length Date Time Name
-------- ---- ---- ----
980 04-06-16 12:28 A.class
1613 04-06-16 12:28 AWSLambdaJRuby.class
962 04-06-16 12:28 AWSLambdaJRuby0.class
1159 04-06-16 12:28 AWSLambdaJRuby1.class
1618 04-06-16 12:28 AWSLambdaJRuby2.class
1618 04-06-16 12:28 AWSLambdaJRuby3.class
0 04-06-16 12:29 lib/
@rtacconi
rtacconi / gradle_jar_aws_lambda.txt
Created Apr 5, 2016
Gradle build of JRuby and AWS lambda
View gradle_jar_aws_lambda.txt
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"
@rtacconi
rtacconi / aws_l-missing_gem.txt
Created Apr 5, 2016
AWS lambda Jruby error missing gem
View aws_l-missing_gem.txt
{
"errorMessage": "(LoadError) no such file to load -- aws-sdk",
"errorType": "org.jruby.embed.EvalFailedException",
"stackTrace": [
"org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:131)",
"org.jruby.embed.ScriptingContainer.runUnit(ScriptingContainer.java:1311)",
"org.jruby.embed.ScriptingContainer.runScriptlet(ScriptingContainer.java:1356)",
"AWSLambdaJRuby.handler(AWSLambdaJRuby.java:35)",
"sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)",
"sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)",
@rtacconi
rtacconi / build.gradle
Created Apr 5, 2016
gradle aws lambda jruby build
View build.gradle
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"
View gist:ef31bb4844aa6d13e599
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
View install_chef_sdk.sh
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
You can’t perform that action at this time.