This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var FormAbandonmentTracker = { | |
init: function(gtag, form_id, event_category, event_action = 'FormAbandonment') { | |
this.$gtag = gtag; | |
this.$eventCategory = event_category ? event_category : form_id; | |
this.$eventAction = event_action; | |
this.$formHistory = []; | |
this.$formIsSubmitted = false; | |
this.$formId = form_id; | |
this.$form = document.getElementById(form_id); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iex(12)> :dbg.tracer() | |
{:error, :already_started} | |
iex(13)> :dbg.tpl(:gun, []) | |
{:ok, [{:matched, :nonode@nohost, 73}]} | |
iex(14)> :dbg.tpl(:gun_http2, []) | |
{:ok, [{:matched, :nonode@nohost, 40}]} | |
iex(15)> :dbg.p(:all ,:c) | |
{:ok, [{:matched, :nonode@nohost, 265}]} | |
iex(16)> (<0.366.0>) call gun_http2:keepalive({http2_state,<0.359.0>,#Port<0.15835>,gun_tcp,#{}, | |
[gun_data_h], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule EmojiMap.TweetConsumer do | |
@moduledoc """ | |
The consumer side. Subscribes to the producer once it is started so when | |
it crashes and the supervisor restarts it, it automatically re-subscribes | |
""" | |
use GenStage | |
@doc """ | |
Starts the consumer. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule EmojiMap.TweetBroadcaster do | |
@moduledoc """ | |
When events arrive and there are no consumers, we store the event in | |
the queue alongside the process information that broadcasted the event. When | |
consumers send demand and there are not enough events, we increase the pending | |
demand. Once we have both the data and the demand, we acknowledge the process | |
that has sent the event to the broadcaster and finally broadcast the event | |
downstream. | |
This follows very closely the example in the Docs on Bufferin Demand: | |
https://hexdocs.pm/gen_stage/GenStage.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule EmojiMap.TwitterStream do | |
@moduledoc """ | |
We get a Twitter Stream from locations within a bounding box. The | |
bounding box is so large that the tweets can come from all over the world. | |
This way we make sure that we only receive geo-tagged tweets. The reason for | |
this is: It isn't possible to search for hundreds of different keywords at | |
once. Plus location isn't a filter. So we find tweets from either the location | |
OR matching the keyword. We have to filter ourself. | |
""" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule EmojiMap.TweetBufferFiller do | |
use GenServer | |
alias EmojiMap.TweetBroadcaster | |
alias EmojiMap.TweetConsumer | |
alias EmojiMap.TwitterStream | |
def start_link(opts \\ []) do | |
{:ok, pid} = GenServer.start_link(__MODULE__, [], opts) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component} from '@angular/core'; | |
import { Nl2BrPipe } from './nl2br.pipe'; | |
@Component({ | |
moduleId: module.id, | |
selector: 'my-component', | |
template: ` | |
<div [innerHtml]="content | nl2br"></div> | |
` |