This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function createAndSendOffer(){ | |
| if(channel){ | |
| channel.close(); | |
| } | |
| // Create Data channel | |
| channel = connection.createDataChannel('channel', {}); | |
| setChannelEvents(channel); | |
| // Create Offer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #%% 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |