Skip to content

Instantly share code, notes, and snippets.

View aptinio's full-sized avatar

Aaron Tinio aptinio

  • Angeles City, Philippines
View GitHub Profile
@nat-418
nat-418 / a-sensible-nixos-xfce-configuration.md
Last active November 1, 2024 10:03
A sensible NixOS Xfce configuration

A sensible NixOS Xfce Configuration

NixOS provides good support for the Xfce desktop environment out-of-the-box, but the defaults are minimal. The files in this Gist provide a more complete experience, including a suite of basic software and plugins as well as an optional home-manager configuration for theming.

The key additions to the default Xfce provided by NixOS are:

  • Complete bluetooth / audio support with panel indicators and apps
  • LightDM with theme
  • Extra Xfce apps for calendaring, disk partitioning, etc.
  • Various quality-of-life improving non-essentials
@wosephjeber
wosephjeber / instructions.md
Last active November 15, 2024 14:45
Ecto migration for renaming table with indexes and constraints

Renaming table in Ecto migration

I recently wanted to rename a model and its postgres table in a Phoenix app. Renaming the table was simple and documented, but the table also had constraints, sequences, and indexes that needed to be updated in order for the Ecto model to be able to rely on default naming conventions. I couldn't find any examples of what this would look like but was eventually able to figure it out. For anyone else in the same situation, hopefully this example helps.

In the example below, I'm renaming the Permission model to Membership. This model belongs to a User and an Account, so it has foreign key constraints that need to be renamed.

defmodule MyApp.Repo.Migrations.RenamePermissionsToMemberships do
  use Ecto.Migration
@evancz
evancz / data-interchange.md
Last active October 31, 2024 12:01
Why do I have to write JSON decoders in Elm?

A vision for data interchange in Elm

How do you send information between clients and servers? What format should that information be in? What happens when the server changes the format, but the client has not been updated yet? What happens when the server changes the format, but the database cannot be updated?

These are difficult questions. It is not just about picking a format, but rather picking a format that can evolve as your application evolves.

Literature Review

By now there are many approaches to communicating between client and server. These approaches tend to be known within specific companies and language communities, but the techniques do not cross borders. I will outline JSON, ProtoBuf, and GraphQL here so we can learn from them all.

@jessejanderson
jessejanderson / macros.md
Last active October 28, 2024 00:58
Don't Write Macros (but do learn how they work)
@timriley
timriley / _pagination.slim
Created January 12, 2016 23:00
Rodakase/ROM pagination
nav.pagination
- unless first_page?
span.first
a href=url_for_page(1)
| « First
span.prev
a href=url_for_page(prev_page) rel="prev"
| ‹ Prev
- if prev_gap?
span.page.gap
# for use by collection_select and friends, to link a human-readable label with a db-friendly symbolic value
# todo: ActiveRecord macros for setters (for allowing multiple values or just one)
# Usage:
# Table name: snacks
# id :integer
# ice_cream :string
# class Snack < ActiveRecord::Base
# FLAVORS = Enum.new [
# [:vanilla, "Vanilla"],
# [:chocolate, "Chocolate"],
@timruffles
timruffles / dyanmic_or_di_elixir.md
Last active June 11, 2020 04:23
Approaches to dependency-injection/dynamic dispatch in elixir

In many production systems you'll want to have one module capable of talking to many potential implementations of a collaborator module (e.g a in memory cache, a redis-based cache etc). While testing it's useful to control which module the module under test is talking to.

Here are the approaches I can see. The two points that seem to divide the approaches are their tool-ability (dialyzer) and their ability to handle stateful implementations (which need a pid).

Passing modules

Modules are first class, so you can pass them in. Used in EEx, where passed module must implement a behaviour.