Skip to content

Instantly share code, notes, and snippets.

Sam Schick schicks

Block or report user

Report or block schicks

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@schicks
schicks / v2.ipynb
Last active Feb 16, 2020
Tree Traversals
View v2.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@schicks
schicks / Trading.ml
Last active Jan 21, 2020
Types are Boring
View Trading.ml
(*
* A linear algebra approach to the problem described here:
* https://alexnixon.github.io/2020/01/14/static-types-are-dangerous.html
*)
type currency = (* Currencies as a simple enum *)
| GBP
| USD
| JPY
@schicks
schicks / README.md
Last active Jan 19, 2020
Pydantic Generation Strategy
View README.md

Pydantic Generation Strategy

We frequently use pydantic at Pluralsight to validate data at the edge of a well typed domain. I've been trying to sell my coworkers on using hypothesis for testing, and thought it might go easier if they could generate test data from existing pydantic schemas. I found that it was almost trivial for data classes, but BaseModel subclasses (which are unfortunately much more common in our code) don't play as nicely, and deeply nested schemas can get you into trouble. If anyone has any advice on how to get around the errors that come from the last test, I'd be super greatful.

Requirements for usage

  • pydantic
  • hypothesis
  • pytest
View Search_QA.md

Common Questions About Search

Why are the results not in the order that I would expect?

The primary reason that results seem like they might be returned out of order is because there is a random element to the rank that we give each search document. This allows us to expose courses that might otherwise have been buried too far down the list to be seen, which both helps authors get exposure and improves the feedback that we get because we see users interact with more courses.

Won't this create an inconsistent experience for the user?

The randomness added to the query is seeded by the user id, so each time an individual user searches for something the results will be in the same order. However, if two different users attempted the same search, they might see results in different orders. This sort of behavior is fairly common among searches on marketplaces, like ecommerce websites, because it helps prevent [winner-t

View autocomplete.js
import axios from 'axios'
import config from '../../config'
const searchUrl = '/library/search?q='
const libraryCoursesUrl = '/library/courses/'
const debounce = (func, wait, immediate) => {
let timeout
return (...args) => {
const later = () => {
@schicks
schicks / default_arguments.md
Last active Jan 23, 2019
default arguments
View default_arguments.md

How Does Javascript Handle Default Arguments?

My first experience with default arguments was from Python, where there are dire warnings of the dragons you will encounter if you supply mutable values as default arguments. The concern is in Python, these arguments are initialized at the time that the function is created, which can give you some very surprising results.

def greeter(greetings={}):
  print(greetings.get('hi', 'No such greeting')
  greetings['hi'] = 'Hello World!'
@schicks
schicks / Rest.js
Last active Dec 6, 2018
Declarative data from rest apis in react
View Rest.js
//@flow
import * as React from 'react'
import axios from 'axios'
type JsonType = number | string | { [string]: JsonType } | JsonType[] | null
type Props = {
uri: string,
children: React.ComponentType<{ loading: boolean, error: boolean, data?: JsonType }>,
transform: JsonType => JsonType,
View fibonacci.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View efficiency.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@schicks
schicks / cloudSettings
Last active Jul 1, 2018
Visual Studio Code Settings Sync Gist
View cloudSettings
{"lastUpload":"2018-07-01T16:18:58.169Z","extensionVersion":"v2.9.2"}
You can’t perform that action at this time.