Skip to content

Instantly share code, notes, and snippets.

View zoellner's full-sized avatar
🤓
coding

Andreas Zoellner zoellner

🤓
coding
View GitHub Profile
@zoellner
zoellner / cognito_oidc_thumbprint.js
Last active April 25, 2024 10:09
node.js script to obtain the thumbprint for a Cognito User Pool to use as OpenID Connect Identity Provider
const openssl = require('openssl-wrapper');
const axios = require('axios');
const config = {
region: 'us-east-1',
userPoolId: 'your-user-pool-id'
};
getThumbprint()
.then(console.log)
@zoellner
zoellner / utf16test.js
Created May 28, 2020 20:37
write utf-16 encoded files in node.js (both utf16be and utf16le)
const fs = require('fs');
// our demo string is in 'default' utf8 with emoji character assuming you are using an editor that supports those.
// if not, you can test this gist by setting utf8string to the equivalent '->\ud83d\ude03\ud83e\uddd2\ud83c\udffc\u00fc\u010d\u0113<-'
// gist doesn't support all ZWJ sequences, so can't show this here but it works with those as well, e.g. '\ud83d\udc68\ud83c\udffc\u200d\ud83d\udcbb'
const utf8string = '->😃🧒🏼üčē<-';
// this is what you'd usually do to write to a utf-8 encoded file
fs.writeFileSync('test-utf8.txt', utf8string);
@zoellner
zoellner / .bash_profile
Last active January 13, 2019 20:44 — forked from natelandau/.bash_profile
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@zoellner
zoellner / docker-build-private-github.md
Last active December 13, 2023 22:25
Extract Github token for Docker build with private repo

Note: There are better ways to do this by now. Check https://docs.docker.com/develop/develop-images/build_enhancements/#new-docker-build-secret-information for details

In order to access packages in private github repositories a Dockerfile might contain statements like this:

RUN git config --global url."https://${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
RUN npm install --ignore-scripts --quiet && npm cache clean --force
RUN git config --global --unset url."https://${GITHUB_TOKEN}@github.com/".insteadOf
@zoellner
zoellner / index.js
Last active November 8, 2017 19:01
mongoose-bug-set-pre-save-hook-with-select
'use strict';
//see https://github.com/Automattic/mongoose/issues/5800
const mongoose = require('mongoose');
const assert = require('assert');
mongoose.Promise = global.Promise;
mongoose.connect('mongodb://localhost/mongoose-gh-5800');
@zoellner
zoellner / deleteTaskDefinition.js
Last active February 19, 2019 19:48
Delete AWS ECS Task Definition for Task Family
'use strict';
const AWS = require('aws-sdk');
const _h = require('highland');
const ecs = new AWS.ECS({region: process.env.AWS_REGION || 'us-east-1'});
let familyPrefix = null;
if (process.argv.length >= 3){
@zoellner
zoellner / mixpanelDeletePeople.js
Created June 3, 2016 23:19
Delete people profiles from mixpanel based on distinct ids in csv file
'use strict';
//Delete people profiles from mixpanel based on distinct ids in people.csv (id in first column)
//provide mixpanel token in environment variable MIXPANEL_TOKEN. change people.csv to your filename
//see https://mixpanel.com/help/reference/http for mixpanel API documentation
var request = require('request');
var _h = require('highland');
_h(_h.wrapCallback(require('fs').readFile)('./people.csv')) //change filename here
.split()
@zoellner
zoellner / Javascript ISO country code to country name conversion
Last active June 30, 2020 19:09 — forked from maephisto/Javascript ISO country code to country name conversion
Javascript ISO 3166-1 alpha-2 country code to ISO 3166-1 alpha-3 country code conversion
var isoCode3 = {
AF: 'AFG',
AX: 'ALA',
DZ: 'DZA',
AL: 'ALB',
AS: 'ASM',
AD: 'AND',
AO: 'AGO',
AI: 'AIA',
AQ: 'ATA',
# Modified from: http://stackoverflow.com/a/11010158/215200
$fromFolder = "D:\FOLDER\"
$rootName = "FILENAME"
$ext = "EXT"
$numFiles = 16
$from = "{0}{1}.{2}" -f ($fromFolder, $rootName, $ext)
$fromFile = [io.file]::OpenRead($from)
@zoellner
zoellner / ebextensions_nginx_loggly.config
Created March 29, 2014 06:30
Configure AWS Elastic Beanstalk syslog to poll nginx logs (in order to send them to loggly)
#
# configure rsyslogd to include logfiles from nginx/apache
# needs 010_loggly.config
# Save this file as .ebextensions/015_nginx-loggly.config
# replace TOKEN
# Deploy per normal scripts or aws.push. To help debug the push, ssh & tail /var/log/cfn-init.log
# See Also /var/log/eb-tools.log
#
files: