This file contains hidden or 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
| cat ~/.tmux.conf | |
| # Enable mouse mode | |
| set -g mouse on | |
| # Create 2x2 grid layout on new sessions | |
| set-hook -g after-new-session { | |
| split-window -h | |
| split-window -v | |
| select-pane -t 0 | |
| split-window -v |
This file contains hidden or 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
| aws apigateway delete-base-path-mapping --domain-name domain.tld --base-path "(none)" | |
| # Reference: https://docs.aws.amazon.com/cli/latest/reference/apigateway/delete-base-path-mapping.html |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| import argparse | |
| import boto3 | |
| def get_account_id(): | |
| sts = boto3.client('sts') | |
| identity = sts.get_caller_identity() | |
| account_id = identity["Account"] | |
| return account_id |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| import argparse | |
| import boto3 | |
| def main(bucket_name): | |
| session = boto3.Session() | |
| s3 = session.resource(service_name='s3') | |
| bucket = s3.Bucket(bucket_name) | |
| bucket.object_versions.delete() |
This file contains hidden or 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
| /* | |
| Copy from: http://web.archive.org/web/20090617110918/http://www.openasthra.com/c-tidbits/printing-binary-trees-in-ascii/ | |
| Source: http://web.archive.org/web/20071224095835/http://www.openasthra.com:80/wp-content/uploads/2007/12/binary_trees1.c | |
| */ | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> |
This file contains hidden or 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
| bool luhn_check(const std::string& pan) { | |
| auto to_int = [](char c) { return c - 48; }; | |
| auto sum_digits = [](int n) { return n / 10 + n % 10; }; | |
| auto do_digits = [&sum_digits](auto&& values) { | |
| auto const& [index, digit] = values; | |
| return (index % 2 == 0) ? digit : sum_digits(digit * 2); | |
| }; | |
| auto rng = pan |
This file contains hidden or 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
| bool rtn_checksum(const std::string& routing_number) { | |
| std::vector<int> const multipliers{3, 7, 1, 3, 7, 1, 3, 7, 1}; | |
| auto to_int = [](char c) { return std::stoul(&c, nullptr, 10); }; | |
| auto const routing_digits = routing_number | views::transform(to_int); | |
| auto multiply = [](auto a, auto b) { return a * b; }; | |
| auto sum = | |
| accumulate(views::zip_with(multiply, routing_digits, multipliers), 0); |
This file contains hidden or 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
| "325081403" | |
| |> String.graphemes() # => ["3", "2", "5", "0", "8", "1", "4", "0", "3"] | |
| |> Stream.map(&String.to_integer/1) # => [3, 2, 5, 0, 8, 1, 4, 0, 3] | |
| |> Stream.zip([3, 7, 1, 3, 7, 1, 3, 7, 1]) # => [{3, 3}, {2, 7}, {5, 1}, {0, 3}, {8, 7}, {1, 1}, {4, 3}, {0, 7}, {3, 1}] | |
| |> Stream.map(fn {a, b} -> a * b end) # => [9, 14, 5, 0, 56, 1, 12, 0, 3] | |
| |> Enum.sum() # => 100 | |
| |> rem(10) == 0 # => true |
This file contains hidden or 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
| #include <iostream> | |
| #include <string> | |
| #include <termios.h> | |
| #include <unistd.h> | |
| int password_prompt(std::string &password) | |
| { | |
| struct termios tty; | |
| // Get current terminal settings |
This file contains hidden or 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
| // track2 decode | |
| std::string decoded = ""; | |
| uint8_t left = 0; | |
| uint8_t right = 0; | |
| for (uint8_t c : encoded) | |
| { | |
| left = c >> 4; | |
| right = c & 0b00001111; | |
| decoded.append(1, left + 0x30); | |
| decoded.append(1, right + 0x30); |
NewerOlder