Skip to content

Instantly share code, notes, and snippets.

@arjan
arjan / presence_bug.exs
Last active June 14, 2023 08:35
Test script for phoenix_pubsub issue #175
#!/usr/bin/env elixir
Mix.install([{:phoenix_pubsub, "== 2.1.2"}, :phoenix])
start_spec = fn(spec) ->
{m,f,a} = spec.start
apply(m,f,a)
end
{:ok, _} = Application.ensure_all_started(:phoenix_pubsub)
111111111111111111111111111111
100000100000000000000001000001
000101001111000000111100101000
101010000000100001000000010101
010010000000100001000000010010
100010000000011110000000010001
010010000000000000000000010010
101010000000000000000000010101
000101000000000000000000101000
100000100000000000000001000001
@arjan
arjan / live_acl.ex
Created March 7, 2023 11:13
LiveView ACL check example code
defmodule ExampleApp.Web.LiveAcl do
@moduledoc """
ACL checks for LiveView
```
use ExampleApp.Web.LiveAcl
```
Provides an `on_mount` hook to do ACL checks on mount, for instance
to ensure the current user has access to a given invoice ID.
@arjan
arjan / example_receive_server.ex
Created February 7, 2023 09:57
Example on how to receive email in Elixir
defmodule MyApp.ReceiveServer do
@behaviour :gen_smtp_server_session
require Logger
# how many simultaneous SMTP sessions
@max_sessions 20
# max email message size
@maxsize 200 * 1024 * 1024
@arjan
arjan / absintheSocketLink.ts
Created July 21, 2022 12:24
Replacement for @absinthe/socket-apollo-link package
@arjan
arjan / toggle-headset-profile.sh
Created April 13, 2022 07:23
Sony WH-1000X bluetooth profile switcher
#!/bin/bash
set -e
CARD=$(pactl list | grep bluez_card | awk -F ': ' '{print $2}')
A=a2dp-sink-ldac
B=headset-head-unit
PROFILE=$(pactl list |grep 'Active Profile' | tail -n 1 | awk -F': ' '{print $2}')
~
▶ curl -X POST https://bsqd.me/phone/webhook/736e85d2-8654-4ec5-ac53-2893e1f2b2fa/31641322599/call1 -d '{}' -H 'Content-type: application/json'
{"is_final":false,"locale":"en","ssml":"<speak><s>Hello this is a bot <break time=\"1500ms\"/> </s><s>What is your name?</s></speak>","tts":null,"voice":{"gender":"FEMALE","locale":"en","name":"en-GB-Wavenet-A","preview_url":"https://cloud.google.com/text-to-speech/docs/audio/en-GB-Wavenet-A.wav","type":"google"}}%
~
~
~
defmodule DynamicSupervisorDeadlockTest do
require Logger
use ExUnit.Case
alias Horde.DynamicSupervisor
setup do
n1 = :"horde_#{:rand.uniform(100_000_000)}"
{:ok, horde_1_sup_pid} =
@arjan
arjan / App.js
Last active September 29, 2020 11:21
Botsquad webview react native demo
import React, { useRef } from "react";
import { Button, StyleSheet, View } from "react-native";
import { WebView } from "react-native-webview";
const userId = "myuserid";
const botHost = "robin.staging.bsqd.me";
export default function App() {
const webviewRef = useRef();
@arjan
arjan / eagi_stt_to_tts.go
Last active June 17, 2020 06:52
EAGI speech to text
// (c) Arjan Scherpenisse 2020, License: MIT
package main
import (
"context"
"fmt"
"io"
"io/ioutil"
"time"