Skip to content

Instantly share code, notes, and snippets.

View Visya's full-sized avatar

Maria Verbenko Visya

View GitHub Profile
@Visya
Visya / docker.MD
Created December 8, 2020 08:47
Running bash inside a short-running stopped Docker container

Running bash on a short-running stopped Docker container

If your Docker container is running a short command and you want to look inside it, sometimes it's really hard to do it, since docker exec doesn't run on stopped containers. What you can do is copy a container and run it with bash entrypoint.

docker ps -a -f "name=my-container"
docker commit my_container_id user/my-container
docker run -it --entrypoint bash user/my-container
@Visya
Visya / index.MD
Created November 4, 2020 11:55
Implementing message versioning for SNS/SQS pattern

Versioning in SNS messages

Message versioning can be required in SNS+SQS patternto allow setting up specific consumers that can process newer versions and make version transitions smooth and painless.

To achieve that you can use the native AWS SNS filtering mechanism. It allows to set version message attribute on a message sent to SNS and filter which queues receive which versions of messages.

Example of versioned message

@Visya
Visya / glue-etl.png
Last active September 22, 2021 11:15
DynamoDB to S3 export as part of data pipeline
glue-etl.png
@Visya
Visya / garbage.js
Created November 12, 2019 12:25
A garbage function that builds the filter query based on req.query and what user has access to
async function getFilter(req) {
const hasWildcardPermission = get(req, ['hasAccessTo', 'wildcard'], false);
const networkIds = hasWildcardPermission ? null : get(req, ['hasAccessTo', 'networkId'], null);
const { showIds: filterShowIds } = req.query;
let showIds = null;
if (hasWildcardPermission) {
// if has access to everything, narrow networks to the shows from query
if (filterShowIds.length) {
const filteredNetworks = await getNetworksForShows(filterShowIds);

Retrieving permissions in client apps

Current model of permissions allows to grant a permission based on network id or show id, but some of the apps know how to work only with show ids. Also, we allow for wildcards, for example, this permission allows to view show in any app:

// *:read:show:showId
{
  app: '*',
  resource: 'show',
 action: 'read',
@Visya
Visya / 1-function.js
Last active June 3, 2019 19:58
What is printed?
var name = 'Cat';
function Animal(name) {
this.name = name;
this.printName = function() {
console.log(this.name);
};
}
//const classFunctionCalled = Animal('Anything?');
@Visya
Visya / mongo
Created May 29, 2019 07:35
Permissions
// Permission
[
{
__t: 'Permission',
id: 123,
definition: 'manage:insights',
params: ['showId']
},
{
__t: 'Permission',
@Visya
Visya / semantic-release.md
Last active February 15, 2019 12:30
Semantic release config
npm i -D -E husky@latest &&
npm i -D -E @commitlint/{cli,config-conventional} &&
npm i -D -E commitizen cz-conventional-changelog &&
npm i -D -E @semantic-release/{commit-analyzer,git,npm,release-notes-generator} semantic-release semantic-release-docker

package.json

  "private": true,
@Visya
Visya / .zshrc
Last active June 19, 2019 09:37
AWS MFA authentication refresher
export MFA_ARN=YOUR_MFA_ARN
alias refreshtoken="AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY AWS_SESSION_TOKEN= ~/tools/aws-auth.sh"
source /tmp/aws-temp-creds.sh || echo "No AWS credentials found"
if ! aws iam get-user &> /dev/null; then
refreshtoken
source /tmp/aws-temp-creds.sh
fi
@Visya
Visya / flutter.md
Created October 7, 2018 13:33
Useful Flutter resources