Skip to content

Instantly share code, notes, and snippets.

JoelQ / dollar.rb
Last active Oct 4, 2022
Implementing value object semantics as an RSpec shared_example.
View dollar.rb
class Dollar
attr_reader :cents
def initialize(cents:)
@cents = cents
def hash
[self.class, cents].hash

Phoenix 1.4.x to 1.5.0 upgrade instructions

Phoenix 1.5 requires Elixir >= 1.7. Be sure your existing version is up to date by running elixir -v on the command line.

Install the new project generator

$ mix archive.uninstall phx_new
$ mix archive.install hex phx_new 1.5.0
gagarine /
Last active Dec 1, 2022
Install fish shell on macOS Mojave with brew

Installing Fish shell on MacOS (Intel and M1) using brew

Fish is a smart and user-friendly command line (like bash or zsh). This is how you can instal Fish on MacOS and make your default shell.

Note that you need the package manager installed on your machine.

Install Fish

brew install fish

mrmartineau /
Last active Dec 1, 2022
Stimulus cheatsheet
ChrisZou / phoenix_channel_wechat_miniprogram_client_transport.js
Last active Jul 24, 2018
Phoenix Channel WeChat miniProgram client transport
View phoenix_channel_wechat_miniprogram_client_transport.js
//This is a WeChat miniprogram client transport for phoenix.js
// so that you can use easily use Phoenix Channel as a WebSocket server.
// Written by @chrismccord
// example usage:
// ```
// let socket = new Socket("ws://localhost:4000/socket", { transport: WxSocket })
// socket.connect()
// let channel ="room:lobby", {})
// channel.join()
// .receive("ok", resp => { console.log("Joined successfully", resp) })
lau / simple_time_zone_list.ex
Last active Apr 15, 2021
Simple city to time zone mapping from Rails. As an Elixir map.
View simple_time_zone_list.ex
# Could be used for instance like this in Phoenix: <%= select f, :time_zone, SimpleTimeZoneList.mapping %>
defmodule SimpleTimeZoneList do
@mapping %{
"International Date Line West" => "Pacific/Midway",
"Midway Island" => "Pacific/Midway",
"American Samoa" => "Pacific/Pago_Pago",
"Hawaii" => "Pacific/Honolulu",
"Alaska" => "America/Juneau",
"Pacific Time (US & Canada)" => "America/Los_Angeles",
"Tijuana" => "America/Tijuana",
ajaxray / select2-cascade.js
Last active Nov 23, 2022
Making Select2 (4.x) list boxes cascading / dependent. Options of a select2 list box will be loaded/refreshed by ajax based on selection of another select2 list box.
View select2-cascade.js
* A Javascript module to loadeding/refreshing options of a select2 list box using ajax based on selection of another select2 list box.
* @url :
* @auther : Anis Uddin Ahmad <>
* Live demo -
* w: | t: @ajaxray
var Select2Cascade = ( function(window, $) {
lopspower /
Last active Dec 4, 2022
Hexadecimal color code for transparency

Hexadecimal color code for transparency


How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

rmondello / gist:b933231b1fcc83a7db0b
Last active Nov 26, 2022
Exporting (iCloud) Keychain and Safari credentials to a CSV file
View gist:b933231b1fcc83a7db0b

Exporting (iCloud) Keychain and Safari credentials to a CSV file

Update (October 2021)

Exporting password + one-time code data from iCloud Keychain is now officially supported in macOS Monterey and Safari 15 (for Monterey, Big Sur, and Catalina). You can access it in the Password Manager’s “gear” icon (System Preferences > Passwords on Monterey, and Safari > Passwords everywhere else), or via the File > Export > Passwords... menu item). You shouldn't need to hack up your own exporter anymore.

Original, Obsolete Content (2014)

After my dad died, I wanted to be able to have access any of his online accounts going forward. My dad was a Safari user and used iCloud Keychain to sync his credentials across his devices. I don’t want to have to keep an OS X user account around just to access his accounts, so I wanted to export his credentials to a portable file. >

stefansundin /
Last active Oct 21, 2022
Git pre-commit check to stop accidental commits to master/main/develop branches.
# This gist contains pre-commit hooks to prevent you from commiting bad code or to the wrong branch.
# There are six variants that I have built:
# - pre-commit: stops commits to master/main/develop branches.
# - pre-commit-2: also includes a core.whitespace check.
# - pre-commit-3: the core.whitespace check and an EOF-newline-check.
# - pre-commit-4: only the core.whitespace check.
# - pre-commit-5: elixir formatting check.
# - pre-commit-6: prettier formatting check.
# Set the desired version like this before proceeding: