This file contains 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
_handleLocalParticipantTracks(room) { | |
const localParticipant = room.localParticipant, | |
localParticipantTracks = localParticipant.tracks, | |
remoteParticipants = room.participants; | |
this.setState({ localParticipant }); | |
localParticipantTracks.forEach(track => { | |
document.getElementById('local-media-div').appendChild(track.attach()); |
This file contains 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
'use strict'; | |
/** | |
* Go through linked list and stop at N-1th node | |
* Remove next node | |
* Cases: remove head, remove middle node, remove last node, N > length of list, N < 1, and list is empty | |
* | |
* N = |list| | |
* Time: O(N) | |
* Additional space: O(1) |
This file contains 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
/** | |
* Find the common elements of 2 int arrays | |
* | |
* can i assume only unique elements in both arrays? | |
* do the counts have to be the same too? | |
* all types of ints right? | |
* | |
* Solution 1: for each element in arr1, check arr2 => O(nm), where n is arr1 and m is arr2 | |
* Solution 2: sort n and m, then do binary search for each elt in shorter array => O(nlogn + mlogm) | |
* Solution 3: use a hash set to keep track of elements in both => O(n + m), O(n) |
This file contains 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 bubbleSort(arr) { | |
// todo: error checks (empty array, 1 elt, etc.) | |
if(!Array.isArray(arr)) return -1; | |
if(arr.length <= 1) return arr; | |
// main idea: iterate through array, moving | |
// each element to higher index until no inversions | |
for(let i = 0; i < arr.length-1; i++) { | |
for(let j = i+1; j < arr.length; j++) { |
This file contains 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 calculateHeight(root) { | |
if(root === null) { | |
return 0; | |
} | |
// base case: root is a leaf node | |
if(!root.left && !root.right) { | |
return 1; | |
} |
This file contains 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
++++++++++ | |
[ | |
> +++++++ | |
> ++++++++ | |
<< - | |
] | |
> ++ . | |
------- . | |
> ++ . . | |
< ++++++++ . |
This file contains 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
Accounts.onCreateUser(function (options, user) { | |
// assign options.profile object to user.profile, set first and last name fields | |
if (typeof(options.profile) !== "undefined") { | |
user.profile = options.profile; | |
user.profile.firstName = user.profile.name.split(" ")[0]; | |
user.profile.lastName = user.profile.name.split(" ")[1]; | |
} | |
// for account creation using accounts-facebook package |
This file contains 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
- (1..51).each do |i| | |
%div{:class => "item-#{i}"} |
This file contains 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
<h1>Hello, Harrison!</h1> |