Skip to content

Instantly share code, notes, and snippets.

View elnygren's full-sized avatar

el3ng elnygren

  • Helsinki, Finland
View GitHub Profile
@elnygren
elnygren / iterm-opener.applescript
Last active October 2, 2017 11:33
Open new iTerm tabs with specific commands using AppleScript. Helpful when you want to automatise opening bigger projects.
-----------------------------------------------------
-- iterm-opener by @elnygren
-- This script runs each command in COMMANDS in a new iTerm2 tab.
-- Useful for opening projects that require several windows.
-- Usage:
-- GUI
-- 1. Open this file with Script Editor
@elnygren
elnygren / consistent.py
Created March 8, 2018 14:23
Consistent code
# 1: SQL + PubSub (Postgres + RabbitMQ)
def controller(request):
# assume validation of data here
user = db.User.create(request.data)
while True:
success = RabbitMQ.queue(user.email)
if success:
@elnygren
elnygren / lunch.sh
Last active April 12, 2018 08:16
The Helsinki Lunch Machine
# just run this in your terminal
python -c 'import random;print(random.choice(["Sushibar+Wine","Friends & Burgers","Nasty Burger","Harju Döner City","Pikku-Nepal","Primero","Hotel Marski","Teatteri","Tortilla House","6k Food Market, Kamppi","Hoku Kamppi","Fuku","Domo","Koto","Bastardo","Beijing8","Sandro","New Bamboo Center","Bar 9","Pjazza","Hesburger","Burger King","Eerikin Pippuri","Rulla","Samrat","Skiffer","Trocadero","Fafas","Tamarin","Thai Orchid Kamppi","Kung Fu Kitchen","Levant","Ravintola Bröd","Kantipur","The Red Koi Thai","Pizzarium","Shanghai Cowboy","Hanko Sushi","some chinese restaurant","Luckiefuns","Roslund","Fat Ramen","Sumo",]))'
@elnygren
elnygren / README.md
Last active April 26, 2018 14:43
React Native x CodePush (prod, staging)

Goal

(replace "Brand" with your app's name)

App             | BuildType / config  | CodePush     
----------------------------------------------------
Brand           | Debug               | <none>
Brand           | Release             | Production
Brand Beta | Debug | 
@elnygren
elnygren / iso_datetime.py
Last active March 8, 2019 02:39
ISO 8601 with timezone (2018-05-01T10:48:30+00:00) support for Django
from django import forms
from django.utils.dateparse import parse_datetime
from django.utils.encoding import force_str
from django.forms.widgets import DateTimeInput
from django.utils.translation import gettext_lazy as _, ngettext_lazy
class ISODateTimeField(forms.Field):
"""DateTimeField that uses django.utils.dateparse.parse_datetime.
@elnygren
elnygren / utils.py
Created May 1, 2018 18:32
Python "good enough error handling"
#
# ErrorMonad and its fmap, bind and m_pipe
# inspired by
# http://www.slideshare.net/eldariof/monads-in-python
#
ErrorMonad = namedtuple('ErrorMonad', ['error', 'value'])
def fmap(func):
@elnygren
elnygren / slackpost.sh
Last active March 28, 2022 00:25
Post to Slack webhook with curl & jq
#!/usr/bin/env bash
# CONFIG
URL="https://hooks.slack.com/services/..."
PAYLOAD='{
"channel": "#test",
"username": "Ghost",
"text": "no-message",
"icon_emoji": ":ghost:"
}'
@elnygren
elnygren / README.md
Last active May 9, 2018 07:31
Join Sumpli, a startup helping people find work (React Native or backend).

Sumpli (https://sumpli.com/) is modernising the way we work. We allow people to find full-time, part-time jobs or on-demand shifts and streamline work contracts & salary payments.

You may have noticed us in the Finnish news:

We are building a mobile platform (iOS & android) with React Native and GraphQL. Our backend is based on various technologies such as Django, PostgreSQL, Node.js, Docker and Google Cloud.

@elnygren
elnygren / 01 - PROBLEM.md
Last active May 22, 2018 14:56
Interview questions

Problem description:

Sumpli has two services: sumpli-core and sumpli-graphql. sumpli-core is a JWKS provider in order to allow sumpli-graphql to directly validate JWT tokens given by sumpli-core.

When running sumpli-core and sumpli-graphql with replica: 1 (in Kubernetes), everything is working perfectly. However, when we increased replicas of both services to >1, eg. replica: 2 we started having problems with authentication; requests with a valid JWT token from sumpli-core we're still rejected as unauthorised by sumpli-graphql.

What went wrong?

@elnygren
elnygren / index.html
Created June 19, 2018 11:30
Frontend of the Future
<html>
<head>...</head>
<body>
<div>foo some template here></div>
{% for meme in memes %}...render meme...{% endfor %}
<div id="react-sidebar-app"/>
<footer id="react-footer-app"/>
</body>
<script>
React.render(<Foo/>, document.getElementById('react-sidebar-app'));