Skip to content

Instantly share code, notes, and snippets.

View mxgrn's full-sized avatar

Max Gorin mxgrn

View GitHub Profile
# It's only a POC for now
defmodule ContextBase do
@moduledoc """
Abstracts away common schema functions, such as list, get, create, update, delete, etc.
Assumes that the schema module has a `changeset` function.
Usage:
defmodule MyContext do
use ContextBase, repo: MyApp.Repo, schema: MyApp.MySchema
end
@mxgrn
mxgrn / renaming-phoenix-app.md
Created December 23, 2023 03:26
Renaming Elixir Phoenix app

Say, at some point you generated your Phoenix app with mix phx.new my_app, but later decided to change its name to "new_app".

See this little memo as a checklist to avoid possible pitfalls.

1. Project-wide search and replace

Use your favorite text editor to search and replace as follows (use case-sensitive search for minimizing chances for a mistake):

  • MyApp -> NewApp
  • my_app -> new_app
@mxgrn
mxgrn / lv_modal_close_confirm.md
Last active April 11, 2024 06:42
LiveView modal close confirmation on dirty form
@mxgrn
mxgrn / book.ex
Created November 4, 2023 16:24
Book Ash Resource
defmodule AshTable.Book do
use Ash.Resource, data_layer: AshPostgres.DataLayer
postgres do
table "books"
repo AshTable.Repo
end
attributes do
uuid_primary_key :id
# install wkhtmltopdf
RUN apt-get -q update && \
apt-get -qy install --no-install-recommends wget && \
wget --no-check-certificate -nv -O /tmp/wkhtmltox.deb https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.bullseye_amd64.deb && \
apt-get -qy install /tmp/wkhtmltox.deb && \
cd /usr/local/bin && \
cp wkhtmltoimage /usr/bin/wkhtmltoimage && \
cp wkhtmltopdf /usr/bin/wkhtmltopdf
Verifying that "maxgorin.id" is my Blockstack ID. https://onename.com/maxgorin
@mxgrn
mxgrn / dvorak-to-colemak.md
Last active January 9, 2019 19:02
Dvorak -> Colemak

I switched to Dvorak about 9 years ago. It was my 3rd touch-typed layout, after ЙЦУКЕН and QWERTY, both of which I was using daily. Now, that I look back, I think choosing Dvorak wasn't ideal: while it's been a huge relief after QWERTY (this ubiquitous finger twister), Dvorak showed certain drawbacks I should have noticed from the very beginning. A good example would be the frequent "sl" combination (slow, sleep, slide, etc), which is a same-finger combination for the right pinkie. Recently, some extra research showed it must have always been Colemak.

Learning a new layout is akin to learning a musical instrument: the cognitive effort required for deliberate practice feels pleasingly mind stretching. So, I decided to switch again. Below this paragraph I'll be posting everything I have typed so far during my Colemak practice, including some report on the progress - for what it's worth. Minor editing here and there is possible for readability. Let's see how much typing it takes to get back to a reasonable spee

### Keybase proof
I hereby claim:
* I am mxgrn on github.
* I am mxgrn (https://keybase.io/mxgrn) on keybase.
* I have a public key ASAawdHU72TBx7thfEqkiCLt2j4IXULM4npcWfbwHkpGaQo
To claim this, I am signing this object:
@mxgrn
mxgrn / netzke10roadmap.md
Last active January 4, 2016 10:13
Netzke 1.0 rough roadmap

A very rough todo list for the Netzke 1.0 release (WIP)

NOTE: this is not replacement for CHANGELOG (CHANGELOG for Basepack).

Netzke Core

  • Currently there's an experimental implementation of the (badly named) clone option in netzkeLoadComponent JS method, which allows loading multiple instances of the same child component, providing different configuration options for each instance. I'd like to consolidate this with the "normal" loading method, and thus get this functionality available by default.
  • Concatenating JS mixins should be made less error-prone (dangling commas, etc)
  • Routing. In the app I'm currently developing there's a need for routing, and I think I came up with a simple and flexible way to use Ext JS's Controller to do just that (I'm able to use nested routes like "#clients/2/orders/1/items").
  • Currently all the component DSL

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email