Skip to content

Instantly share code, notes, and snippets.

@kalinchernev
kalinchernev / collections.json
Created March 7, 2023 16:05
`npx @mocks-server/main mocks` on yarn install and run `mocks` as documented on mocks-server.org
[
{
"id": "get-result",
"routes": ["get-result:get-result-actual"]
}
]
@kalinchernev
kalinchernev / delete.mjs
Last active September 6, 2021 13:20
get and upload data to instagram
import Instagram from 'instagram-web-api';
(async () => {
const username = process.env.IG_USERNAME;
const password = process.env.IG_PASSWORD;
const client = new Instagram({ username, password });
await client.login();
const photos = await client.getPhotosByUsername({ username, first: 50 });
photos.user.edge_owner_to_timeline_media.edges.map(async edge => {
@kalinchernev
kalinchernev / nest.js
Last active September 2, 2020 19:58
nest objects by 2 props: id and parent
const nest = (items, parent = 0) => {
const nested = [];
Object.values(items).forEach(item => {
// parent can be a string or a number
/* eslint-disable-next-line eqeqeq */
if (item.parent == parent) {
const children = nest(items, item.id);
if (children.length) {

Visual mode

  • v: character
  • Shift + v: whole line
  • Ctrl + v: cursor, multiple lines

Navigation

  • h,j,k,l
  • f{c}: move to c character (useful for characters which would otherwise mess with / regex search: .,,,;,:, etc.)
#!/usr/bin/env node
const path = require('path');
const https = require('https');
const AWS = require('aws-sdk');
const promisePipe = require('promisepipe');
const unzip = require('unzipper');
const runner = async () => {
const runParams = {
taskDefinition: RUNNER,
launchType: "FARGATE",
networkConfiguration: {
awsvpcConfiguration: {
assignPublicIp: "ENABLED",
subnets: [SUBNET]
}
},
overrides: {
const runParams = {
taskDefinition: RUNNER,
launchType: "FARGATE",
networkConfiguration: {
awsvpcConfiguration: {
assignPublicIp: "ENABLED",
subnets: [SUBNET]
}
#!/usr/bin/env node
const path = require('path');
const https = require('https');
const AWS = require('aws-sdk');
const promisePipe = require('promisepipe');
const unzip = require('unzip');
const { argv } = require('yargs');
FROM node:8
# Environment variables acting as parameters of the runner.
ENV AWS_LAMBDA_FUNCTION_EVENT {}
ENV AWS_LAMBDA_FUNCTION_CONTEXT {}
# Create app directory
WORKDIR /usr/src/app
COPY . .
import AWS from 'aws-sdk';
export const handler = async (event, context, callback) => {
// Coming from environment variables setup in your `serverless.yaml` file
// See https://serverless.com/framework/docs/providers/aws/guide/variables/#referencing-environment-variables
const { RUNNER, SUBNET } = process.env;
const ecs = new AWS.ECS();
// Some other logic specific to your case here ...