Skip to content

Instantly share code, notes, and snippets.

@dsasse07
dsasse07 / heapify.js
Last active Jun 22, 2021
MaxHeap with heapify & Heap sort
View heapify.js
class MaxHeap {
constructor(arr = []){
this.size = 0
this.values = this._heapify(arr)
}
insert(value){
// If no value, do nothing
if (value === undefined) return
// Insert the value, and increment the size of the heap
@dsasse07
dsasse07 / maxHeap.js
Last active Aug 4, 2021
Javascript Max Heap Implementation
View maxHeap.js
class MaxHeap {
constructor(){
this.values = []
this.size = 0
}
insert(value){
// If no value, do nothing
if (value === undefined) return
// Insert the value, and increment the size of the heap
@dsasse07
dsasse07 / socialShare.js
Last active May 19, 2021
Share Feature Implementation - Share Action Button display Floating Action Buttons with Social Share Links
View socialShare.js
import "./styles.css";
import styled from "styled-components";
import LinkedInIcon from "@material-ui/icons/LinkedIn";
import FacebookIcon from "@material-ui/icons/Facebook";
import TwitterIcon from "@material-ui/icons/Twitter";
import MailOutlineIcon from "@material-ui/icons/MailOutline";
import SmsIcon from "@material-ui/icons/Sms";
import ShareIcon from "@material-ui/icons/Share";
import { useState } from "react";
@dsasse07
dsasse07 / README.md
Created Mar 16, 2021 — forked from ihollander/README.md
Rails API Setup
View README.md

Rails API Setup

Environment Setup

Make sure you are running a Ruby version supported by Heroku to make your app easier to deploy later. At the time of writing, that is:

  • 2.6.6
  • 2.7.2
  • 3.0.0
@dsasse07
dsasse07 / log-generator.js
Last active Mar 8, 2021
Storing functions in Objects for Abstract invocation
View log-generator.js
// Using Conditionals
const newMessage = {type: "error", message: "You still haven't squished the bugs!"}
const generateLog = newMessage => {
if (newMessage.type === "warn" {
Log.warn(newMessage.message)
} else if (newMessage.type === "error" {
Log.error(newMessage.message)
} else if (newMessage.type === "notify" {
@dsasse07
dsasse07 / JS-variable-object-keys.js
Created Mar 8, 2021
Calling Object keys using variables in JS
View JS-variable-object-keys.js
const greetings = {
english: "hello",
spanish: "hola"
}
const langChoice = "spanish"
greetings.english //=> "hello"
greetings[langChoice] //=> "hola"
@dsasse07
dsasse07 / js-log-class.js
Created Mar 8, 2021
Log message generator class
View js-log-class.js
export class Log {
static error(msg){
let date = new Date();
let time = date.toLocaleTimeString();
return {type: 'error', msg: `[${time}] ERROR: ${msg}`}
}
static warn(msg){
let date = new Date();
let time = date.toLocaleTimeString();
@dsasse07
dsasse07 / sudoku-full.rb
Last active Feb 18, 2021
OO Sudoku Board generator & solver - Basis for my sudoku_wizard gem
View sudoku-full.rb
class Sudoku
attr_accessor :starting_board, :solution, :removed_values, :difficulty
BLANK_BOARD = [
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
View sudoku-full.js
const BLANK_BOARD = [
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0]
@dsasse07
dsasse07 / sudoku-initialize-functions.js
Last active Feb 17, 2021
Sudoku initialize functions
View sudoku-initialize-functions.js
const newSolvedBoard = _ => {
startTime = new Date
// Create an unaffiliated clone of a fresh board
const newBoard = BLANK_BOARD.map(row => row.slice() )
// Populate the board using backtracking algorithm
fillPuzzle(newBoard)
return newBoard
}