Skip to content

Instantly share code, notes, and snippets.

View Kotauror's full-sized avatar
🌞

Justyna Jurkowska (Zygmunt) Kotauror

🌞
  • London (UK) / Kraków (PL)
  • 00:20 (UTC +02:00)
View GitHub Profile
@Kotauror
Kotauror / closure.md
Last active April 15, 2020 10:09
Closure in Javascript

Closure in JavaScript

With every fancy framework and even fancier plugin to it, JavaScript is getting easier to use - more things happening behing the scenes, less difficult algorithms and procedures to write by hand. However, every now and then in the troublefree world of frameworks and libraries one might encounter an unexpected problem and then the JavaScript rules will creep out of the shadows and there will be no other other option but to finally face them.

In this entry, I'll go back to JavaScript basics to explain one of the fundamental concepts - a closure. I'll start with explaining the documention on very simple examples and then I'll move on to two more practical use cases.

Cracking the documentation code

Let's start talking about the closure from looking at the definition from documentation:

@Kotauror
Kotauror / jsharder.md
Last active May 18, 2020 10:40
JavaScript the harder parts.
@Kotauror
Kotauror / docker-connect.md
Created May 29, 2019 08:54
connecting to docker in EC2
  1. Connect to the ec2 instance: eb ssh name-of-instance --profile name-of-profile (as in the .ssh file)
  2. docker ps - to list the dockers
  3. take a name of docker container
  4. docker exec -it name-of-container /bin/bash
  5. cd craft/storage/logs.
@Kotauror
Kotauror / typescript-interfaces.md
Last active May 20, 2019 15:48
Typescript interfaces

When and how to use interfaces in typescript. TL;DR - to prepare tymplates for objects.

Simple function, not many parameters - interface not needed:

let drawPoint = (x, y) => {
  console.log("kotek")
}
@Kotauror
Kotauror / fixErlangBuilds.md
Last active May 8, 2019 12:27
Fix Erlang builds

This note explains how I've solved a problem with building Erlang 21.0.

I used to use evm for managing versions of Erlang. After I've installed Erlang 21.0, I've tried to run mix and this gave me the following error: ** (MatchError) no match of right hand side value: {:error, {:crypto, {'no such file or directory', 'crypto.app'}}}.

I've then decided to use kerl instead of evm because of bigger online support. However, kerl gave me errors when I was trying to build Erlang 21.0 (kerl build 21.0 21.0).

The core of the problem with building Erlang 21.0 was hardcoding the version 20.0 of Erlang into my $PATH. I used to have this:

@Kotauror
Kotauror / aws.tf
Created October 31, 2018 13:21
aws.tf
variable "AWS_ACCESS_KEY" {}
variable "AWS_SECRET_KEY" {}
provider "aws" {
region = "us-east-1"
access_key = "${var.AWS_ACCESS_KEY}"
secret_key = "${var.AWS_SECRET_KEY}"
}
resource "aws_key_pair" "justyna-key" {
@Kotauror
Kotauror / manage.py
Created October 29, 2018 15:31
manage.py
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from app import app, db
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
@Kotauror
Kotauror / models.py
Created October 29, 2018 15:24
models.py
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class Contact(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True)
def __init__(self, name):
@Kotauror
Kotauror / psql1.py
Last active October 29, 2018 15:06
psql1.py
from flask import Flask
import time
import os
from models import db
from flask_sqlalchemy import SQLAlchemy
from models import Contact
app = Flask(__name__)
POSTGRES = {
@Kotauror
Kotauror / start.sh
Last active October 24, 2018 15:27
start.sh
cd /var/www/html/
nohup sudo flask run --port=80 --host=0.0.0.0 > /dev/null 2>&1 &