Skip to content

Instantly share code, notes, and snippets.

View coreyd303's full-sized avatar
🐲

Corey Davis coreyd303

🐲
  • Remote
View GitHub Profile
@coreyd303
coreyd303 / storing_state
Last active August 29, 2015 14:05
Storing State in Sessions
1. What's the difference between a cookie and a session?
A cookie is a string of data that is set on response to be stored on client. It works as an encrypted data package used for managing communication.
A session is more like an object that exists on the request
2. What's serialization and how does it come into play with cookies?
Object --> string (Cookies serialize data)
3. Can a cookie be shared by more than one user? How/why?
Yes, if both users are on the same client. (But really shouldn't be)
1. What does it mean for an application to be multi-tenant?
2. What would you want to build an application to be multi-tenant?
3. How do you implement multi-tenancy at the data / database level?
4. How do Active Record scopes help keep tenant data segregated?
5. Why is multi-tenancy dangerous from a security/privacy perspective?
@coreyd303
coreyd303 / corey_davis
Created October 28, 2014 23:24
Corey Davis lightning talk gist
The idea of genius is often based on some unnatural skill or knowledge. But new science on the idea of mylination and deep practice pushes us to rethink this. I will be discussing this idea, and the application of it to programming as associated skills. Looking at specifically code kata, touch typing, and logical thinking. I don't know what else you want in a gist so...thats it.
@coreyd303
coreyd303 / NLP_snippets.swift
Created July 6, 2017 17:08
Natural language processing with swift
//Access to the new NSLinguisticTagger APIs are provided as a public enum as:
public enum NSLinguisticTagger: Int {
case word
case sentence
case paragraph
case document
}
//To see what units and schemes are available use a class level function:
@coreyd303
coreyd303 / mergeSort.swift
Last active June 1, 2020 21:37
SwiftyAlgos: Merge Sort
import UIKit
// Merge sort in Swift
// Split arrays
func mergeSort(array: [Int]) -> [Int] {
guard array.count > 1 else {
return array
func bubbleSort(array: [Int]) -> [Int] {
var array = array
for i in 0..<array.count {
for j in 1..<array.count - i {
if array[j] < array[j - 1] {
array.swapAt(j, j - 1)
}
}
}
struct Nucleotide {
private let validNucleotides = "ATCG"
private var errorMessage: ((Character) -> (String)) = { n in
return "\(n) is not a valid Nucleotide"
}
let dna: String
init(_ dna: String) {
import Foundation
func quickSort(array: inout [Int], low: Int, high: Int) {
// if the high index value is greater than the low index value we need to partition and sort
if high > low {
// determine our pivot index by generating partitions
let pi = partition(array: &array, low: low, high: high)
// recursively pass our upper and lower partitions back into quickSort using the new pivot index
quickSort(array: &array, low: low, high: pi - 1)
@coreyd303
coreyd303 / StructsSample.swift
Last active October 2, 2020 18:52
This is a code sample demonstrating the basics of Structs in Swift
struct Car {
let make: String
let model: String
var color: String
private(set) var mileage: Int? = 0
mutating func update(mileage: Int) {
self.mileage = mileage
}
@coreyd303
coreyd303 / graphicsCrash.crash
Created April 8, 2021 21:08
Crash report 4/21
panic(cpu 0 caller 0xffffff7f8b212498): "Graphics firmware encountered an exception (eip: 0xbd82, fault #: 0xd)\n"@skl/sched3/IGGuC.cpp:889Backtrace (CPU 0), Frame : Return Address0xffffff83c5b03b70 : 0xffffff800691963d 0xffffff83c5b03bc0 : 0xffffff8006a53ae5 0xffffff83c5b03c00 : 0xffffff8006a4566e 0xffffff83c5b03c50 : 0xffffff80068bfa40 0xffffff83c5b03c70 : 0xffffff8006918d07 0xffffff83c5b03d70 : 0xffffff80069190f7 0xffffff83c5b03dc0 : 0xffffff80070c01cc 0xffffff83c5b03e30 : 0xffffff7f8b212498 0xffffff83c5b03e80 : 0xffffff7f8b187ef6 0xffffff83c5b03ee0 : 0xffffff800702bc5d 0xffffff83c5b03f30 : 0xffffff800702a52e 0xffffff83c5b03f70 : 0xffffff8007029b26 0xffffff83c5b03fa0 : 0xffffff80068bf13e       Kernel Extensions in backtrace:         com.apple.driver.AppleIntelKBLGraphics(14.0.7)[D944342F-11C2-38F7-A113-412261DE3D36]@0xffffff7f8b186000->0xffffff7f8b27cfff            dependency: com.apple.iokit.IOPCIFamily(2.9)[017B6656-0279-38F7-917D-97CB6A21AC33]@0xffffff7f87312000            dependency: com.apple.iokit.IO