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.AccountLookup.Cache do | |
@moduledoc """ | |
Provides a cache that can be used for account lookups. This cache is backed by | |
Cachex for local storage and pg2 for remote distribution. Keys are set to expire | |
after 7-10 days (randomly distributed) in order to prevent stale data in our cache | |
over a long time period. | |
""" | |
use Cachex.DistributedCache |
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
# We use this ClusterLoadBalancer to prevent hot nodes in our load balanced setup. | |
# The WebSockets are provided by Phoenix through the PushEx application https://github.com/pushex-project/pushex/ | |
# The load balancer's `Worker` module is where the bulk of the cluster orchestration happens, using pg2 for cross node communication | |
defmodule ClusterLoadBalancer.Behavior do | |
@moduledoc """ | |
Behavior for implementing a ClusterLoadBalancer compatible tool. | |
""" | |
@callback count() :: number |
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
public class ImmutableCounter { | |
private final int counter; | |
public ImmutableCounter(int num) { | |
this.counter = num; | |
} | |
public int getCount() { | |
return this.counter; | |
} |
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
import java.util.HashMap; | |
// This class is broken, follow the TODOs | |
public class ImmutableDemo { | |
// TODO: How to prevent external actors from accessing the map directly? | |
public HashMap<String,String> map; | |
public ImmutableDemo() { | |
this.map = new HashMap<String, String>(); | |
this.map.put("Important", "OKAY"); |
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 Super.RepoTest do | |
use Super.DataCase, async: true | |
require Logger | |
@skipped_schemas [UserService.User] | |
defp tenant_schemas do | |
{:ok, mods} = :application.get_key(:super, :modules) | |
Enum.map(mods, fn mod -> |
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 TestRouter do | |
def build(routes) do | |
contents = | |
quote do | |
use Plug.Router | |
plug :match | |
plug :dispatch | |
Enum.map(unquote(Macro.escape(routes)), fn %{match: match, assign: assign} -> |
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
var links = document.getElementsByTagName('a'); | |
var params = new URLSearchParams(window.location.search); | |
var utmParams = {}; | |
params.forEach(function (val, name) { | |
if (name.startsWith('utm_')) { | |
utmParams[name] = val; | |
} | |
}); |
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
{ | |
"user": { | |
"id": "(Required) String: The ID of the user logging into Clove", | |
"email": "String: The email address of the user", | |
"name": "String: Full name of the user", | |
"given_name": "String: First name of the user", | |
"family_name": "String: Last name of the user", | |
"custom_data": "Map: Arbitrary data container for your application", | |
"organization": { | |
"id": "(Required if organization key present) String: The ID of the organization this user belongs to", |
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
export const SpaceLayoutEditor = { | |
// Not important for the integration, just something for my specific use case | |
recentItems: [], | |
mounted() { | |
// IMPORTANT LINE: LiveView -> React data flow | |
this.handleEvent("react.update_items", ({ items }: { items: string }) => { | |
const newItems: SpaceItem[] = JSON.parse(items) | |
this.mountEditor(newItems) | |
}) |
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
export const SpaceLayoutEditor = { | |
mounted() { | |
// I use webpack chunks to reduce LiveView entry file size | |
import(/* webpackChunkName: "space-layout-editor-lv" */ '../entry/space-layout-editor-lv').then((mounter) => { | |
this.unmountComponent = mounter.default(this.el.id, { | |
editorOpts: this.editorOpts() | |
}) | |
}).catch(console.error) | |
}, |
NewerOlder