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 Struct do | |
defstruct [:a, :b, :c, :d, :e, :f, :g, :h] | |
end | |
defmodule CreateStruct do | |
def create1() do | |
struct(Struct, create1_fields()) | |
end |
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
// Convert 4 unsigned big endian bytes to int | |
int x = java.nio.ByteBuffer.wrap(bytes).getInt(); |
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 <iomanip> | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <openssl/hmac.h> | |
int main() | |
{ | |
// https://tools.ietf.org/html/rfc2104#section-3 |
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
// g++-8 -std=c++17 -Wall -Wextra -fsanitize=address c++17.cc | |
#include <array> | |
#include <cstddef> | |
#include <iostream> | |
#include <set> | |
#include <sstream> | |
#include <string> | |
#include <string_view> | |
#include <tuple> |
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()...; |
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 <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
// 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
// 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
# 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 |