Skip to content

Instantly share code, notes, and snippets.

View igorjs's full-sized avatar
🦝
Building Raccoon Lang

igor.js igorjs

🦝
Building Raccoon Lang
View GitHub Profile
export function safeThrow(
target: object,
key: string | symbol,
descriptor: TypedPropertyDescriptor<(req: Request, res: Response, next: NextFunction) => Promise<any>>) {
const fun = descriptor.value;
descriptor.value = async function () {
try {
await fun.apply(this, arguments);
} catch (err) {
arguments[2](err);
@igorjs
igorjs / toggleAutoScalingGroup.md
Created December 10, 2020 23:39 — forked from veuncent/toggleAutoScalingGroup.md
AWS Auto Scaling Groups: scheduled start/stop

Tutorial: scheduled start/stop of EC2 instances managed by Auto Scaling Groups

If your EC2 instances in AWS are managed through Auto Scaling Groups, it is easy to schedule startup and shutdown of those instances, e.g. to save money.

This tutorial walks you through setting up an AWS Lambda function that is triggered by CloudWatch Events and automatically changes the min, max and desired instances in your Auto Scaling Group(s).

The idea is to toggle between 0 (stop) and a specifed min, max and desired amount of instances (start), so you only need a single Lambda function. The premise is that you do not touch these Auto Scaling Group settings manually, or you might make your EC2 instances nocturnal.

Create new Lambda function and Start Event

@igorjs
igorjs / AngularJSApolloProvider.js
Last active January 4, 2021 04:17
AngularJS Apollo Provider
(function(appModule) {
"use strict";
var Apollo = function () {
function Apollo(client, $q) {
this.client = client;
this.$q = $q;
}
@igorjs
igorjs / README.md
Created November 25, 2020 06:50 — forked from sidorares/README.md
node.js conventions and best practices

Node.JS best practices and conventions

This is not about JS style

Advice: if you have style guide / policy, apply it automatically ( in the editor or git hook ) https://github.com/jshint/fixmyjs

Collection of (mostly) JS styles (pick one you like or write another one if none fits you)

// scraped from https://mariadb.com/kb/en/mariadb/documentation/sql-language-structure/mariadb-error-codes/
//
module.exports = [
[
"1000",
"HY000",
"ER_HASHCHK",
"hashchk"
],
[
@igorjs
igorjs / _readme.md
Created October 12, 2020 23:52 — forked from andywer/_readme.md
React - Functional error boundaries

React - Functional error boundaries

Thanks to React hooks you have now happily turned all your classes into functional components.

Wait, all your components? Not quite. There is one thing that can still only be implemented using classes: Error boundaries.

There is just no functional equivalent for componentDidCatch and deriveStateFromError yet.

Proposed solution

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@igorjs
igorjs / bitbucket-pipelines.yml
Created August 22, 2020 11:43 — forked from Gr1N/bitbucket-pipelines.yml
Why Drone CI can be interesting for you? Example of Bitbucket Pipelines configuration using YAML anchors and aliases
definitions:
caches:
poetry-path: /root/.poetry
poetry-venv: /root/.cache/pypoetry/virtualenvs
steps:
- step: &step-37
image: python:3.7
caches:
- poetry-path
interface IXOptions {
a?: string,
b?: any,
c?: number
}
const XDefaults: IXOptions = {
a: "default",
b: null,
c: 1