Skip to content

Instantly share code, notes, and snippets.

View tappoz's full-sized avatar

Alessio Gottardo tappoz

View GitHub Profile
@tappoz
tappoz / ElixirSetup.md
Last active March 8, 2016 10:53
Setting up Elixir on a Debian/Ubuntu Linux distro

Check that you are using a trusty distro, on Ubuntu:

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 14.04.3 LTS
Release:	14.04
Codename:	trusty
@tappoz
tappoz / intel-edison-iot-linux.md
Last active January 23, 2024 23:07
Getting started with Intel Edison IoT board on a Linux Debian/Ubuntu environment

Make sure the following packages are installed

sudo apt-get install gdebi libncurses5:i386 libstdc++6:i386

Then install the Intel Phone Flash Tool Lite (cfr. their website), the key tool chain Intel provides to flash the Intel Edison board.

sudo gdebi phoneflashtoollite_5.2.4.0_linux_x86_64.deb 

Then you should be able to find the gui (graphical user interface) at /usr/bin/phoneflashtoollite and the cli (command line interface) at /usr/bin/phoneflashtoollitecli.

Find who's listening on TCP port 8081 (on Mac OSX / bash)

$ netstat -an | grep -E '\.8081.*LISTEN'
tcp4       0      0  127.0.0.1.8081        *.*                    LISTEN

$ cat /etc/services |grep 8081
sunproxyadmin   8081/tcp    # Sun Proxy Admin Service
sunproxyadmin   8081/udp    # Sun Proxy Admin Service

Java 8 UTC date-time to formatted string and viceversa

// YYYY-MM-DDTHH:mm:ssZ

// date ---> string
java.time.format.DateTimeFormatter.ISO_INSTANT.format(java.time.ZonedDateTime.now().truncatedTo(java.time.temporal.ChronoUnit.SECONDS))

// string ---> date
java.time.ZonedDateTime.parse('2016-07-18T13:26:45Z', java.time.format.DateTimeFormatter.ISO_INSTANT.withZone(java.time.ZoneOffset.UTC))

AWS SDK for python

To get temporary credentials from within an EC2 instance for a given IAM role iam_role:

import urllib2
import json

# Instance metadata docs:
# http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#instance-metadata-security-credentials
http_data = urllib2.urlopen('http://169.254.169.254/latest/meta-data/iam/security-credentials/'+iam_role)
@tappoz
tappoz / docker-vm-cheat-sheet.md
Last active August 29, 2019 15:28
Docker and Virtual Machine cheat sheet

Docker

Building

If you have a Dockerfile in your project, then go to that folder e.g. /path/to/my/project then type docker build -t CONTAINER_NAME . where CONTAINER_NAME is a name of your choice.

Starting

@tappoz
tappoz / db-cheatsheet.md
Last active December 9, 2016 17:17
cheatsheet for common tasks using Postgres or MySQL

Postgres

Command to display active connections to a PostgresDB: SELECT * FROM pg_stat_activity;

Connection to Redshift

$ psql -h <ENDPOINT_NAME>.us-east-1.redshift.amazonaws.com -p 5439 -d <DB_NAME> -U <DB_USERNAME>
@tappoz
tappoz / aws-commands-cheatsheet.md
Created December 9, 2016 17:41
AWS CLI cheatsheet

EC2

Generate ssh key

To be used for a user in an EC2 instance:

$ ssh-keygen -b 4096 -t rsa -f ~/.ssh/$(whoami)-<suffix-for-ec2-environment>
@tappoz
tappoz / Shell-tricks.md
Last active October 25, 2021 08:00
command line tricks

How to find and list all the symbolic links created for a particular file?

$ ls -li
# take note of the symlink ID
$ find / -follow -inum 5097642 2>/dev/null
# you'll have a list of symlink to that inode

Useful bash configuration

@tappoz
tappoz / ansible-install-docker-and-other-tricks.md
Last active November 23, 2017 13:41
Ansible playbook to install docker and other tricks

Docker stuff

This playbook works on Ubuntu and should work also on debian:

---
- name: Make sure docker is installed and configured
  hosts: my_hosts_group # cf. the hosts file below for this group of hosts
  sudo: yes
  tasks: