This file contains 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 MyApp.Channel do | |
alias Experimental.GenStage | |
use GenStage | |
use MyApp.Web, :channel | |
def init(socket) do | |
{:consumer, socket, subscribe_to: [MyApp.BroadcastStage]} | |
end | |
def handle_events(events, _from, socket) do | |
# get events pushed directly to each channel connection | |
Enum.each events, &Phoenix.Channel.push(socket, "message", &1) |
This file contains 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 Coll do | |
@doc """ | |
Removes all values from the subject | |
iex> Coll.remove([1, 2, 3], [2, 3]) | |
[1] | |
iex> Coll.remove([1, 2], [2, 3, 4]) | |
[1] | |
""" |
This file contains 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
def descendants(organization_id, truncation, filter \\ from o in __MODULE__) do | |
sub = from os in filter, where: os.organization_id == ^organization_id and os.truncation == ^truncation, select: [os.organization_id, os.parent_organization_id, os.id, ^1, os.datetime, os.truncation] | |
query = from outer in __MODULE__, | |
join: t in fragment(""" | |
WITH RECURSIVE search_orgs(organization_id, parent_organization_id, id, depth, datetime, truncation) AS ( | |
? | |
UNION ALL | |
SELECT | |
o.organization_id, |
This file contains 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
def descendants(organization_id, truncation, filter \\ from o in __MODULE__) do | |
sub = from os in filter, where: os.organization_id == ^organization_id and os.truncation == ^truncation, select: [os.organization_id, os.parent_organization_id, os.id, ^1, os.datetime, os.truncation] | |
query = from outer in __MODULE__, | |
join: t in fragment(""" | |
WITH RECURSIVE search_orgs(organization_id, parent_organization_id, id, depth, datetime, truncation) AS ( | |
? | |
UNION ALL | |
SELECT | |
o.organization_id, |
This file contains 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
def descendants(organization_id, truncation, filter \\ from o in __MODULE__) do | |
sub = from os in filter, where: os.organization_id == ^organization_id and os.truncation == ^truncation, select: [os.organization_id, os.parent_organization_id, os.id, ^1, os.datetime, os.truncation] | |
query = from outer in __MODULE__, | |
join: t in fragment(""" | |
WITH RECURSIVE search_orgs(organization_id, parent_organization_id, id, depth, datetime, truncation) AS ( | |
? | |
UNION ALL | |
SELECT | |
o.organization_id, |
This file contains 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
displaySleep = false -- Need better way to determine initial state of this variable. But it should be the truth most of the time. | |
systemSleep = false | |
function handleCaffeinateUpdates() | |
wifiPower = hs.wifi.interfaceDetails().power | |
if displaySleep and systemSleep and wifiPower then | |
print("Disabling WiFi before going to sleep") | |
hs.wifi.setPower(false) | |
elseif not displaySleep and not systemSleep and not wifiPower then | |
print("Woke up - enabling wifi") |
This file contains 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 Swarm.DynamicSupervisor do | |
use GenServer | |
require Logger | |
defstruct [ | |
:child_name, | |
:child_module, | |
:child_args, | |
:group, | |
:pid, |
This file contains 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 Cluster.RabbitStrategy do | |
use GenServer | |
use Cluster.Strategy | |
import Cluster.Logger | |
alias Cluster.Strategy.State | |
@routing_key "cluster.heartbeat" | |
def start_link(opts) do |
This file contains 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 RepoStream do | |
defmodule Producer do | |
use GenStage | |
defstruct [:demand, :pid] | |
def start_link() do | |
GenStage.start_link(__MODULE__, self()) | |
end |
This file contains 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
*smoothScroll.js* | |
*smooth*.js* | |
*nicescroll*js* | |
*jquery.mousewheel.js* | |
*plugins-scroll.js* | |
https://d33wubrfki0l68.cloudfront.net/bundles/85ee573a175fbccec4ed26bf47ede7fd06c1d248.js |