Skip to content

Instantly share code, notes, and snippets.

@wosephjeber
wosephjeber / instructions.md
Last active March 27, 2024 10:52
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
@nicbet
nicbet / _Webpack-Fontawesome-Bootstrap-Phoenix.md
Last active April 28, 2020 05:43
Sass versions of Bootstrap 4 and Fontawesome 5 with Elixir / Phoenix Framework 1.3.x and 1.4.x using Webpack

SASS Versions of

  • Fontawesome 5
  • Bootstrap 4

in Phoenix 1.3 and 1.4 via Webpack

@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API
@pythoninthegrass
pythoninthegrass / install_mosh_centos7.sh
Created May 25, 2018 23:10
Install mosh on CentOS 7
#!/usr/bin/env bash
# SOURCE: https://eligiblestore.com/blog/2017/05/02/how-to-install-mosh-on-centos/
# ensure running as root
if [[ "$(id -u)" != "0" ]]; then
exec sudo "$0" "$@"
fi
# install mosh
yum install -y epel-release
@jasongoodwin
jasongoodwin / gist:b6aa964ecfa230b53dc3562d85376819
Created April 24, 2018 13:46
Functional Programming Paradigms - "Monadic"-style data processing in elixir
theme: Sketchnote, 7
build-lists: false
slidenumbers: true
autoscale: true
---
# Functional Programming Paradigms In Elixir
- Objectives:
- Understand functional programming a bit better
@dylanmckay
dylanmckay / facebook-contact-info-summary.rb
Last active March 12, 2024 22:46
A Ruby script for collecting phone record statistics from a Facebook user data dump
#! /usr/bin/env ruby
# NOTE: Requires Ruby 2.1 or greater.
# This script can be used to parse and dump the information from
# the 'html/contact_info.htm' file in a Facebook user data ZIP download.
#
# It prints all cell phone call + SMS message + MMS records, plus a summary of each.
#
# It also dumps all of the records into CSV files inside a 'CSV' folder, that is created
# HELP mothership_collector_working Is the master process collector able to collect metrics
# TYPE mothership_collector_working gauge
mothership_collector_working 1
# HELP mothership_collector_rss total memory used by collector process
# TYPE mothership_collector_rss gauge
mothership_collector_rss 243605504
@JunSuzukiJapan
JunSuzukiJapan / tasks.json
Created January 20, 2018 10:00
VS Code tasks.json for Elixir/Mix
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "mix compile",
"group": {
"kind": "build",
"isDefault": true
@mort3za
mort3za / git-auto-sign-commits.sh
Last active January 30, 2024 10:31
Auto sign your git commits
# Generate a new pgp key: (better to use gpg2 instead of gpg in all below commands)
gpg --gen-key
# maybe you need some random work in your OS to generate a key. so run this command: `find ./* /home/username -type d | xargs grep some_random_string > /dev/null`
# check current keys:
gpg --list-secret-keys --keyid-format LONG
# See your gpg public key:
gpg --armor --export YOUR_KEY_ID
# YOUR_KEY_ID is the hash in front of `sec` in previous command. (for example sec 4096R/234FAA343232333 => key id is: 234FAA343232333)

注意:指令在後續版本略有修改,建議閱讀專案 README。

SNAFU 使用教學(暫定)

這篇文章會簡單描述如何使用 SNAFU Python installer manager

這個專案源自我對社群不懂 Windows 又愛亂教的不滿。如果有興趣讀相關故事,以及一些背後邏輯,可以參考我在碼天狗上的抱怨文

特點