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
fn fib(x: u64) -> u64 { | |
if x > 1 { fib(x - 1) + fib(x - 2) } else { x } | |
} | |
fn main() { | |
println!("Result {}", fib(10)); // -> 55 | |
} |
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
{ | |
// Configure the daemon below: | |
"options": { | |
"host_identifier": "scw-xxxxxxx", | |
"config_plugin": "filesystem", | |
// Select the osquery logging plugin. | |
"logger_plugin": "aws_kinesis", | |
"enable_monitor": "true", | |
// Splay the scheduled interval for queries. |
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
require "openssl" | |
class Chef | |
class Recipe | |
def self.certificate_expired?(path) | |
OpenSSL::X509::Certificate.new(File.open(path, "rb").read).not_after <= Time.now | |
end | |
end | |
end |
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
REPORT=/tmp/ssh_acl.txt | |
for user in $(knife data bag show users) | |
do | |
knife data bag show users $user | grep -v ssh_keys | grep -v ssh-rsa | grep -v htpasswd | grep -v shell >> $REPORT | |
echo "---------------------" >> $REPORT | |
done |
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
aws ec2 describe-instances \ | |
--query 'Reservations[*].Instances[*].[Tags[?Key==`Name`].Value|[0],PublicIpAddress]' \ | |
--output table --region us-east-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
#!/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 |
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
# 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 |
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
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] | |
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 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 |