Skip to content

Instantly share code, notes, and snippets.

function createRTCPeerConnection(){
connection = new RTCPeerConnection(configuration);
// Add both video and audio tracks to the connection
for (const track of localStream.getTracks()) {
log("Sending Stream.")
existingTracks.push(connection.addTrack(track, localStream));
}
// This event handles displaying remote video and audio feed from the other peer
function createAndSendOffer(){
if(channel){
channel.close();
}
// Create Data channel
channel = connection.createDataChannel('channel', {});
setChannelEvents(channel);
// Create Offer
#%% gradient descent
# ***********************************************************
def run_gradient_descent(func, initial_point, gradients, verbose=False):
"""
Simple implementation of gradient descent for a convex function of 2 arguments.
Arguments:
func: the function of 2 variables to minimize
initial_point: a 2D tuple representing the initial point
@Amit2016-17
Amit2016-17 / genSankey
Created February 2, 2020 09:29 — forked from ken333135/genSankey
Wrapper Function to create Sankey Diagram from DataFrame
def genSankey(df,cat_cols=[],value_cols='',title='Sankey Diagram'):
# maximum of 6 value cols -> 6 colors
colorPalette = ['#4B8BBE','#306998','#FFE873','#FFD43B','#646464']
labelList = []
colorNumList = []
for catCol in cat_cols:
labelListTemp = list(set(df[catCol].values))
colorNumList.append(len(labelListTemp))
labelList = labelList + labelListTemp
@elktros
elktros / Raspberry_Pi_DHT_11.py
Created February 21, 2018 09:13
Python Script for Interfacing DHT11 Humidity and Temperature Sensor with Raspberry Pi.
import sys
import Adafruit_DHT
import time
while True:
humidity, temperature = Adafruit_DHT.read_retry(11, 4)
print 'Temp: {0:0.1f} C Humidity: {1:0.1f} %'.format(temperature, humidity)
time.sleep(1)