Skip to content

Instantly share code, notes, and snippets.

View valentinzberea's full-sized avatar

Valentin Zberea valentinzberea

View GitHub Profile
@babldev
babldev / Dockerfile
Last active March 6, 2024 16:37
Next.js + worker orchestration on Google Cloud example
# Alpine image is smaller but Prisma is broken on M1 https://github.com/prisma/prisma/issues/8478
# FROM node:18-alpine AS builder
# RUN apk update
# RUN apk add --no-cache openssl
FROM node:18-slim AS runner
RUN apt-get update \
&& apt-get install -y openssl
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
@babldev
babldev / README.md
Last active December 29, 2023 20:54
NextJS Background Task

NextJS Background Task Example

An example of how to add a background task (e.g. a queue consumer) to an existing NextJS project.

Setup

  • Add your background task file
  • Add a new worker-tsconfig.json, specifically specifying "module": "commonjs" and targeting only the worker source files.
  • Add convenience functions for building & running to package.json

Then to build once:

@malteneuss
malteneuss / Dockerfile
Created April 28, 2022 19:43
Nextjs + Prisma DB (query and migrations) in Docker
# Adapted from https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile
# Install dependencies only when needed
FROM node:16-alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
# Rebuild the source code only when needed
require "sqlite3"
require 'set'
require 'byebug'
# Will be rebuilt at any time. Nice and incremental.
db = SQLite3::Database.new "index.db"
# Keep prefix indexes for "mos*" searches.
#
# TODO: It doesn't seem like SQLITE FTS5 supports synonyms well. That's ok, but
# we're going to want that. We can download this database from Princeton, write
@Maecenas
Maecenas / Raymond Hettinger - Beyond PEP 8 -- Best practices for beautiful intelligible code - PyCon 2015.md
Last active March 11, 2024 05:49
Raymond Hettinger - Beyond PEP 8 -- Best practices for beautiful intelligible code - PyCon 2015. Distillation of knowledge gained from a decade of Python consulting, Python training, code reviews, and serving as a core developer. (https://www.youtube.com/watch?v=wf-BqAjZb8M) <br/> https://www.shawnxli.com/posts/beyond-pep-8/

Raymond Hettinger's professional at doing code review and architecture review

P vs. NP. Pythonic vs. Non-Pythonic.

How to make use of PEP 8

  1. Golden rule of PEP-8: PEP-8 onto yourself. PEP 8 is style guide, not a law book.
  2. Care about intelligibility, not simply visually better
  3. Transforming (Java) API to pythonic ones

Why not PEP 8

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real

@seancribbs
seancribbs / qcon-nyc-2017-resources.md
Last active July 29, 2017 16:49
Resources for my talk "Adopting Stream Processing for Instrumentation" at QCon New York 2017
@notwaldorf
notwaldorf / 👀.md
Last active February 18, 2024 21:13
Advice for new developers

Someone sent me an email asking me what advice I had for new developers. I get this question a bunch, so I wanted to put all my thoughts in one place, that I can update as I get more ideas!

I answered this a bunch on my AMA repo, so here's some initial general answers, before I get to some of the specific questions:

defmodule PyramidCalculator do
@doc """
iex> PyramidCalculator.pyramid_prices_percents([1, 2, 3], 10)
[10.0, 33.33333333333333, 56.666666666666664]
iex> PyramidCalculator.pyramid_prices_percents([1, 2, 3], 40)
[40.0, 33.333333333333336, 26.666666666666668]
iex> PyramidCalculator.pyramid_prices_percents([1, 3, 7, 22], 5)
[5.0, 10.517241379310345, 21.551724137931036, 62.93103448275862]
"""
import functools
from channels.handler import AsgiRequest
from rest_framework.exceptions import AuthenticationFailed
from rest_framework.settings import api_settings
authenticators = [auth() for auth in api_settings.DEFAULT_AUTHENTICATION_CLASSES]