Skip to content

Instantly share code, notes, and snippets.

View Stock Enquiry.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="order.xslt"?>
<Order xmlns="urn:schemas-basda-org:2000:purchaseOrder:xdr:3.01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:schemas-basda-org:2000:purchaseOrder:xdr:3.01 order-v3.xsd urn:schemas-bossfed-co-uk:OP-Order-v1 OP-Order-v1.xsd">
<OrderHead>
<Schema>
<Version>3.05</Version>
</Schema>
<Parameters>
<Language>en-GB</Language>
<DecimalSeparator>.</DecimalSeparator>
View PurchaseOrderRequest.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="order.xslt"?>
<Order xmlns="urn:schemas-basda-org:2000:purchaseOrder:xdr:3.01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:schemas-basda-org:2000:purchaseOrder:xdr:3.01 order-v3.xsd urn:schemas-bossfed-co-uk:OP-Order-v1 OP-Order-v1.xsd">
<OrderHead>
<Schema>
<Version>3.05</Version>
</Schema>
<Parameters>
<Language>en-GB</Language>
<DecimalSeparator>.</DecimalSeparator>
View resolver.ex
def me(_, _, %{context: %{current_user: user}}),
do:
{:ok,
%{
user: user,
token: Phoenix.Token.sign(PhoenixAbsintheAuthenticatedSubscriptionsWeb.Endpoint, "user sesion", user.id)
}}
View worker.ex
def handle_info(:reschedule, state) do
Accounts.list_users()
|> Enum.map(fn %{id: id} ->
Absinthe.Subscription.publish(PhoenixAbsintheAuthenticatedSubscriptionsWeb.Endpoint, Enum.random(1..10),
accounts_user_count: "user_count:#{id}"
)
end)
schedule_user_worker()
View subscription.ex
object :accounts_subscriptions do
field :accounts_user_count, :integer do
config(fn
_args, %{context: %{current_user: %{id: user_id}}} ->
{:ok, topic: "user_count:#{user_id}"}
_args, _context ->
{:error, Responses.get(:user_unauthorized)}
end)
View user_socket.ex
def connect(%{"token" => token}, socket) do
with {:ok, user_id} <-
Phoenix.Token.verify(PhoenixAbsintheAuthenticatedSubscriptionsWeb.Endpoint, "user sesion", token,
max_age: 86_400
),
%Accounts.User{} = current_user <- Accounts.lookup_user(user_id) do
socket =
Absinthe.Phoenix.Socket.put_options(socket,
context: %{
current_user: current_user
View Graphiql - subscription article.json
{
"key": "graphiql",
"lastId": 4,
"tabIds": [
"tab1",
"tab2",
"tab3",
"tab4"
],
"closedTabs": [],
View static_website_s3_with_cloud_front.yaml
AWSTemplateFormatVersion: "2010-09-09"
Description: "Static website hosting with S3 and CloudFront"
Parameters:
BucketName:
Type: String
Default: "a-proper-bucket-name"
Resources:
# Create the bucket to contain the website HTML
View static_website_s3_cloud_front.yaml
AWSTemplateFormatVersion: "2010-09-09"
Description: "Static website hosting with S3 and CloudFront"
Parameters:
BucketName:
Type: String
Default: "a-proper-bucket-name"
Resources:
# Create the bucket to contain the website HTML
View starter_worker.ex
defmodule MyApp.StarterWorker do
@moduledoc """
Start lost children
"""
use GenServer
def start_link() do
GenServer.start_link(__MODULE__, [])
end
You can’t perform that action at this time.