Skip to content

Instantly share code, notes, and snippets.

Avatar

Olivier Huin olih

View GitHub Profile
View scala-cheatsheet.md

Scala

Convert Seq To Map

val map = seq.map(a => a.key -> a).toMap
@olih
olih / redis.md
Created Nov 25, 2016
Redis cheetsheet based on Official documentation
View redis.md

Redis Commands:

  • APPEND key value Append a value to a key
  • AUTH password Authenticate to the server
  • BGREWRITEAOF Asynchronously rewrite the append-only file
  • BGSAVE Asynchronously save the dataset to disk
  • BITCOUNT key start end Count set bits in a string
  • BITFIELD key GET type offset SET type offset value INCRBY type offset increment OVERFLOW WRAP|SAT|FAIL Perform arbitrary bitfield integer operations on strings
  • BITOP operation destkey key key ... Perform bitwise operations between strings
  • BITPOS key bit start end Find first bit set or clear in a string
@olih
olih / r-cheetsheet.md
Last active Nov 30, 2016
R programming cheatsheet
View r-cheetsheet.md

Installation

On linux

sudo yum install -y epel-release
sudo yum install R

On Mac OS

View ssl-cheatsheet.md

SSL cheetsheet

Encode file with password

alias enc='openssl enc -e -aes128 -base64 -pass "env:PASS"'

Decode file with password

alias dec='openssl enc -d -aes128 -base64 -pass "env:PASS"'
@olih
olih / awk-sed-cheetsheet.md
Last active Nov 1, 2016
Awk and Sed cheetsheet
View awk-sed-cheetsheet.md

awk & sed cheetsheet

Extract lines between start and end

between() { sed -n "/^$1/,/^$2/p" | sed '1d;$d'; }

Also:

awk '/^START=A$/,/^END$/ { print }’ data
View jq-cheetsheet.md

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@olih
olih / install-aws.sh
Last active Aug 29, 2015
install-aws.sh
View install-aws.sh
#AWS
# . install-aws.sh
instance_profile=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/`
aws_access_key_id=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep AccessKeyId | cut -d':' -f2 | sed 's/[^0-9A-Z]*//g'`
aws_secret_access_key=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep SecretAccessKey | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'`
aws_secret_access_key=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep SecretAccessKey | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'`
aws_session_token=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep Token | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'`
@olih
olih / install-basic.sh
Last active Aug 29, 2015
A few basic tools to install by default
View install-basic.sh
#!/bin/bash
sudo yum install -y epel-release
sudo yum install -y nano
sudo yum install -y git
#Install Amazon Client
curl -O http://peak.telecommunity.com/dist/ez_setup.py
sudo python ez_setup.py
#Install pip
sudo easy_install pip
@olih
olih / curl-ca.md
Created Jun 23, 2015
Curl with custom CA certificates
View curl-ca.md

Using curl with custom CA certificates

This document describes how to use curl with both custom and official CA SSL certificates.

Prerequisite

You would need first to install curl , see http://curl.haxx.se/docs/install.html. Using a package manager such as yum, brew, ... for your platform should be the easiest though.

Example for Mac OS: