View 00_destructuring.md

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors

View config
# ~/aws/config
[profile main-account-with-no-resources]
aws_access_key_id=...
aws_secret_access_key=...
[profile sub-account-with-resources]
region = eu-west-1
role_arn=arn:aws:iam::<account number for sub-account-with-resources>:role/dashsoft-iam
source_profile=dashsoftiam
View call-rest-service-on-caller-machine.sh
#!/bin/bash
foo=$(pstree -c -p -s $$ | awk -Fsshd '{print $3}' | cut -f2 -d '(' | tr -d ')' | tr -d '-')
caller=$(who -u | grep $foo | cut -f2 -d '(' | tr -d ')')
# a few other ways to get the IP
TTy=$(ps -eo pid,tty|grep $$|awk '{print $2}')
WhoAmI=$(who -u |grep -e "$TTy")
TheIp=$(echo $WhoAmI | awk '{print $7}' | sed 's/[()]//g'
View jenkins-start-compile-service.sh
AMI="ami-xxxxxxxx"
aws ec2 describe-instances --region eu-central-1 --output table --filter Name=image-id,Values=$AMI
aws ec2 run-instances --image-id $AMI --count 1 --instance-type t2.medium --key-name xxxxxx --security-group-ids sg-xxxxxxxx --subnet-id subnet-xxxxxxxx --iam-instance-profile Name=CIWindows --region eu-central-1 --output table
aws ec2 wait instance-exists --region eu-central-1 --output json --filter Name=image-id,Values=$AMI
instance=$(aws ec2 describe-instances --region eu-central-1 --output text --filter Name=image-id,Values=$AMI --query 'Reservations[*].Instances[*].[InstanceId]')
View probem001.mli
(* Ocaml *)
let rec range ?(start=0) len =
if start >= len
then []
else start :: (range len ~start:(start+1))
List.fold_left (+) 0 (List.map (fun x -> if 0 = x mod 3 or 0 = x mod 5 then x else 0) (range 1000))
List.fold_left (+) 0 (List.filter (fun x -> 0 = x mod 3 or 0 = x mod 5) (range 1000))
View git shortcuts
# get changes on current branch
alias u="git diff --name-status develop.."
# current branch
git branch | awk '/\*/ { print $2; }'
View forum.py
import boto3, hashlib, json, datetime, time, sys, getopt, threading, logging
import botocore
from boto3.dynamodb.conditions import Key, Attr
logging.getLogger('botocore').setLevel(logging.CRITICAL)
logging.getLogger('boto3').setLevel(logging.CRITICAL)
logging.basicConfig(filename='forum.log',level=logging.INFO, format="%(threadName)s:%(message)s")
class APIerror(Exception):
pass
View README
virtualenv -p $(which python3) venv
source venv/bin/activate
(venv)[klang@ergates workers]$ python -i tester_run.py
>>>
View docker_with_oracle.md

export RDSHELPER=the_ip_address_of_the_t2.micro_to_be_used

install docker

ssh -i ~/.ssh/e2ckey.pem ec2-user@$RDSHELPER
sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -a -G docker ec2-user
exit
View output.txt
[klang@ergates bin]$ split_destination-test.sh
destination user@host.with.full.domain:/full/path/to/install/package.ext
server host.with.full.domain
servershort host
user user
fullpath /full/path/to/install/package.ext
path /full/path/to/install/
package package.ext