- Terraform
- provider vs provisioner
- Load balancing
- Network Load Balancer vs Application Load Balancer
- Networking
- Layer 1 vs Layer 4
- haproxy uses which layer?
- Database
- Mysql
- myisamchk
- what does it do?
- Open source databases: MySQL, Postgres, Mongodb
Friday, 4 December 2020
Interview questions: 2020-12
Tuesday, 9 June 2020
iftop config
~/.iftoprc
interface: eth0 # The interface to monitor log-scale: no # Use a logarithmic scale for bar graphs. max-bandwidth: 2M # Fixes the maximum for the bar graph scale to bw, e.g. "10M". In bits dns-resolution: yes # Controls reverse lookup of IP addresses. port-display: on # Controls display of port numbers. port-resolution: yes # Controls conversion of port numbers to service names.
Monday, 25 May 2020
Sunday, 24 May 2020
k8s ssl cert loading as secret
kubectl --cert=/tmp/tls.crt --key=/tmp/tls.key create secret tls tls-wc-ingress
Thursday, 17 October 2019
Tuesday, 12 February 2019
Connection with Jedis to passworded, "in-transit" encrypted AWS Elasticache Redis instance
import redis.clients.jedis.Jedis;
public class RedisStringJava {
public static void main(String[] args) {
Jedis jedis = new Jedis("master.redis-poc-single-01.eeeeee.use1.cache.amazonaws.com", 6379, true);
jedis.auth("mypassword");
System.out.println("Connection to server sucessfully");
jedis.set("tutorial-name", "Redis tutorialz");
// Get the stored data and print it
System.out.println("Stored string in redis:: "+ jedis.get("tutorial-name"));
}
}
Wednesday, 6 February 2019
Monday, 4 February 2019
venv
brew install python3
mkdir -p ~/bin/python3
python3 -m venv ~/bin/python3
source ~/bin/python3/bin/activate
enjoy!
mkdir -p ~/bin/python3
python3 -m venv ~/bin/python3
source ~/bin/python3/bin/activate
enjoy!
Wednesday, 23 January 2019
common git
- git grep ‘pattern’: search the repo for a string
- git commit --amend: rewrite the last commit message (must do this before pushing otherwise you’re push will be rejected)
- git rebase -i master: does an interactive rebase on your local master branch. handy for cleaning up your branch before opening a merge request. this is how i squash commits and rewrite commit messages
- git rebase -i HEAD^^: does an interactive rebase with just the last two commits. I use this if i want to combine the two most recent commits together
- git diff <branch> — <path/to/file> : diffs between current branch and another branch, but only the file (or files) you specify
- git checkout <branch> — <path/to/file>: replaces (or adds) a version of a file from another branch. handy for reverting
- git commit -m ‘message’: quickly commit with a commit message
- git commit -C HEAD: commit with the same exact commit message as the last commit.
- git commit --amend: rewrite the last commit message (must do this before pushing otherwise you’re push will be rejected)
- git rebase -i master: does an interactive rebase on your local master branch. handy for cleaning up your branch before opening a merge request. this is how i squash commits and rewrite commit messages
- git rebase -i HEAD^^: does an interactive rebase with just the last two commits. I use this if i want to combine the two most recent commits together
- git diff <branch> — <path/to/file> : diffs between current branch and another branch, but only the file (or files) you specify
- git checkout <branch> — <path/to/file>: replaces (or adds) a version of a file from another branch. handy for reverting
- git commit -m ‘message’: quickly commit with a commit message
- git commit -C HEAD: commit with the same exact commit message as the last commit.
Tuesday, 18 December 2018
Quickly ssh into repeatly new Linux instances with same IP without host key check
WARNING: this is extremely dangerous on networks not completely TRUSTED
Host 10.10.* *.mycompany.org User myuser IdentityFile /home/myuser/.ssh/my_ssh_key StrictHostKeyChecking no UserKnownHostsFile=/dev/null
Monday, 26 November 2018
Total n00b’s guide to Big O, Big Ω, & Big θ
Crazy brillant!
https://medium.com/@.RT/total-n00bs-guide-to-big-o-big-%CF%89-big-%CE%B8-aa259ae8a1c2
Total n00b’s guide to Big O, Big Ω, & Big θ
https://medium.com/@.RT/total-n00bs-guide-to-big-o-big-%CF%89-big-%CE%B8-aa259ae8a1c2
Total n00b’s guide to Big O, Big Ω, & Big θ
Tuesday, 11 September 2018
tcpdump -nnXSs
Taken: https://www.askbjoernhansen.com/2007/07/12/how_to_dump_packets_with_tcpdump.html
I always forget the parameters for this and have to look them up in the man page, so enough of that:
tcpdump -nnXSs 0 port 80
I always forget the parameters for this and have to look them up in the man page, so enough of that:
tcpdump -nnXSs 0 port 80
- "-nn" makes it not lookup hostnames in DNS and service names (in /etc/services) for respectively faster and cleaner output.
- "-X" makes it print each packet in hex and ascii; that's really the useful bit for tracking headers and such
- "-S" print absolute rather than relative TCP sequence numbers - If I remember right this is so you can compare tcpdump outputs from multiple users doing this at once
- "-s 0" by default tcpdump will only capture the beginning of each packet, using 0 here will make it capture the full packets. We are debugging, right?
Sunday, 9 September 2018
Monday, 27 August 2018
perl cli regex
perl -pe 's/^(.+)\/([^\s]+)\-([v0-9.]+)\-*([Final|GA|M2|rc|beta|R5]*).jar$/$2\t$3\t$4/'
Saturday, 23 June 2018
key git book pages to read
- https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging
- https://git-scm.com/book/en/v2/Git-Branching-Branching-Workflows
Sunday, 10 June 2018
packer: virtualbox
Prep
ex001.json
- Vagrant
- vagrant init hashicorp/precise64
- vagrant up
- vagrant destroy -f
Generate
- Packer
- find ~/.vagrant.d/ -name '*ovf' -ls | grep hashi
- create ex001.json
- see below
- fix "source_path" to ovf file to match your system
- packer validate ex001.json
- packer build ex001.json
- vagrant box add my-box-001 packer_virtualbox-ovf_virtualbox.box --force
Test
- mkdir test001
- cd test001
- vagrant init
- in generated "Vagrantfile", change 1st line to 2nd line
- config.vm.box = "base"
- config.vm.box = "my-box-001"
- vagrant up
- vagrant ssh
- cat /var/tmp/welcome.txt
- should say, "welcome001"
- vagrant destroy -f
Cleanup
- vagrant box remove my-box-001 --force
- vagrant box remove hashicorp/precise64 --force
ex001.json
{
"builders": [{
"type": "virtualbox-ovf",
"source_path": "<path to your home dir>/.vagrant.d//boxes/hashicorp-VAGRANTSLASH-precise64/1.1.0/virtualbox/box.ovf",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"shutdown_command": "echo 'packer' | sudo -S shutdown -P now"
}],
"provisioners": [
{
"type": "shell",
"inline":[ "echo welcome001 > /var/tmp/welcome.txt" ]
}
],
"post-processors": ["vagrant"]
}
"builders": [{
"type": "virtualbox-ovf",
"source_path": "<path to your home dir>/.vagrant.d//boxes/hashicorp-VAGRANTSLASH-precise64/1.1.0/virtualbox/box.ovf",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"shutdown_command": "echo 'packer' | sudo -S shutdown -P now"
}],
"provisioners": [
{
"type": "shell",
"inline":[ "echo welcome001 > /var/tmp/welcome.txt" ]
}
],
"post-processors": ["vagrant"]
}
Monday, 16 April 2018
end is nigh: serverless
"For a small company focused on rapid growth, the last thing we wanted to deal with was disk space and memory management, logging agents, security patches, operating system updates, and other traditional server management processes."
Thursday, 12 April 2018
recursive
def recursive_countdown(x):
print('Countdown: ' + str(x))
if x == 1:
return 1
else:
return recursive_countdown(x - 1)
recursive_countdown(5)
def recursive_fib(x):
#print('Fib: ' + str(x))
if x in [0, 1]:
return x
else:
return (recursive_fib(x - 1) + recursive_fib(x -2 ))
# this algo can be easily improved if answers are indexed
print(recursive_fib(5))
print(recursive_fib(6))
print(recursive_fib(7))
print(recursive_fib(8))
print('Countdown: ' + str(x))
if x == 1:
return 1
else:
return recursive_countdown(x - 1)
recursive_countdown(5)
def recursive_fib(x):
#print('Fib: ' + str(x))
if x in [0, 1]:
return x
else:
return (recursive_fib(x - 1) + recursive_fib(x -2 ))
# this algo can be easily improved if answers are indexed
print(recursive_fib(5))
print(recursive_fib(6))
print(recursive_fib(7))
print(recursive_fib(8))
Wednesday, 11 April 2018
Python: sort by value then key
No idea yet how this works, or why.
>>> d = {'apple': 7, 'banana': 3, 'almond': 7, 'peach': 4, 'beetroot': 3}
>>> sorted(d.iteritems(), key=lambda(k, v): (-v, k))
[('almond', 7), ('apple', 7), ('peach', 4), ('banana', 3), ('beetroot', 3)]
Thursday, 5 April 2018
Basic Ansible in 10 mins
- "site.yml" file
- playbook containing
- "roles" that will be applied to individual host groups / "hosts"
- how the hosts will be accessed
- and by what user to run as
- Puppet equivalent is "nodes.pp"
- "hosts" file
- use real/local DNS hostname to define which hosts are in which hostgroups
- example: webserver1, webserver2, haproxy1, haproxy2, mongo1, mongo2
- some variables like "port" can be added too
- "group-vars" directory
- key/value pairs to use when generating output from template files
- files named identically to hostgroup names defined in "hosts" file
- these are more in-line in Puppet, and less controllable/flexible
- "roles" directory
- Puppet equivalents are "modules"/"classes"
- directories arbitrarily named to match "roles" in site.yml
- e.g. "tomcat", "common", "mongod"
- "templates" directory
- files with variables that are resolved using "group-vars" key/values
- moved on to target systems using task keyword "template"
- same name is used in Puppet
- "files"
- raw files to be moved into place on the target filesystems
- used by tasks with keyword "file"
- same name used in Puppet
- "handlers"
- "main.yml"
- control system services on target systems
- "service" keyword
- "state", e.g. "restarted"
- in Puppet, these are not broken out from other "resources"
- "tasks"
- this is the core list of actions to perform on target systems
- Puppet equivalents are "includes"/"classes", maybe "modules" as well
- "main.yml"
- collection of tasks
- uses yml structure
- "name" is arbitrary reference for developers
- ansible keyword to perform some action on the system
- ansible keywords: "file", "template", "command"
- puppet equivalents are called "resources"
- conditionals/dependencies: "when", "notify", "wait_for"
Subscribe to:
Posts (Atom)
Interview questions: 2020-12
Terraform provider vs provisioner Load balancing Network Load Balancer vs Application Load Balancer Networking Layer 1 vs Layer 4 haproxy u...
-
CRITICAL: AWS now offers internal VPC DNS! Below is no longer necessary AFAIK. Woo hoo! http://aws.amazon.com/about-aws/whats-new/2014/...
-
build sudo apt-get install git gcc sudo apt-get install automake autoconf git clone git://github.com/rriley/tsunami-udp.git cd tsunam...
-
From: https://bugs.eclipse.org/bugs/show_bug.cgi?id=382972#c4 Assumptions: jEdit was installed into /Applications directory. Close any...