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
# --------------------------------------------------------------------------------------------------- | |
terraform { | |
required_providers { | |
aws = { | |
source = "hashicorp/aws" | |
version = ">= 3.31.0" | |
} | |
kubernetes = { | |
source = "hashicorp/kubernetes" |
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
# As an exercise after reading this tweet: https://twitter.com/Al_Grigor/status/1357028887209902088?s=20 | |
str = String.split("aaaabbbcca", "", trim: true) | |
str | |
|> Enum.reduce([], fn | |
x, [{x, count} | rest] -> | |
[{x, count + 1} | rest] | |
x, acc -> |
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
defmodule Timestamp do | |
@moduledoc """ | |
Generate a timestamp as an integer using current time. | |
""" | |
@spec make() :: integer() | |
def make() do | |
%{year: y, month: m, day: d, hour: hh, minute: mm, second: ss, microsecond: {us, _}} = | |
NaiveDateTime.utc_now() |
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
CONFORMANCE TEST BEGIN ==================================== | |
ERROR, test=Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_0: Should have failed to parse, but didn't. request=protobuf_payload: "\001DEADBEEF" requested_output_format: PROTOBUF message_type: "protobuf_test_messages.proto3.TestAllTypesProto3" test_category: BINARY_TEST, response=protobuf_payload: "" | |
ERROR, test=Required.Proto2.ProtobufInput.IllegalZeroFieldNum_Case_0: Should have failed to parse, but didn't. request=protobuf_payload: "\001DEADBEEF" requested_output_format: PROTOBUF message_type: "protobuf_test_messages.proto2.TestAllTypesProto2" test_category: BINARY_TEST, response=protobuf_payload: "" | |
ERROR, test=Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_1: Should have failed to parse, but didn't. request=protobuf_payload: "\002\001\001" requested_output_format: PROTOBUF message_type: "protobuf_test_messages.proto3.TestAllTypesProto3" test_category: BINARY_TEST, response=protobuf_payload: "" | |
ERROR, test=Required.Proto2.Protobuf |
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
# install aws cli first and configure it with credentials and default region | |
# the script will iterate over all regions of AWS | |
#! /bin/sh | |
for region in `aws ec2 describe-regions --output text | cut -f4` | |
do | |
echo -e "\nListing Instances in region:'$region'..." | |
# aws ec2 describe-instances --query "Reservations[*].Instances[*].{IP:PublicIpAddress,ID:InstanceId,Type:InstanceType,State:State.Name,Name:Tags[0].Value}" --output=table --region $region |
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
// clang++ -std=c++17 -Wall -Wextra pointer_member.cc | |
#include <iostream> | |
struct foo | |
{ | |
int a; | |
int b; | |
}; |
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
// clang++ -I. -std=c++17 -Wall -Wextra yocto_merge_manifest_licenses.cc | |
#include <fstream> | |
#include <iostream> | |
#include <regex> | |
#include <set> | |
#include <string> | |
#include <tuple> | |
#include <boost/algorithm/string/replace.hpp> |
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 <climits> | |
#include <cmath> | |
#include <fstream> | |
#include <iostream> | |
#include <limits> | |
#include <utility> | |
#include <vector> | |
// IEEE 754 does not specify endianess (https://en.wikipedia.org/wiki/Endianness#Floating_point). | |
// So, to have a portable representation, we can "decompose" the floating-point value using frexp(). |
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
// When compiled (macOS, 64 bits) with g++-8 -O3 -std=c++14 ub.cc -Wall -Wextra: | |
// 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 | |
// 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | |
// Notice the '1' coming from nowhere :-) | |
// Note that clang++ produces: | |
// 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | |
// 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | |
#include <cstdint> |
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 <functional> | |
#include <iostream> | |
#include <string> | |
#include <variant> | |
template <typename... Ts> | |
struct make_visitor | |
: Ts... | |
{ | |
using Ts::operator()...; |
NewerOlder