This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LinkedList: | |
def __init__(self, value=None): | |
self.head = None | |
if value is not None: | |
self.head = self.Node(value) | |
self.tail = self.head | |
self.count = 0 | |
if value is not None: | |
self.countUp() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
def factorial(n): | |
'''factorial(n) returns the product of the integers 1 through n for n >= 0, | |
otherwise raises ValueError for n < 0 or non-integer n''' | |
# implement factorial_iterative and factorial_recursive below, then | |
# change this to call your implementation to verify it passes all tests | |
... | |
return factorial_iterative(n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// CoreDataStack.swift | |
// | |
// | |
// Created by Fernando Rodríguez Romero on 21/02/16. | |
// Copyright © 2016 udacity.com. All rights reserved. | |
// | |
import CoreData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="js-linkable" data-href="https://example.com"> | |
<!-- | |
Contents of this div | |
--> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).on('turbolinks:load', () => { | |
linkableElements = $('.js-linkable'); | |
linkableElements.click((e) => { | |
e.preventDefault(); | |
const { delegateTarget } = e; | |
const href = $(delegateTarget).data('href'); | |
Turbolinks.visit(href); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hash_from_dot_notation(value) | |
return value unless value.is_a?(Hash) | |
value.deep_stringify_keys.each_with_object({}) do |(k,v), result| | |
root, child = k.split('.') | |
if child | |
result[root] ||= {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Auth | |
module VerifyJwt | |
extend self | |
JWKS_CACHE_KEY = "auth/jwks-json".freeze | |
JWKS_URL = "https://#{Rails.configuration.auth0[:auth_domain]}/.well-known/jwks.json".freeze | |
def call(token) | |
JWT.decode( | |
token, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run with `ruby rails_optimistic_locking_example.rb` | |
# | |
# frozen_string_literal: true | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } |