Skip to content

Instantly share code, notes, and snippets.

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ssm:DescribeAssociation",
"ssm:GetDeployablePatchSnapshotForInstance",
"ssm:GetDocument",
"ssm:GetManifest",
amazon-ebs output will be in this color.
==> amazon-ebs: Prevalidating AMI Name: ubuntu-18.04-root-encryption-2018-09-29T14-40-02Z
amazon-ebs: Found Image ID: ami-0ac019f4fcb7cb7e6
==> amazon-ebs: Creating temporary keypair: packer_5baf8ec2-f229-8c17-afd9-76b501a75f67
==> amazon-ebs: Creating temporary security group for this instance: packer_5baf8ec5-e1ba-73cb-8dca-dfec2c8ccfc2
==> amazon-ebs: Authorizing access to port 22 from 0.0.0.0/0 in the temporary security group...
==> amazon-ebs: Launching a source AWS instance...
==> amazon-ebs: Adding tags to source instance
amazon-ebs: Adding tag: "Name": "Packer Builder"
{
"variables": {
"ami-name": "ubuntu-18.04-{{ isotime }}"
},
"builders": [
{
"type": "amazon-ebs",
"ami_name": "{{ user `ami-name` | clean_ami_name }}",
"region": "us-east-1",
"source_ami_filter": {
{
"variables": [
],
"builders":[
],
"provisioners":[
],
wget -O packer.zip https://releases.hashicorp.com/packer/1.3.1/packer_1.3.1_linux_amd64.zip
sudo unzip -d /usr/local/bin packer.zip
#include <memory>
#include <cstdio>
/////////////////////////////////////////////////////////////////////////////
typedef std::unique_ptr<std::FILE, int (*)(std::FILE *)> unique_file_ptr;
typedef std::shared_ptr<std::FILE> shared_file_ptr;
static shared_file_ptr make_shared_file(const char * filename, const char * flags)
{
@david7482
david7482 / mp4v2_reader.c
Created September 22, 2015 12:30
MP4V2 library test
#include <stdio.h>
#include "mp4.h"
char *mp4FileName = "\\Storage Card\\TestVectors\\Downloaded\\[Ani]Conan-01.mp4";
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
@david7482
david7482 / get_base_file_name_compile_time.cpp
Created July 22, 2015 18:27
Get base file name at compile time
// Extract base file name at compile time. E.g., "bar.cc" when __FILE__ == "/foo/bar.cc"
static constexpr const char* BASE_FILE(const char* dp, const char* p) {
return *p == '\0' ? dp : *p == '/' ? BASE_FILE(p + 1, p + 1) : BASE_FILE(dp, p + 1);
}
static constexpr const char* BASE_FILE(const char* s) { return BASE_FILE(s,s); }
@david7482
david7482 / test_hash_func.cpp
Created July 17, 2015 17:16
Simple program to test hash function
/* Nick Mudge 24 February 2008 */
// http://nickmudge.info/?post=84
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#define SIZE 50000
void make_random_strings(unsigned char *strings[]);
@david7482
david7482 / C++11_string_swtich.cpp
Last active December 14, 2023 21:09
Use C++11's constexpr to achieve string switch
// http://stackoverflow.com/a/107657
constexpr unsigned long long int HashStringToInt(const char *str, unsigned long long int hash = 0)
{
return (*str == 0) ? hash : 101 * HashStringToInt(str + 1) + *str;
}
void simple_switch(const std::string &str)
{
switch (HashStringToInt(str.c_str()))
{