Skip to content

Instantly share code, notes, and snippets.

View chris-campbell's full-sized avatar
🏠
Working from home

Chris chris-campbell

🏠
Working from home
View GitHub Profile
@chris-campbell
chris-campbell / 02_assignment.md
Last active December 1, 2022 16:09
CSS Grid Layout
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>CSS Grid Layout</title>
    <style>
        body {

Can you tell us why the following Javascript code doesn’t work correctly?

How would you fix it?

Problem

function count() {
    let counter;

What is a Closure?

Closure is a function that is returned from a parent function that has preserved the parent functions state.

Curried Function Example

const saveTheDate = (groom) => {
@chris-campbell
chris-campbell / max_sort.py
Last active June 27, 2019 10:45
Sort Downloads folder files on Mac into individual folders based on given file extensions.
import glob, shutil, os
from IPython import embed
def final_destination(file_ext):
EXTENSIONS = [
'txt', 'pdf', 'zip', 'gz', 'pkg', 'bz2', 'dmg','csv', 'doc',
'docx', 'pls', 'mp3', 'mp4', 'mov','html', 'htm', 'torrent',
'iso', 'gem','erb', 'xlsx', 'rtf', 'xml', 'xps', 'gif', 'odt',
'ai', 'eps', 'js', 'py', 'rb', 'css', 'scss', 'png', 'jpg',
'epub', 'ind', "psd", 'jpeg', 'tiff', 'mpa', 'wav', 'wma', 'midi',
function firstRecurringChar(array) {
let box = {};
for(let i=0; i < array.length; i++) {
box[array[i]] = [array[i], 0];
}
for(let j = 0; j < array.length; j++) {
box[array[j]][1]++;
if (box[array[j]][1] == 2) {
return box[array[j]][0]
@chris-campbell
chris-campbell / linked_list.js
Created June 21, 2019 13:39
Revised linked list to make sure I understand how they function.
class Node {
constructor(value) {
this.value = value;
this.next = null;
}
}
class LinkedList {
constructor(value) {
this.head = {
$ git remote rm origin
$ git remote add origin [email protected]:aplikacjainfo/proj1.git
$ git config master.remote origin
$ git config master.merge refs/heads/master
@chris-campbell
chris-campbell / collatz_longest_sequence.rb
Last active October 3, 2018 17:48
Runs the collatz sequence and generates the longest sequence to integer provided as a argument.
def collatz(num)
sequence_item = []
sequences = []
num.downto(1) do |n|
sequence_item.push(n) unless sequence_item[0] == n
while (n != 1) do
value = n.even? ? n = (n / 2) : n = (n * 3) + 1
sequence_item.push(value)
end
sequences.push(sequence_item)
@chris-campbell
chris-campbell / fibonacci.rb
Created September 27, 2018 12:18
Generates fibonacci sequence when ran
def fibonacci(num)
previously_calculated = 1
current_value = 2
num.times do
save_value = current_value
p current_value = previously_calculated + save_value
previously_calculated = save_value
end
end
def uuid
characters = ("a".."f").to_a.concat((1..9).to_a)
uuid = ""
sequence = [8, 4, 4, 8, 12]
sequence.each do |i|
i.times { uuid += characters.sample.to_s }
uuid += "-" unless i == 12
end
uuid