Skip to content

Instantly share code, notes, and snippets.

@nicokruger
nicokruger / fix-slow-oh-my-zsh-big-git-repos.sh
Created October 6, 2020 10:36
Fix slow oh my zsh in large git repos
git config --add oh-my-zsh.hide-status 1
git config --add oh-my-zsh.hide-dirty 1
list databases: \l *;
non-binary way:
export PGPASSWORD=whatever
for F in $(cat dbs); do echo $F; psql -h dt-rds-test.coivvuccn9hs.eu-west-1.rds.amazonaws.com -v -U postgres -d ${F} < ${F}.sql ; done
binary way:
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/PostgreSQL.Procedural.Importing.html
# above way doesnt seem to work with roles etc.
umount /mnt/c; sudo mount -t drvfs C: /mnt/c -o metadata
@nicokruger
nicokruger / ports.ps1
Created July 19, 2020 12:22
Open WSL ports to windows host
$remoteport = bash.exe -c "ifconfig eth0 | grep 'inet '"
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
if( $found ){
$remoteport = $matches[0];
} else{
echo "The Script Exited, the ip address of WSL 2 cannot be found";
exit;
}
@nicokruger
nicokruger / lambdapricing.js
Created April 27, 2020 10:08
Work out approximate cost per lambda across region over time period using Cloudwatch Log Insights
const aws = require('aws-sdk');
aws.config.region = 'eu-west-1';
const cloudwatchlogs = new aws.CloudWatchLogs();
const moment = require('moment');
const fs = require('fs');
const filename = `results-${new Date().getTime()}.csv`;
fs.appendFileSync(filename, ['logGroup','dollars','rcnt','numberdollars','total'].join(",") + "\n");
const endTime = moment().toDate().getTime();
@nicokruger
nicokruger / getAllS3Objects.js
Created March 13, 2020 11:00
getAllS3Objects
async function getAllS3Objects(Params) {
let listing = true;
const objects = [];
while (listing) {
const data = await s3.listObjects(Params).promise();
if (!data.isTruncated) {
listing = false;
} else {
Params.Marker = data.NextMarker;
}
class Chezzers(sfn.IStepFunctionsTask):
def __init__(self, app, id, **kwargs):
super().__init__(app, **kwargs)
def bind(task):
print("called it!")
@nicokruger
nicokruger / go-away.sh
Created October 22, 2012 09:08
Turn of super annoying system bell
xset b off
xset b 0 0 0
@nicokruger
nicokruger / test.sh
Created October 5, 2012 17:10
Test gist
echo "Hello"
@nicokruger
nicokruger / netcat.sh
Created October 1, 2012 15:33
netcat example
for F in $(seq 1); do echo "Doing $F"; bash -c 'sleep 1; echo -e "login:a:a;\r\ncommand;\r\nlogout;\r\n"' | netcat localhost 8094; done