Skip to content

Instantly share code, notes, and snippets.

View olih's full-sized avatar

Olivier Huin olih

View GitHub Profile
@olih
olih / scala-cheatsheet.md
Created December 8, 2016 15:32
Scala cheatsheet

Scala

Convert Seq To Map

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

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 November 30, 2016 10:28
R programming cheatsheet

Installation

On linux

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

On Mac OS

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 December 21, 2023 10:10
Awk and Sed cheetsheet

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
@olih
olih / jq-cheetsheet.md
Last active November 4, 2024 05:44
jq Cheet Sheet

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 August 29, 2015 14:28
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 August 29, 2015 14:23
A few basic tools to install by default
#!/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 June 23, 2015 10:57
Curl with custom CA certificates

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: