Skip to content

Instantly share code, notes, and snippets.

View danielberkompas's full-sized avatar

Daniel Berkompas danielberkompas

View GitHub Profile
@danielberkompas
danielberkompas / auth.ex
Created March 4, 2017 20:44
An example of how to hack together Ueberauth.Auth structs
defmodule MyApp.Auth do
@moduledoc """
Creates `Ueberauth.Auth` structs from OAuth responses.
This module is an ugly hack which is necessary because `Ueberauth` doesn't provide
the necessary hooks to get such a struct without giving it control of the whole
callback phase. We can't do this in the API because all the mobile app can give us
is the OAuth token.
Most of the code was lifted from Ueberauth, with minor changes as needed.
@danielberkompas
danielberkompas / destructure.ex
Created October 31, 2016 20:26
Javascript-style Destructuring for Elixir
defmodule Destructure do
@moduledoc """
Provides helpers for destructuring Elixir data structures. See the `d/1` macro
for more information.
"""
@doc """
Easy destructuring of maps and keyword lists, with atom keys only.
## Examples
@danielberkompas
danielberkompas / scheduler.ex
Created October 26, 2016 17:59
A simple mix task scheduler for Elixir apps
defmodule MyApp.Scheduler do
@moduledoc """
Schedules a Mix task to be run at a given interval in milliseconds.
## Options
- `:task`: The name of the Mix task to run.
- `:args`: A list of arguments to pass to the Mix task's `run/1` function.
- `:interval`: The time interval in millisconds to rerun the task.
@danielberkompas
danielberkompas / date_time_marshaller.rb
Created May 21, 2015 18:42
DateTime marshaler for attr_encrypted
require "attr_encrypted"
require "active_support/core_ext/date_time"
module DateTimeMarshaler
FORMAT = "%F %H:%M:%S"
def self.dump(datetime)
datetime.strftime(FORMAT)
end
@danielberkompas
danielberkompas / compiling.log
Created May 11, 2015 19:02
Complete backtrace of mix deps.get, deps.compile
on_sale [upgrade-phoenix-13●] rm -rf deps
on_sale [upgrade-phoenix-13●] git s
M mix.exs
M mix.lock
on_sale [upgrade-phoenix-13●] mix deps.get
Running dependency resolution
Dependency resolution completed successfully
* Getting phoenix (Hex package)
Checking package (https://s3.amazonaws.com/s3.hex.pm/tarballs/phoenix-0.13.0.tar)
Using locally cached package
@danielberkompas
danielberkompas / phoenix_html.log
Created May 11, 2015 18:54
Upgrading to Phoenix 0.13.0
==> phoenix_html
Compiled lib/phoenix_html/engine.ex
lib/phoenix_html/link.ex:1: warning: redefining module Phoenix.HTML.Link
Compiled lib/phoenix_html.ex
Compiled lib/phoenix_html/link.ex
lib/phoenix_html/tag.ex:1: warning: redefining module Phoenix.HTML.Tag
lib/phoenix_html/form_data.ex:17: warning: redefining module Phoenix.HTML.FormData.Plug.Conn
lib/phoenix_html/safe.ex:1: warning: redefining module Phoenix.HTML.Safe
Compiled lib/phoenix_html/form_data.ex
Compiled lib/phoenix_html/tag.ex
p = Project.first
p.update(description: <<CONTENT
Here is a description
More description
CONTENT
@danielberkompas
danielberkompas / .travis.yml
Created April 3, 2015 22:23
Build PLTs on Travis
language: elixir
elixir:
- 1.0.0
- 1.0.1
- 1.0.2
- 1.0.3
otp_release:
- 17.4
- 17.3
- 17.2
@danielberkompas
danielberkompas / gist:737b11e3c36e20b0ebe4
Created April 2, 2015 17:20
Generate ctags for YouCompleteMe
ctags -R --fields=+l

Keybase proof

I hereby claim:

  • I am danielberkompas on github.
  • I am dberkom (https://keybase.io/dberkom) on keybase.
  • I have a public key whose fingerprint is 3231 92F3 2380 DF70 97E9 DB82 A53C DADD 426D 840C

To claim this, I am signing this object: