Skip to content

Instantly share code, notes, and snippets.

@chrismccord
chrismccord / phx-1.4-upgrade.md
Last active June 16, 2023 06:22
Phoenix 1.3.x to 1.4.0 Upgrade Guides

Phoenix 1.4 ships with exciting new features, most notably with HTTP2 support, improved development experience with faster compile times, new error pages, and local SSL certificate generation. Additionally, our channel layer internals receiveced an overhaul, provided better structure and extensibility. We also shipped a new and improved Presence javascript API, as well as Elixir formatter integration for our routing and test DSLs.

This release requires few user-facing changes and should be a fast upgrade for those on Phoenix 1.3.x.

Install the new phx.new project generator

The mix phx.new archive can now be installed via hex, for a simpler, versioned installation experience.

To grab the new archive, simply run:

@poteto
poteto / flatten_nested_json.ex
Last active April 20, 2018 16:52
Flatten deeply nested Map in Elixir
defmodule Json do
def flatten(%{} = json) do
json
|> Map.to_list()
|> to_flat_map(%{})
end
def flatten(%{} = json) when json == %{}, do: %{}
defp to_flat_map([{_k, %{} = v} | t], acc), do: to_flat_map(Map.to_list(v), to_flat_map(t, acc))
defp to_flat_map([{k, v} | t], acc), do: to_flat_map(t, Map.put_new(acc, k, v))
#!/bin/bash
SSH_COMMAND="ssh "
DESCRIBE_COMMAND=$(cat << EOS
aws ec2
--output text
describe-instances
--query
'sort_by(Reservations[].Instances[].{InstanceId:InstanceId,Tags:Tags[?Key==\`Name\`].Value|[0],InstanceType:InstanceType,State:State.Name,Ip:PublicIpAddress},&Tags)'
--filter
@keijiro
keijiro / XPS13-Ubuntu.md
Last active May 22, 2019 04:00
Dell XPS 13 (2015) に Ubuntu を入れる

2015/4/24 追記 - Ubuntu 15.04 (Vivid Vervet) では特に工夫しなくともすんなり動作するようになった模様です。ということで、インストール時には 15.04 を選ぶようにしましょう。

下記は 14.04 向けの古い情報となります。


XPS 13

Dell の XPS 13 (2015) に Ubuntu を入れたら幸せになれるのではないか。そんな気がしたので入れてみたのですが、案外に気をつけるべきポイントが多いので、手順を書き記しておきます。

@onk
onk / .rubocop.yml
Last active January 15, 2018 02:30
僕の使っている .rubocop.yml
# rubocop v0.35.0 から inherit_gem という機能が増えたので gem にしました
# https://github.com/onk/onkcop
inherit_gem:
onkcop: "config/rubocop.yml"
@donpdonp
donpdonp / gist:2258175
Created March 31, 2012 00:28
sublime text 2 Slim
donp@sparky:~/.config/sublime-text-2/Packages$ git clone git://github.com/fredwu/ruby-slim-tmbundle.git Ruby-Slim.tmbundle
Cloning into Ruby-Slim.tmbundle...
remote: Counting objects: 142, done.
remote: Compressing objects: 100% (63/63), done.
remote: Total 142 (delta 89), reused 114 (delta 61)
Receiving objects: 100% (142/142), 21.44 KiB, done.
Resolving deltas: 100% (89/89), done.
donp@sparky:~/.config/sublime-text-2/Packages$ ls Ruby-Slim.tmbundle/
Commands info.plist Preferences README.md Snippets Syntaxes
donp@sparky:~/.config/sublime-text-2/Packages$
@vastdevblog
vastdevblog / ExampleServer.scala
Created March 12, 2012 14:30
Example of a Finagle server
package com.vast.example
import java.net.InetSocketAddress
import java.util.UUID
import java.util.concurrent.{Executors, TimeUnit}
import com.google.common.base.Splitter
import com.twitter.finagle.http.Http
import com.twitter.finagle.builder.{Server, ServerBuilder}
import com.twitter.finagle.service.TimeoutFilter
import com.twitter.finagle.{Service, SimpleFilter, GlobalRequestTimeoutException}