Skip to content

Instantly share code, notes, and snippets.

😎
When in doubt, log it out

Brian Flannery bflannery

😎
When in doubt, log it out
Block or report user

Report or block bflannery

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am bflannery on github.
  • I am bflanneryatx (https://keybase.io/bflanneryatx) on keybase.
  • I have a public key ASCZM5oBZsOAVNP9U1OgIwdKOlCJ08g2peWYNeiuiw1ODwo

To claim this, I am signing this object:

@bflannery
bflannery / sameFrequency.js
Created Feb 3, 2019
Frequency Counter Challenge - sameFrequency
View sameFrequency.js
// Frequency Counter - sameFrequency
// Write a function called sameFrequency. Given two positive intergers,
// find out if the two numbers have the same frequency of digits.
// Solution Requirements
// - Time Complexity: O(n)
function sameFrequency(int1, int2) {
const int1Arr = Array.from(int1.toString()).map(Number);
View es6_hash_table.js
class HashTable {
constructor(size) {
this.buckets = Array(size);
this.numBuckets = this.buckets.length;
}
hash() {
var total = 0;
for (var i = 0; i < key.length; i++) {
total += key.charCodeAt(i);
View binary_search_tree.js
class BST {
constructor(value) {
this.value = value;
this.left = null;
this.right = null;
}
insert(value) {
if (value <= this.value) {
if (!this.left) this.left = new BST(value);
View es6_linked_list.js
class LinkedList {
constructor() {
this.head = null;
this.tail = null;
}
addToHead(value) {
let newNode = new Node(value, this.head, null);
if (this.head) this.head.prev = newNode;
else this.tail = newNode;
View stack.js
const _items = new WeakMap()
class Stack {
constructor(value) {
_items.set(this, []);
}
push(value) {
_items.get(this).push(value);
}
View async_currency_converter.js
const getExchangeRate = async (from, to) => {
try {
const apiKey = '' // Add unique fixer.io apiKey
const response = await axios.get(`http://data.fixer.io/api/latest?access_key=${apiKey}&format=1`)
const euro = 1 / response.data.rates[from];
const rate = euro * response.data.rates[to];
if (isNaN(rate)) {
throw new Error()
}
View input-example.component.ts
@Component({
selector: 'friend-tour',
template: `
<input #newFriend
(keyup.enter)="addFriend(newFriend.value)"
(blur)="addFriend(newFriend.value); newFriend.value='' ">
<button (click)="addFriend(newFriend.value)">Add</button>
<ul><li *ngFor="let friend of friends">{{friends}}</li></ul>
@bflannery
bflannery / sumTwoSmallestNumbers.js
Created Jan 20, 2017
return the sum of the two smallest positive integers
View sumTwoSmallestNumbers.js
// return the sum of the two smallest positive integers
function sumTwoSmallestNumbers(numbers) {
let sorting = numbers.sort((a,b) => {
if(a > b) {
return a;
}
});
return sorting[0] + sorting[1];
@bflannery
bflannery / returnATriangle.js
Created Jan 20, 2017
Give 3 integers, will they make a triangle
View returnATriangle.js
// Give 3 integers, will they make a triangle
function isTriangle(a,b,c){
if(a+b > c && a+c > b && b+c > a) {
return true;
} else {
return false;
}
}
You can’t perform that action at this time.