Skip to content

Instantly share code, notes, and snippets.

View pachun's full-sized avatar

Nicholas Pachulski pachun

View GitHub Profile

I've been working on an email client for about a year to fill the Newton Mail shaped hole in my heart. I put it in the store about a week ago.

Newton Mail: https://en.wikipedia.org/wiki/Newton_(software) Emma Email (my app): https://emmaemail.app

Emma only runs on iOS and only supports Gmail. I have started building it 3 times over the past 5 or so years - because Newton has gone out of business 3 times in that timeframe. The first two times, it was saved by savior companies who bought and revived it, so in those two instances, I stopped working on a "rebuild". The most recent time it went out of business (June/July 2024), it died permanently. Nobody saved it and despite promises from the most recent company that bought / revived it that if it went out of business again, they'd open source it, that never happened. I'm not super upset about that; que sera. Especially after contacting those people (the last company that revived Newton), via reddit about their stack. Sounds like it was a mess of legacy code

defmodule EmmaApiWeb.Gmail.WebhookControllerTest do
use EmmaApiWeb.ConnCase
use EmmaApi.TestDSL
test "sends new inbox email push notifications and returns an ok status", %{conn: conn} do
%{id: id, gmail_address: gmail_address} = Factory.insert(:gmail_account)
allow(SendNewInboxEmailsPushNotifications)
|> to_receive(:send, 2)
defmodule EmmaApi.ExpectDSL do
defmacro expect({op, _meta, _args} = assertion_ast) when op in [:==, :=~, :>, :<, :<=, :>=] do
quote do
assert unquote(assertion_ast)
end
end
defmacro expect(module) do
quote do: unquote(module)
end
@pachun
pachun / mswNock.ts
Created May 26, 2025 09:47
Replace nock() with mswNock() (also, uninstall nock and install msw in your development dependencies)
import { http, HttpResponse, HttpHandler, StrictRequest } from "msw"
import { setupServer } from "msw/native"
const server = setupServer()
beforeAll(() => server.listen())
afterEach(() => server.resetHandlers())
afterAll(() => server.close())
type Headers = Record<string, string>
import { http, HttpResponse, HttpHandler, StrictRequest } from "msw"
import server from "./emmaApiMock"
type Headers = Record<string, string>
type QueryParams = Record<string, string | null>
type HttpMethod = "get" | "post" | "put" | "delete"
class MSWNock {
private method: HttpMethod = "get"
private fullUrl = ""
-- Vim split hotkeys
vim.keymap.set("n", "<leader>d|", "<C-w>v", { desc = "Split window vertically" })
vim.keymap.set("n", "<leader>d_", "<C-w>s", { desc = "Split window horizontally" })
-- <leader>+ toggles maximizing the current pane, like tmux
_G.toggle_session = function()
local session_file = "/tmp/vim_session_" .. vim.fn.getpid() .. ".vim"
if vim.fn.filereadable(session_file) == 1 then
vim.cmd("silent! source " .. session_file)
vim.fn.delete(session_file)
-- Rename tmux window when nvim opens
if vim.fn.exists("$TMUX") == 1 then
local function rename_tmux_tab()
local cwd = vim.fn.fnamemodify(vim.fn.getcwd(), ":t")
vim.fn.system('tmux rename-window "' .. cwd .. '"')
end
local function reset_tmux_tab()
vim.fn.system("tmux set-window-option automatic-rename on")
end
import type { Config } from "jest"
import * as fsPromises from "fs/promises"
const setupFilesAfterEnv = async (): Promise<string[]> => {
const setupFilesAfterEnvPath = "./tests/helpers/jest/setupFilesAfterEnv/"
return (await fsPromises.readdir(`${setupFilesAfterEnvPath}`)).map(
fileName => `${setupFilesAfterEnvPath}/${fileName}`,
)
}
local function filename()
return vim.fn.expand("%:p")
end
local function line_number()
return vim.api.nvim_win_get_cursor(0)[1]
end
local function current_directory()
return vim.fn.getcwd()
-- Change the Diagnostic symbols in the sign column (gutter)
-- (not in youtube nvim video)
local signs = { Error = "", Warn = "", Hint = "󰠠", Info = "" }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon .. " ", texthl = hl, numhl = "" })
end
-- Change the diagnostic symbols by the error message
vim.diagnostic.config({