Skip to content

Instantly share code, notes, and snippets.

@toraritte
toraritte / the-union.js
Last active May 4, 2020 02:43
Short script to normalize the articles of the Nevada City/Grass Valley Union
/*
There are about 12 <article> HTML tags on each news
article page, and none of them are explicitly marked
as the main one (which would make sense because the
URL of this page is explicitly for this article; the
rest are just offered for extra navigation).
Therefore the below assignment is on shaky legs,
because I'm just assuming that the first <article>
@toraritte
toraritte / currying-erlang.md
Last active February 20, 2020 21:12
Currying in Erlang
-module(f).
-export([curry/1]).

curry(AnonymousFun) ->
    {arity, Arity} =
        erlang:fun_info(AnonymousFun, arity),

    do_curry(AnonymousFun, Arity, [[], [], []]).

do_curry(Fun, 0, [Fronts, Middle, Ends] = X) ->

@toraritte
toraritte / FreeSWITCH-notes.md
Last active May 13, 2023 06:06
FreeSWITCH notes (and Stackoverflow backup)

TODO Start saving posts off Stackoverflow, and only contribute conservatively.

What is the purpose of FreeSWITCH's mod_esl?

There is [another question][1] trying to figure out the connection between mod_event_socket and the Event Socket Library (ESL).

The [Event Socket Library][2] itself is a C library ([libesl][3]) that can be used to build external C applications to control FreeSWITCH via its [event system][4].

As far as I understand, [mod_esl][5] is only a FreeSWITCH module wrapper around [libesl][3], used to extend programming languages with the same functionality (i.e., to control a FreeSWITCH instance). The [documentation][5] doesn't mention this, but basing this assumption on the quoted sources below, and on the fact that I couldn't find anyone ever using it directly (i.e., found no mailing list question, nothing on slack, no SO questions, no blog posts, [the books][6] also barely mention it, and so on). Are there any other use cases that I'm missing?

Attila Gulyas 10:48 AM hi, if we'd like to have callers control audio playback during a call, we would use the relevant mod_commands (such as uuid_fileman perhaps?), bound to DTMF key strokes (like here: https://lists.freeswitch.org/pipermail/freeswitch-users/2013-January/091183.html ), right? For context: this is for a system for blind users to listen to articles recorded by volunteers.

Joshua Young 11:01 AM via the dialplan, dial *1 thru *3 on leg

<action application="bind_meta_app" data="1 b s playback::file1.wav"/>
<action application="bind_meta_app" data="2 b s playback::file1.wav"/>
<action application="bind_meta_app" data="3 b s playback::file1.wav"/>
@toraritte
toraritte / conf-dir_dialplan_default_ext_fsm_erlang.xml
Created November 22, 2019 21:45
A mirror of the code from Seven Du's post "Build a complex hence powerful FreeSWITCH IVR in Erlang".
<extension name="icall_fsm">
<condition field="destination_number" expression="^fsm$">
<action application="erlang" data="icall:fsm [email protected]"/>
</condition>
</extension>
@toraritte
toraritte / gce-firewall-postgres.md
Created September 10, 2019 00:38
gce firewall postgres

[PostgreSQL must also be configured to allow remote connections][1], otherwise the connection request will fail, even if all firewalls rules are correct and PostgreSQL server is listening on the right port.

Steps

1. IP addresses

To connect from your laptop, you will need the public IP address of your laptop, and that of the Google Compute Engine (GCE) instance.

1.1 Your laptop's public IP address

@toraritte
toraritte / gce-firewall-ingress-egress-source-destination-target.md
Created June 20, 2019 22:21
Summary of GCE firewall terms ingress, egress, source, destination, and targets
@toraritte
toraritte / configure-postgres-to-allow-remote-connection.md
Last active September 4, 2023 01:06
Configure PostgreSQL to allow remote connections

Configure PostgreSQL to allow remote connections

NOTE: This post is a personal update to Neeraj Singh's post. [PostgreSQL must also be configured to allow remote connections][1], otherwise the connection request will fail, even if all firewalls rules are correct and PostgreSQL server is listening on the right port.

Steps

Outline

Couldn't create links, but this is a rather long answer so this may helps.

<extension name="SignalWire CONNECTORS incoming call">
<condition field="destination_number" expression="^(\+15555161718)$"/>
<condition regex="any">
<regex field="ani" expression="^(\+15550123456)$"/>
<regex field="ani" expression="^(\+15557891011)$"/>
<regex field="ani" expression="^(\+15551213141)$"/>
<action application="answer"/>
<action application="ivr" data="demo_ivr"/>
</condition>
@toraritte
toraritte / freeswitch-dialplan.xml
Created June 11, 2019 18:30
Whitelist registered numbers only (naive try)
<extension name="SignalWire CONNECTORS incoming call">
<!-- the number you assigned in your SignalWire dashboard -->
<condition field="destination_number" expression="^(\+15550123456)$"/>
<condition field="ani" expression="^(\+15557891011)$">
<!-- <condition field="ani" expression="^(\+15551213141)$"> -->
<action application="answer"/>
<action application="ivr" data="demo_ivr"/>
</condition>
</extension>