Skip to content

Instantly share code, notes, and snippets.

@sammachin
sammachin / playlist_titles.py
Last active September 14, 2018 11:11
Short script to print all the titles in a YouTube Playlist
import requests
playlist = "XXXXXXX" #Playlist ID from URL eg https://www.youtube.com/playlist?list=PL1Hr6VkuONaE4XM52ThiV-s3vXAUT0JCR
key = "XXXXXXXX" # Your YouTube API Key from https://console.developers.google.com/apis/credentials
params = {"part" : "snippet", "maxResults" : 50, "playlistId": playlist, "key" : key}
url = "https://www.googleapis.com/youtube/v3/playlistItems"
items = []
r = requests.get(url, params=params)
rdata=r.json()
@sammachin
sammachin / install.sh
Created April 30, 2018 13:25
Node building blocks webhook prereqs
npm install express
npm install body-parser
@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") = "🇺🇸"