Skip to content

Instantly share code, notes, and snippets.

View wiserfirst's full-sized avatar
🎯
Focusing

Qing Wu wiserfirst

🎯
Focusing
  • Australia
View GitHub Profile
@wiserfirst
wiserfirst / push_credential.md
Last active July 20, 2022 07:17
Create a mobile_push_credential and associate it with a SIP connection via API

Create new mobile_push_credential

Once you've obtained the certificate and private key for iOS (you can follow this guide for that), you can create a new iOS push_credential with the following request:

curl -X "POST" "https://api.telnyx.com/v2/mobile_push_credentials" \
     -H 'Authorization: Bearer <my-telnyx-api-key>' \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d '{
  "certificate": "<my-iOS-Certificate>",

How to create a Slash command

  1. Create a Slack app on https://api.slack.com/apps
  2. Create a new Slash command in app management on Slack. A number of fields to fill out, but most important are:
    • Command name: what the user should type after /
    • Request URL: URL of the Slack app backend. When the user do type the command, Slack will send a POST request to the Request URL. It needs to be publicly accessible and it needs to be able to handle the requests from Slack.
  3. Sample request from Slack
  %{
#!/usr/bin/env bash
chromedriver_path=$(command -v chromedriver)
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) chrome_path="/usr/bin/google-chrome";;
Darwin*) chrome_path="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";;
esac
chromedriver_version=$("${chromedriver_path}" --version)
@wiserfirst
wiserfirst / video-composition.md
Last active March 2, 2022 04:55
How to start a video composition

How to start a video composition

Create or update room

One can create a room with recording enabled and a webhook_event_url using the following request:

curl -X "POST" "https://api.telnyx.com/v2/rooms" \
     -H 'Authorization: Bearer <my-telnyx-api-key>' \
     -H 'Content-Type: application/json; charset=utf-8' \
@wiserfirst
wiserfirst / video-converter.rb
Created June 20, 2021 22:37
Convert/compress videos in a directory with ffmpeg
#!/usr/bin/env ruby
require 'shellwords'
def usage
puts <<~HEREDOC
Usage:
./video-converter.rb [dir]
to convert mov/avi files to mp4 with H.264 video codec and AAC audio codec"
HEREDOC
const encode64 = str => Buffer.from(str).toString('base64')
describe('base64 encoding comparison', () => {
const triggerId = 'direct1'
const fulfilmentType = 'ClickandCollect'
const orderId = '000000123'
const string = `{"property-value-westfield_direct_trigger_id":["${triggerId}"],"property-value-westfield_direct_received_fulfilment_type":["${fulfilmentType}"],"property-value-westfield_direct_received_order_id":["${orderId}"]}`
it('should produce same result', () => {
const encoded = encode64(string)
def hello
src = File.open('/Users/wiser/Downloads/sample.avro', 'rb')
dst = File.open('/Users/wiser/Downloads/dest.avro', 'wb')
# p get_events(file)
data_reader =
Avro::DataFile::Reader.new(src, Avro::IO::DatumReader.new)
record = data_reader.first
schema = Avro::Schema.parse(data_reader.meta["avro.schema"])
# Creates DatumWriter instance with required schema.
writer = Avro::IO::DatumWriter.new(schema)

Keybase proof

I hereby claim:

  • I am wiserfirst on github.
  • I am wiserfirst (https://keybase.io/wiserfirst) on keybase.
  • I have a public key ASAt6O_wdsd5pJH5ZqKcWiuFwrVOjYi0fxpNxNlfVyZIOAo

To claim this, I am signing this object:

@wiserfirst
wiserfirst / results.md
Last active April 6, 2018 01:30
staging benchmark

Naive Approach

product 10,000 events time (second) total events total time (hour)
MS 87.7 11,518,770 28.1
RE 106.8 62,502,979 185.4
REJR 63.3 3,801,180 6.7
REX 105.4 42,040,956 123.1
WF 85.3 1,643,635 3.9

With Repo.stream

@wiserfirst
wiserfirst / Program.cs
Last active March 6, 2018 23:25
Dynamics test program
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PP.CRM.PascalMessage.Tester
{
class Program
{