Skip to content

Instantly share code, notes, and snippets.

@connor11528
connor11528 / binarySearch.js
Last active May 20, 2018 20:15
Binary search for finding an element's index in a sorted array using Javascript.
function binarySearch(arr, target) {
let left = 0;
let right = arr.length - 1;
while (left <= right) {
const mid = left + Math.floor((right - left) / 2);
if (arr[mid] === target) {
return mid;
}
if (arr[mid] < target) {
left = mid + 1;
@connor11528
connor11528 / binarySearchTree.js
Last active July 13, 2020 05:31
Binary search tree implemented in Javascript
class BinarySearchTree {
constructor(){
this.root = null;
}
// add a node to the tree
add(value){
let newNode = { value, left: null, right: null};
@connor11528
connor11528 / fibonacci.js
Created January 3, 2018 01:20
Recursive solution to Fibonacci series in Javascript
// 1, 1, 2, 3, 5, 8
function fib(n){
if(n < 2) return n;
return fib(n - 1) + fib(n - 2);
}
@connor11528
connor11528 / app\Http\Middleware\IsAdmin.php
Created March 1, 2018 13:39
Middleware to check if user is an admin in Laravel 5
<?php
namespace App\Http\Middleware;
use Closure;
class IsAdmin
{
/**
* Handle an incoming request.
*
@connor11528
connor11528 / app\Http\Controllers\AdminController.php
Created March 1, 2018 13:48
Admin controller that invokes custom middleware to protect a route
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class AdminController extends Controller
{
public function __construct()
{
$this->middleware('auth');
@connor11528
connor11528 / ScapeGreenhouse.php
Last active January 6, 2024 21:50
Artisan command to scrape jobs from Greenhouse.io
<?php
namespace App\Console\Commands;
use App\Company;
use App\JobListing;
use Illuminate\Console\Command;
use Goutte\Client;
class ScrapeGreenhouse extends Command
@connor11528
connor11528 / JobListingList.vue
Created August 1, 2018 23:44
render and search a list with Vue.js
<template>
<section>
<input type="text" class="form-control" placeholder="Search by job title" v-model="searchTerm">
<div class="list-group mt-2" :style="{ height: this.search_window_height + 'px' }">
<div class="list-group-item list-group-item-action flex-column align-items-start" v-for="jobListing in filteredJobListings">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">
{{ jobListing.title }}
@connor11528
connor11528 / CompaniesMap.vue
Last active August 1, 2018 23:51
Employbl companies map
<template>
<div id="companies-map-container">
<div id="companies-map" class="h-500"></div>
</div>
</template>
<style scoped>
#companies-map {
margin: 0 auto;
background: gray;
@connor11528
connor11528 / CandidateProfileForm.vue
Last active January 20, 2019 21:23
Form for the update candidate job search profile on Employbl
<template>
<div class="row">
<div class="col-7 offset-2">
<div class="row">
<div class="col-md-12 mb-3">
<label>Summary</label>
<textarea class="form-control" v-model="candidateInfo.summary"
placeholder="What do you like to do?"></textarea>
<div v-if="errors && errors.summary" class="text-danger">{{ errors.summary[0] }}</div>
</div>
@connor11528
connor11528 / CandidateController.php
Last active January 20, 2019 21:22
Laravel backend for adding tags to the Employbl candidate application
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
use Spatie\Tags\Tag;
class CandidateController extends Controller
{