Skip to content

Instantly share code, notes, and snippets.

View hmm29's full-sized avatar

hmm29

  • YouTube
  • United States
View GitHub Profile
@hmm29
hmm29 / twilio-problem-code.js
Last active September 14, 2018 01:44
I need help figuring out why this is causing a Firebase bug in prod
_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());
'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)
/**
* 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)
@hmm29
hmm29 / sorts.js
Last active April 29, 2017 23:56
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++) {
function calculateHeight(root) {
if(root === null) {
return 0;
}
// base case: root is a leaf node
if(!root.left && !root.right) {
return 1;
}
@hmm29
hmm29 / Bo5u-0.bf
Created February 20, 2016 01:06 — forked from anonymous/Bo5u-0.bf
https://repl.it/Bo5u/0 created by anonymous
++++++++++
[
> +++++++
> ++++++++
<< -
]
> ++ .
------- .
> ++ . .
< ++++++++ .
@hmm29
hmm29 / gist:1f872a3af26ab2e4f0e1
Created May 4, 2015 00:43
How to assign quotes to users in InstaQuote
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
@hmm29
hmm29 / SassMeister-input-HTML.haml
Created September 9, 2014 06:35
Generated by SassMeister.com.
- (1..51).each do |i|
%div{:class => "item-#{i}"}
@hmm29
hmm29 / SassMeister-input-HTML.html
Created September 8, 2014 04:50
Generated by SassMeister.com.
<h1>Hello, Harrison!</h1>