Skip to content

Instantly share code, notes, and snippets.

View sb8244's full-sized avatar

Stephen Bussey sb8244

View GitHub Profile
{% if user %}
<script>
window.intercomSettings = {
app_id: "YOUR_APP_ID",
user_id: "{{ user.id }}",
email: "{{ user.email }}",
user_hash: "{{ user.id | encrypt: "hmac", "YOUR_IDENTITY_VERIFICATION_SECRET" }}"
};
</script>
{% else %}
<script type="text/javascript">
if (window.top !== window.self) {
const msg = {
urlChange: {
pathname: window.location.pathname,
search: window.location.search,
href: window.location.href
}
}
window.top.postMessage(msg, '*')
<!-- Note: un-minified source code available at clove-embed.js -->
<script type="text/javascript" src="https://public-cdn.cloveapp.io/clove-embed.min.js"></script>
<script type="text/javascript">
CloveEmbed.installFrameListener()
CloveEmbed.setFrameUrl("https://yourhub.example.com")
</script>
@sb8244
sb8244 / header.html
Last active February 18, 2022 21:42
Clove IFrame Embed Code — View more at https://hub.clovecx.com/hc/a/embed-your-customer-hub
<script type="text/javascript">
if (window.top !== window.self) {
document.body.classList.add('in-iframe')
}
</script>
/**
* This example is just copy/pasted from my code base. The gist of it is that `this.pushEventTo` on the hook
* will send an event over the LiveView channel that is processed by the component/LiveView that's mounted at
* that element.
*
* I recommend using pushEventTo instead of pushEvent because I've run into situations where the event gets sent
* to the incorrect component or LiveView.
*/
const GeneratePDFButton = {
mounted() {
@sb8244
sb8244 / notion.ex
Created December 22, 2021 07:35
Example of fetching pages and blocks from Notion's public API in Elixir
defmodule Clove.Connections.Client.Notion do
# There is not a way to filter last_edited_time, so consumer should check if it needs to fetch the blocks or not
# This will help for deletion detection, though
def retrieve_pages(connection) do
request = %{
method: :post,
url: "#{base_url()}/v1/search",
params: %{
"query" => "",
"sort" => %{
@sb8244
sb8244 / contentful-import.json
Last active November 12, 2021 22:28
Clove Contentful Types https://cloveapp.io
{
"contentTypes": [
{
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "hq8sy8wk8n0y"
}
@sb8244
sb8244 / chartkick.ex
Created May 16, 2021 16:10
This allows chartkick to be embedded in LiveViews
defmodule Chartkick do
@moduledoc """
Adapted from https://github.com/buren/chartkick-ex/blob/master/lib/chartkick.ex to work with LiveView.
Works in conjunction with Phoenix LiveView hooks to render charts using Chartkick.js library.
"""
require EEx
gen_chart_fn = fn chart_type ->
defmodule SteveTrollsElixir.Private do
defmacro __using__(_) do
quote do
import unquote(__MODULE__)
@on_definition {unquote(__MODULE__), :on_priv_def}
end
end
defmacro private() do
quote do
import { Pushex } from 'pushex'
import { getToken } from './tokenService'
const pushexOptions = {
getParams: () => getToken().then(({ token }) => Promise.resolve({ token })),
onConnectionError: pushex => {
pushex.resetParams()
},
}