Skip to content

Instantly share code, notes, and snippets.

@mkcode
mkcode / route.ts
Last active November 7, 2024 23:29
How to setup Next App Router + Clerk + TRPC
// TRPC API endpoint
// src/app/api/trpc/[trpc]/route.ts
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
import { type NextRequest } from "next/server";
import { env } from "~/env";
import { appRouter } from "~/server/api/root";
import { createTRPCContext } from "~/server/api/trpc";
import { getAuth } from "@clerk/nextjs/server";
@mkcode
mkcode / .vscode-neovim-init.vim
Created October 5, 2022 20:17
Minimal yet functional config for VSpaceCode with VSCode-Neovim
" Our .vscode-neovim directory
let data_dir = '~/.vscode-neovim'
let plugFile = data_dir . '/plug.vim'
" Download plug.vim if it doesn't exist
" Then install the plugins in this file
if empty(glob(plugFile))
silent execute '!curl -fLo '.plugFile.' --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
execute "autocmd VimEnter * PlugInstall --sync | source " . expand('%:p')
@mkcode
mkcode / mlh_open_source.md
Last active February 4, 2021 00:44
MLH Open Source Program Description

Welcome to the MLH Open Source Fellowship

Over the course of the program, you will work with other fellows, your team lead, open source maintainers, and Raise.dev Coaches to contribute to open source. You can read the full program details in the official MLH Fellowship Handbook.

Fellow Expectations

As a member of the Fellowship, you have access to a team of experienced software developer coaches. You're welcome and encouraged to go to them for help and advice as needed throughout the program. To help you stay on track, we've set some minimum expectations for interacting with Raise.dev Coaches.

Over the course of the program you should:

  • Complete at least five (5) Pair Programming Sessions with a Raise.dev Coach.
  • Complete two (2) Career Advice Sessions with a Raise.dev Coach.
  • Attend all of the weekly sync meetings with your project maintainer and Raise.dev Coach.
@mkcode
mkcode / Get Student PRs.md
Last active June 22, 2020 21:29
Student Pull Request GraphQL Query

Get List of your fellows' PRs'

Get list of Student Node Ids

Do this once and save the user ids

Url is https://api.github.com/users/[GITHUB_USER_NAME]

I used the following command, filling in the different user names. (jsonpath is not available by default):

@mkcode
mkcode / nyc-corona.md
Last active March 5, 2020 00:40
NYC Coronavirus

To friends in NYC - Coronavirus

March 4, 2020

This document is an appeal for friends and family in NYC to begin behaving as if 'Community Spread' of the corona virus is currently happening. We now have many examples throughout the world which show that early dramatic action is most effective in curtailing the spread of virus. Simple prudent actions now, can have big impacts.

Appropriate actions given Community Spread

Please continue to follow all of the standard advice you have heard regarding thoroughly washing hands, not touching your face, and avoiding body contact with others. In addition to this, please begin voluntarily practicing 'Social Distancing' techniques. These include:

My largest Sidekiq application had a memory leak and I was able to find and fix it in just few hours spent on analyzing Ruby's heap. In this post I'll show my profiling setup.

As you might know Ruby 2.1 introduced a few great changes to ObjectSpace, so now it's much easier to find a line of code that is allocating too many objects. Here is great post explaining how it's working.

I was too lazy to set up some seeding and run it locally, so I checked that test suite passes when profiling is enabled and pushed debugging to production. Production environment also suited me better since my jobs data can't be fully random generated.

So, in order to profile your worker, add this to your Sidekiq configuration:

if ENV["PROFILE"]
(defvar-local prose-proselint-enabled nil
"Buffer local proselint enabled status")
(defun prose-proselint-enabled-p ()
"Workaround for proselint flycheck checker predicate"
prose-proselint-enabled)
(flycheck-define-checker proselint
"A linter for prose."
:command ("proselint" source-inplace)
<%
# Quick function to calculate the correct number DB_POOL size. DB_POOL size is
# reused for the puma web server and sidekiq. It cannot be less than the
# amount the concurrency of either.
db_needed_for_web = ENV.fetch('WEB_CONCURRENCY', 1) * ENV.fetch('WEB_THREADS', 1)
db_needed_for_sidekiq = ENV.fetch('SIDEKIQ_CONCURRENCY', 0)
# The minimum pool size is the maximum of the sidekiq and web concurrency. We
# add some extras to the pool for sidekiq's scheduler and one off dynos.
ObjectSpace stats:
TOTAL: 1142492
FREE: 669062
T_STRING: 179003
T_ARRAY: 114638
T_IMEMO: 80083
T_HASH: 61165
T_OBJECT: 12105
T_DATA: 10860
Total allocated: 8512525 bytes (74080 objects)
Total retained: 255630 bytes (1749 objects)
allocated memory by gem
-----------------------------------
3037410 sprockets-3.5.2
2550216 2.3.0/lib
1143973 binding_of_caller-0.7.2
604899 activesupport-4.2.5.2
375267 actionview-4.2.5.2