Skip to content

Instantly share code, notes, and snippets.

View coreyd303's full-sized avatar
🐲

Corey Davis coreyd303

🐲
  • Henry Meds
  • 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 / nudge.py
Last active September 5, 2024 06:35
Debugging with lldb and xCode
""" File: nudge.py
An lldb Python script to add a nudge command.
Add to ~/.lldbinit:
command script import ~/path/to/nudge.py
Usage:
(lldb) nudge x-offset y-offset [view]
@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
}