Skip to content

Instantly share code, notes, and snippets.

@oliverbth05
oliverbth05 / Index.html
Last active May 15, 2018 15:16
Line chart accepting JS Date object (Vue)
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js"></script>
</head>
<body>
<div id = "app">
<canvas id = "lineChart"></canvas>
<div>
@oliverbth05
oliverbth05 / App.js
Last active May 18, 2018 19:44
Budget Managin Functionality (vue)
new Vue({
el: "#app",
data: {
entries: [],
amount :"",
date :"",
input2: "",
setBudget: 400
},
@oliverbth05
oliverbth05 / app.css
Created May 31, 2018 15:49
Navigation Side Drawer
*{
padding: 0;
margin: 0;
font-family: 'Lato', sans-serif;
}
/* The sidebar menu */
.sidenav {
height: 100%; /* Full-height: remove this if you want "auto" height */
width: 150px; /* Set the width of the sidebar */
position: fixed; /* Fixed Sidebar (stay in place on scroll) */
@oliverbth05
oliverbth05 / app.js
Last active June 5, 2018 20:44
Mobile-Friendly Navigation (Vue)
new Vue({
el:"#app",
data: {
navDrawer: false
},
methods: {
showDrawer: function(){
this.navDrawer = !this.navDrawer;
},
dismissDrawer: function(){
@oliverbth05
oliverbth05 / gist:6f78568e06f367d32f27f9a1c73687fd
Last active August 22, 2018 12:48
Javascript Bubble Sort
function bubbleSort(arr){
let sortOccurred = true;
while (sortOccurred === true) {
for(var i = 0; i < arr.length; i++){
if (arr[i] > arr[i + 1]) {
var a = arr[i];
arr[i] = arr[i + 1];
@oliverbth05
oliverbth05 / gist:3889afbf8c33e81c515534548a482bca
Created August 22, 2018 13:19
Javascript Fibonacci Sequence
function generateFibonacci(length){
let sequence = [1];
for(var i = 1; i <= length; i++){
if (sequence.length === 1) {
sequence[i] = 1
}
else{
sequence[i] = sequence[i-1] + sequence[i - 2]
@oliverbth05
oliverbth05 / gist:8fd2cf91594135f9579ad865f26a40e6
Created August 27, 2018 12:55
Array: Find sum of two numbers
function findSum(arr, sum) {
var i = 0;
var j = arr.length-1;
var complete = false;
while (complete === false) {
if(arr[i] + arr[j] === sum) {
complete = true;
return [arr[i], arr[j]];
@oliverbth05
oliverbth05 / Binary Search.js
Last active August 28, 2018 15:27
Binary Search JS
function binarySearch(arr, elem) {
var start = 0;
var end = arr.length - 1;
var middle = Math.floor((start + end) / 2);
while(arr[middle] !== elem && start <= end) {
if(elem < arr[middle]){
end = middle - 1;
@oliverbth05
oliverbth05 / Find Substring.js
Created August 28, 2018 18:05
Find Substring
function subStr(str, sub) {
let i = 0;
let j = 0;
let collected = '';
let counter = 0;
let complete = false;
while (complete === false) {
@oliverbth05
oliverbth05 / Selection Sort JS
Created August 29, 2018 13:32
Selection Sort JS
function selectionSort(arr) {
let currentMin = 0;
let newMin = 0;
let complete = false;
while (!complete) {
for (var i = currentMin; i < arr.length; i++) {