Skip to content

Instantly share code, notes, and snippets.

View rtacconi's full-sized avatar

Riccardo Tacconi rtacconi

View GitHub Profile
@rtacconi
rtacconi / gist:2d90655ad55324d697ab9f1907b70c5b
Last active February 7, 2017 17:14
AWS CLI list instances name with public IP
aws ec2 describe-instances \
--query 'Reservations[*].Instances[*].[Tags[?Key==`Name`].Value|[0],PublicIpAddress]' \
--output table --region us-east-1
@rtacconi
rtacconi / rsyslog.conf
Created January 31, 2017 22:48
rsyslog.conf configured to send logs to a local ping, change the IP with the IP of your machine
# rsyslog configuration file
# For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
# If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html
#### MODULES ####
# The imjournal module bellow is now used as a message source instead of imuxsock.
$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
$ModLoad imjournal # provides access to the systemd journal
@rtacconi
rtacconi / run_chef_client_kitchen.sh
Last active February 6, 2017 19:20
Run chef-client in Test Kitchen. It installs Chef Zero and it uploads everything to it.
#!/bin/bash
cd /tmp/kitchen
/opt/chef/embedded/bin/gem install chef-zero
/opt/chef/embedded/bin/chef-zero -d
knife upload / -c client.rb
chef-client -j dna.json -c client.rb
@rtacconi
rtacconi / binary_search.rb
Last active August 7, 2016 19:57
Binary search
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 August 7, 2016 18:36
Flatten an array without using the Ruby library
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 July 26, 2016 10:26 — forked from fnichol/README.md
Auto-enable Local HTTP Caching in Test Kitchen

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 October 29, 2020 13:58
Install chef server 12.6.0 on 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
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 April 5, 2016 12:04
Gradle build of JRuby and AWS lambda
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 April 5, 2016 11:46
AWS lambda Jruby error missing gem
{
"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)",