Skip to content

Instantly share code, notes, and snippets.

@alexjeen
alexjeen / eventbridge.tf
Created June 27, 2023 16:10
Using the EventBridge modules multiple times
variable "env_level" {
description = "Environment level"
default = "dev"
}
module "eventbridge_price" {
source = "terraform-aws-modules/eventbridge/aws"
create_bus = false
create_connections = true
create_api_destinations = true
@alexjeen
alexjeen / ecs.tf
Last active July 18, 2023 21:03
Autoscaling ECS cluster (Terraform)
variable "prefix" {
type = string
}
variable "vpc_id" {
type = string
}
variable "private_subnets" {
type = list(string)
@alexjeen
alexjeen / gist:4d7b88fdcf7e8850b00110ecb9146a04
Created January 6, 2022 12:17
Build and run a AMD64 container on a ARM macbook (slow due to emulation!)
docker buildx build . --platform linux/amd64 --tag testcontainer
docker run --platform linux/amd64 -it testcontainer bash
@alexjeen
alexjeen / logz.config
Created July 15, 2020 13:53
logz.io ElasticBeanstalk configuration (send ElasticBeanstalk logs to Logz.io)
files:
"/etc/filebeat/filebeat.yml":
mode: "000755"
owner: root
group: root
content: |
filebeat.inputs:
- type: log
enabled: true
paths:
@alexjeen
alexjeen / lambda.js
Last active July 19, 2019 19:19
Sync ECS task account with EC2 instances in AutoscalingGroup (AWS)
exports.handler = async (event, context, callback) => {
console.log('Starting the process');
var AWS = require('aws-sdk');
// set the service names
var ecsClusterName = "clustername";
var ecsServiceName = "servicename";
var autoScalingGroupName = "autoscalinggroupname";
@alexjeen
alexjeen / mongodb-drop.js
Last active June 16, 2018 09:41
Drops all collections from a MongoDB database
db.getCollectionNames().forEach( function(collection_name) {
if (collection_name.indexOf("system.") == -1)
db[collection_name].drop();
else
db.collection_name.remove({});
});
<?xml version="1.0"?>
<columns code="100" optimize="true">
<column id="1">
<field>fin.trs.head.yearperiod</field>
<label>Periode</label>
<visible>true</visible>
<ask>true</ask>
<operator>between</operator>
<from></from>
<to></to>
@alexjeen
alexjeen / RawConnection.php
Created December 30, 2016 21:21
Exact Online API XML read + write
<?php
namespace app\exact;
use GuzzleHttp\Client;
class RawConnection extends \Picqer\Financials\Exact\Connection
{
/**
* Gets XML for an division.
@alexjeen
alexjeen / array_csv.php
Last active April 2, 2016 15:06
Array to CSV PHP
function _array_to_csv_download($array, $filename = "export.csv", $delimiter=",") {
// open raw memory as file so no temp files needed, you might run out of memory though
$f = fopen('php://memory', 'w');
// loop over the input array
foreach ($array as $line) {
// generate csv lines from the inner arrays
fputcsv($f, $line, $delimiter);
}
// reset the file pointer to the start of the file
fseek($f, 0);
@alexjeen
alexjeen / 0_reuse_code.js
Created March 9, 2016 17:43
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console