Skip to content

Instantly share code, notes, and snippets.

View hencrice's full-sized avatar
🏠
Working from home

Yenlin Chen hencrice

🏠
Working from home
View GitHub Profile
@hencrice
hencrice / Bottlerocket updog check update
Created January 25, 2021 01:26
Bottlerocket updog pr 1282
bash-5.0# updog check-update --log-level debug
01:20:12 [DEBUG] (1) bottlerocket_release: Found os-release value NAME=Bottlerocket
01:20:12 [DEBUG] (1) bottlerocket_release: Found os-release value ID=bottlerocket
01:20:12 [DEBUG] (1) bottlerocket_release: Found os-release value PRETTY_NAME=Bottlerocket OS 1.0.6
01:20:12 [DEBUG] (1) bottlerocket_release: Found os-release value VARIANT_ID=aws-k8s-1.17
01:20:12 [DEBUG] (1) bottlerocket_release: Found os-release value VERSION_ID=1.0.6
01:20:12 [DEBUG] (1) bottlerocket_release: Found os-release value BUILD_ID=74c69ec1-dirty
01:20:12 [DEBUG] (2) webpki_roots: webpki-roots-shim activated, 138 certificates
01:20:12 [DEBUG] (2) webpki_roots: certificate source: /etc/pki/tls/certs/ca-bundle.crt
01:20:12 [DEBUG] (2) reqwest::connect: starting new connection: https://updates.bottlerocket.aws/
@hencrice
hencrice / dmesg output
Created January 25, 2021 01:13
Bottlerocket dmesg output for pr 1282
[ 0.000000] Linux version 5.4.80 (builder@buildkitsandbox) (gcc version 9.3.0 (Buildroot 2020.02.2)) #1 SMP Sun Jan 24 18:58:55 UTC 2021
[ 0.000000] Command line: BOOT_IMAGE=(hd0,gpt2)/vmlinuz root=/dev/dm-0 rootwait ro console=tty0 console=ttyS0 random.trust_cpu=on selinux=1 enforcing=1 systemd.log_target=journal-or-kmsg systemd.log_color=0 net.ifnames=0 biosdevname=0 dm_verity.max_bios=-1 dm_verity.dev_wait=1 "dm-mod.create=root,,,ro,0 1884160 verity 1 PARTUUID=18ae72ac-fb60-49c6-bd89-26cca1448684/PARTNROFF=1 PARTUUID=18ae72ac-fb60-49c6-bd89-26cca1448684/PARTNROFF=2 4096 4096 235520 1 sha256 491c398a43780d31ba2ed15d98a290fefe7825d5c22f8fc8167fe64acd58b49f 05d7756cd6a54e331ecee914cb6010ebcc2e6677ccc5f95d356222ced5070123 1 restart_on_corruption"
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
[ 0.000000] x86/fpu:
@hencrice
hencrice / schema_common.yml
Created January 19, 2020 22:44
Cloudformation template schema
---
AWSTemplateFormatVersion: "version date"
Description:
String
Parameters:
set of parameters
Conditions:
@hencrice
hencrice / a_few_resources.yml
Created January 19, 2020 05:44
Create the following resources: 1) an on-demand DynamoDB table with a local secondary index 2) an S3 bucket with a lifecycle policy to clean up after itself 3) an SQS queue with AWS CloudWatch alarms on queue depth
AWSTemplateFormatVersion: 2010-09-09
Description: >-
Create the following resources:
1) an on-demand DynamoDB table with a local secondary index
2) an S3 bucket with a lifecycle policy to clean up after itself
3) an SQS queue with AWS CloudWatch alarms on queue depth
Parameters:
AutoCleanupPrefix:
Description: >-
@hencrice
hencrice / s3CleanUpAfterItself.yml
Last active December 15, 2019 06:26
A Cloudformation template that creates an S3 bucket with a lifecycle policy
AWSTemplateFormatVersion: "2010-09-09"
Description: >-
This template deploys an S3 bucket with a lifecycle policy to clean up after itself.
Parameters:
AutoCleanupPrefix:
Description: >-
All object with this prefix will be deleted automatically by S3.
Type: String
RetentionDays:
@hencrice
hencrice / ede02aa07eb6.csv
Last active September 15, 2019 02:21
Everything related to mut, let and &
Syntax Is valid syntax? Attempted destructuring? Can modify v through b? Is v moved? Can v be borrowed again (after 'rebind' b)? Can 'rebind' b?
let b = v Yes No No Yes No No
let &b = &v Yes Yes N/A N/A N/A N/A
let &mut b = v Yes Yes N/A N/A N/A N/A
let &mut b = &mut v Yes Yes N/A N/A N/A N/A
let b = mut v No N/A N/A N/A N/A N/A
let b = &mut v Yes No Yes No No* No
let mut b = v Yes No No Yes No Yes
let mut b = &v Yes No No No Yes Yes
let mut b = &mut v Yes No Yes No Yes Yes
@hencrice
hencrice / pass_mut_vector_by_ref.rs
Created September 14, 2019 00:01
Pass a mutable vector by reference into a function
fn main() {
let s = String::from("123");
let mut stack = Vec::with_capacity(s.len());
pop_and_compare(&mut stack, '1');
}
fn pop_and_compare(stack: &mut Vec<char>, closing: char) -> bool {
match stack.pop() {
None => false,
Some(s) => s == closing,
@hencrice
hencrice / iterate_over_vec_of_iterators.rs
Created September 13, 2019 07:03
Iterate over a vector of iterators until one of it returns None
pub fn loop_over_vec_of_iterators(strs: Vec<String>) {
// create list of iterators for each word in strs, then loop over each and call next() once.
// Since we would like to modify individual iterators by calling its `next()`, we need to
// delcare this vector as mutable.
let mut iterators_vec: Vec<std::str::Chars> = strs.iter().map(|x| x.chars()).collect();
while let Some(it) = iterators_vec.get_mut(index) {
match it.next() {
Some(c) => {
// do something
@hencrice
hencrice / pattern_matching_char.rs
Created September 12, 2019 04:33
Rust: Pattern Matching on char
// pattern matching on char
fn single_roman_to_abs(c: char) -> i32 {
match c {
'I' => 1,
'V' => 5,
'X' => 10,
'L' => 50,
'C' => 100,
'D' => 500,
'M' => 1000,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.