This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### REPLACE \n WITH LITERAL '\n' | |
sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g' | |
### SEARCH AND PRINT REGEX MATCH | |
echo ... | sed -n -e "s/^.*arn:aws:iam::\(.*\):user.*/\1/p" | |
### PRINT SEQUENCE | |
seq -f "10.235.5.%g" 117 126 | |
### SEARCH AND REPLACE IN FILES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Kill process and all its children | |
kill -- -$(ps -o pgid= $PID | grep -o '[0-9]*') (signal TERM) | |
kill -9 -$(ps -o pgid= $PID | grep -o '[0-9]*') (signal KILL) | |
### FIND TOP MEMORY USERS | |
ps aux | awk '{print $2, $4, $11}' | sort -k2rn | head -n 10 | |
### SSH menu | |
~C |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ "keys": ["ctrl+x"], "command": "cut" }, | |
{ "keys": ["ctrl+c"], "command": "copy" }, | |
{ "keys": ["ctrl+v"], "command": "paste" }, | |
{ "keys": ["ctrl+shift+v"], "command": "paste_and_indent" }, | |
{ "keys": ["ctrl+s"], "command": "save" }, | |
{ "keys": ["ctrl+z"], "command": "undo" }, | |
{ "keys": ["ctrl+shift+z"], "command": "redo" }, | |
{ "keys": ["ctrl+y"], "command": "redo_or_repeat" }, | |
{ "keys": ["ctrl+u"], "command": "soft_undo" }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### berks ignore ssl | |
$ cat ~/.berkshelf/config.json | |
{ | |
"ssl": { | |
"verify": false | |
} | |
} | |
### berks Faraday SSL error | |
export SSL_CERT_FILE=/etc/openssl/cert.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# tcpdump -i eth0 -A -s65535 port 8080 | |
intecepts all packets goving over port 8080 on eth0 network interface. | |
-s means size of each packet. so it dumps first 65k of the packet. default is much short and will truncate long http responses. | |
-A means show packets as ascii on screen | |
-w filename | |
for non plain text protocol (e.g. LDAP), write to file and use wireshark. | |
https://danielmiessler.com/study/tcpdump/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### USING DBM MAP | |
RewriteEngine On | |
RewriteMap some_map dbm=sdbm:/var/www/some_map.map | |
RewriteCond %{QUERY_STRING} some[iI]d=(\d+) | |
RewriteCond ${some_map:%1} !="" | |
RewriteRule ^/some/thing/view\.asp$ /some/thing/else/${some_map:%1}? [P] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### knife.rb: | |
knife[:vault_mode] = "client" | |
data_bag_path "/Users/hnguyen/data_bags" | |
### Creating a Vault | |
Vault creation is very similar to data bag creation. Specify a Vault name, and Item name inside of that vault as well as the default JSON data to go into the vault. You can optionally specify a node search, and/or a list of Chef Server users who should have access to the vault. | |
knife vault create [vault] [item] '{}' | |
knife vault create [vault] [item] '{}' -S 'search' -A 'user1,user2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### SIZE OF S3 BUCKET | |
aws s3api list-objects --bucket BUCKETNAME --output json --query "[sum(Contents[].Size), length(Contents[])]” | |
### BUCKET POLICY FOR ENCRYPTED BUCKET | |
{ | |
"Version": "2012-10-17", | |
"Id": "PutObjPolicy", | |
"Statement": [ | |
{ | |
"Sid": "DenyUnEncryptedObjectUploads", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<jmeterTestPlan version="1.2" properties="2.9" jmeter="3.0 r1743807"> | |
<hashTree> | |
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="cic-proxy-latency-test" enabled="true"> | |
<stringProp name="TestPlan.comments"></stringProp> | |
<boolProp name="TestPlan.functional_mode">false</boolProp> | |
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp> | |
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true"> | |
<collectionProp name="Arguments.arguments"/> | |
</elementProp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create strong LUKS key | |
openssl genrsa -out /root/luks.key 4096 | |
chmod 400 /root/luks.key | |
# Fill random data to the device | |
shred -v --iterations=1 /dev/xvdb | |
# Format device | |
echo "YES" | cryptsetup luksFormat /dev/xvdb --key-file /root/luks.key |
OlderNewer