Skip to content

Instantly share code, notes, and snippets.

@nhu313
nhu313 / rss_entry_template
Created July 13, 2014 04:01
Phoenix RSS Entry template
<%= for entry <- @entries do %>
<li>
<%= entry.body %>
</li>
<% end %>
@nhu313
nhu313 / feeder_controller
Created July 13, 2014 05:54
Feeder controller
defmodule FeederWeb.Controllers.Pages do
use Phoenix.Controller
def hello(conn, _params) do
render conn, "hello"
end
end
@nhu313
nhu313 / httpotion_error
Created September 19, 2014 03:12
HTTPoition error
20:11:48.357 [error] Error in process <0.642.0> with exit value: {badarg,[{erlang,hd,[[]],[]},{'Elixir.RssParser',find_value,2,[{file,"lib/rss_parser.ex"},{line,37}]},{'Elixir.RssParser',convert_rss,1,[{file,"lib/rss_parser.ex"},{line,18}]},{'Elixir.Enum','-map/2-lc$^0/1-0-',2,[{file,"lib/enum.ex"},{...
20:11:48.358 [error] Ranch listener FeederWeb.Router.HTTP had connection process started with :cowboy_protocol:start_link/4 at #PID<0.633.0> exit with reason: {:badarg, [{:erlang, :hd, [[]], []}, {RssParser, :find_value, 2, [file: 'lib/rss_parser.ex', line: 37]}, {RssParser, :convert_rss, 1, [file: 'lib/rss_parser.ex', line: 18]}, {Enum, :"-map/2-lc$^0/1-0-", 2, [file: 'lib/enum.ex', line: 977]}, {Enum, :"-map/2-lc$^0/1-0-", 2, [file: 'lib/enum.ex', line: 977]}, {FeedRetriever, :retrieve_content, 1, [file: 'lib/FeedRetriever.ex', line: 18]}, {FeedRetriever, :"-pmap/2-fun-0-", 3, [file: 'lib/FeedRetriever.ex', line: 10]}]}
@nhu313
nhu313 / ci3_carousel.js
Created June 16, 2015 05:01
jQuery Carousel plugin
[error] #PID<0.302.0> running MyApp.Endpoint terminated
Server: localhost:4000 (http)
Request: GET /todo_lists/new
** (exit) an exception was raised:
** (ArgumentError) cannot generate inputs_for for field :todo_items with type {:assoc, %Ecto.Association.Has{cardinality: :many, defaults: [], field: :todo_items, on_cast: :changeset, on_delete: :nothing, on_replace: :delete, owner: MyApp.TodoList, owner_key: :id, queryable: MyApp.TodoItem, related: MyApp.TodoItem, related_key: :todo_list_id}}
(phoenix_ecto) lib/phoenix_ecto/html.ex:164: Phoenix.HTML.FormData.Ecto.Changeset.find_inputs_for_type!/2
(phoenix_ecto) lib/phoenix_ecto/html.ex:30: Phoenix.HTML.FormData.Ecto.Changeset.to_form/4
(phoenix_html) lib/phoenix_html/form.ex:255: Phoenix.HTML.Form.inputs_for/4
(my_app) web/templates/todo_list/form.html.eex:18: anonymous fn/2 in MyApp.TodoListView.form.html/1
(phoenix_html) lib/phoenix_html/form.ex:227: Phoenix.HTML.Form.form_for/4
@nhu313
nhu313 / deploy_dokku.md
Last active May 15, 2018 21:03
Deploying phoenix on Dokku through Digital ocean

This write up was based on Henrik's gist

Create server

  1. Create a droplet on digital ocean. Use my referal link for $10 credit. I also credit if you spend money, so thanks in advance ;)
    1. Select "Create Droplet"
    2. Under "Choose an image", click on "One-click Apps"
    3. Select Dokku for your app
    4. Under "Choose a size" select at least 1GB of RAM
    5. Add your ssh public key
  2. Click "Create"
@nhu313
nhu313 / questions.json
Created March 25, 2016 19:10
usmle questionnaire
{"question": "",
"choices": [],
"answer": "",
"explaination": ""
},

Keybase proof

I hereby claim:

  • I am nhu313 on github.
  • I am nhu313 (https://keybase.io/nhu313) on keybase.
  • I have a public key ASBfHWicA2Vt4-PV4IZRnRwm4x6t4caB4Uo4OErnYJ_a8Ao

To claim this, I am signing this object:

import org.junit.Test;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class StreamTest {
@Test
package com.example.interview;
import java.util.HashMap;
import java.util.Map;
public class PalindromePermutation {
public static boolean isPalindromePermutation(String value) {
Map<Character, Integer> counts = countCharacters(value);