Skip to content

Instantly share code, notes, and snippets.

@sammachin
sammachin / install.sh
Created April 30, 2018 12:19
Python Nexmo Client pre-reqs
pip install nexmo
@sammachin
sammachin / install.sh
Created April 30, 2018 10:54
python webhook pre-requisites
pip install ‘flask>=1.0’
var handlers = {
'LaunchRequest': function () {
this.emit('SayHello');
},
'SayHello': function(){
if (this.event.user.hasOwnProperty('accessToken')) {
this.response.speak('Hello User');
this.emit(':responseReady');
}
else {
var handlers = {
'LaunchRequest': function () {
this.emit('SayHello');
},
'SayHello': function(){
if (this.event.user.hasOwnProperty('accessToken')) {
this.response.speak('Hello User');
this.emit(':responseReady');
}
else {
@sammachin
sammachin / downsample.js
Created December 1, 2017 09:57
Node Downsample 16Khz > 8Khz
// Downsample frames from 16Khz to 8Khz
function convert(message){
var arr = []
var x = 0;
var y;
var i;
for (i = 0; i < 160; i++) {
y = x+2
arr.push(message.slice(x,y))
x += 4;
@sammachin
sammachin / gist:65280ae9eedcbdff83795b5bb5e9f51f
Created October 16, 2017 12:04
raw.githubusercontent.com SSL Cert
Sams-iMac:~ smachin$ openssl s_client -connect raw.githubusercontent.com:443
CONNECTED(00000003)
depth=1 /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 High Assurance Server CA
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
0 s:/C=US/ST=California/L=San Francisco/O=GitHub, Inc./CN=www.github.com
i:/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 High Assurance Server CA
1 s:/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 High Assurance Server CA
@sammachin
sammachin / client.js
Created March 14, 2017 20:59
WTF JSON?
ptt_btn.onmousedown = function(e){
ptt=true;
document.getElementById("tx").innerHTML=status_tx;
if(ws.readyState == ws.OPEN) {
var evt = '{"event": "ptt_on"}';
ws.send(JSON.stringify(evt));
}
}
@sammachin
sammachin / country_code_to_emoji_extras.py
Created October 21, 2016 19:59 — forked from linville/country_code_to_emoji_extras.py
Django template converts country code to Emoji
from django import template
register = template.Library()
OFFSET = ord('🇦') - ord('A')
@register.filter
def flag(code):
return chr(ord(code[0]) + OFFSET) + chr(ord(code[1]) + OFFSET)
# Example:
# flag("US") = "🇺🇸"
@sammachin
sammachin / nexmo-jwt
Last active October 3, 2016 14:49
Generate CAPI JWT's from Command Line
#!/usr/bin/python
import sys
import json
import requests
from datetime import datetime
from base64 import urlsafe_b64encode
import os
import calendar
from jose import jwt
@sammachin
sammachin / unicode_sms.py
Created August 26, 2016 13:37
Sending Amharic Characters with Nexmo using Unicode and Python
import nexmo
#Add Your Nemxo Details and Mobile Number here
nexmo_key='XXX'
nexmo_secret='XXX'
to = 'XXX'
client = nexmo.Client(key=nexmo_key, secret=nexmo_secret)
#First test shows the result of not setting Unicode