Skip to content

Instantly share code, notes, and snippets.

View memoryonrepeat's full-sized avatar
🏝️

Thanh Nguyen memoryonrepeat

🏝️
View GitHub Profile
@memoryonrepeat
memoryonrepeat / dynamodb-pull
Last active September 12, 2022 20:58
Exporting a DynamoDB table to a .json file
#!/bin/bash
# Dependencies: dynamo-archive
# In case there is some big tables, it is advisable to dedicate a process for each big table
# and another process for the rest, since this can work in parallel
# Can use https://github.com/bchew/dynamodump which is faster and easier
key=<AWS access key>
secret=<AWS secret>
region=<AWS region>
@memoryonrepeat
memoryonrepeat / dynamodb-query
Last active August 29, 2015 14:23
Query an item using any property using scan()
# Querying using query() is only allowed for primary and indexed keys. This work around allows querying using any field.
aws dynamodb scan --table-name <TABLE> --filter-expression "fieldname = :c" --expression-attribute-values file://expression-attribute-values.json > <OUTPUT>.json
@memoryonrepeat
memoryonrepeat / dynamodb-remove
Last active August 29, 2015 14:23
Update an item
# Remove the property from the item
aws dynamodb update-item --table-name <TABLE_NAME> --key file://key.json --update-expression "REMOVE #X" --expression-attribute-names file://expression-attribute-names.json --return-values ALL_NEW
@memoryonrepeat
memoryonrepeat / _terminal
Last active July 22, 2016 07:52
Commands and hotkeys
# List all process whose name contains some string
ps aux | grep <string>
# List all process listening to a particular port
lsof -i :<port number>
# List all running processes
ps -A
# Killall process that match a specific name
@memoryonrepeat
memoryonrepeat / redis
Last active November 26, 2015 08:46
Redis tips & tricks
# Connect to remote redis server
# Note: If server is hosted on EC2, it's isolated inside VPC and doesn't have ICMP available.
# Therefore, either do the command from inside EC2 or setup SSH tunnel to run from local
redis-cli -h <server IP address> -p <port> [command]
# Install Redis properly on server (rmb to change daemon to 'yes' in redis.conf)
# If failed, do it manually according to this guide http://redis.io/topics/quickstart
sudo ./utils/install-server.sh
# Start redis server as a daemon (need to install using the above method first)
@memoryonrepeat
memoryonrepeat / ssh
Last active August 29, 2015 14:24
SSH tips & tricks
# ssh tunneling through a remote server
# local port forwarding
# -f is for ssh to go to background
# -N is to not execute a command on remote host
ssh -L <local port>:<destination host>:<destination port> <remote username>@<remote host> -f -N
# then either go to http://localhost:<local port> or in case using DBs like Redis
# Example: ssh -L 3001:google.com:80 [email protected] will forward all http://localhost:3001 through server.com to google.com:80
# Example: ssh -L 3001:redishost.com:6379 [email protected]
# then
@memoryonrepeat
memoryonrepeat / refactoring
Created July 31, 2015 17:17
Refactoring experience
General philosophy:
- Unit test -> Prune (to reduce complexity) -> Test -> Redesign -> Test -> Redecorate -> Test -> New feature -> Test
@memoryonrepeat
memoryonrepeat / git.md
Last active August 30, 2016 07:20
Git tips and tricks

###Compare single file between versions and pipe the diff to a new file for better view: git diff branch1..branch2 -- filename &gt; difffile

@memoryonrepeat
memoryonrepeat / linux.txt
Created October 6, 2015 09:39
Experience using linux
Create a ~/.profile to let any kind of shell inherit from it
When executing a command, do note what kind of shell it's executing on top of.