Chart to visualize sleep data.
A Pen by Christopher Saunders on CodePen.
| //The game of life in Swift | |
| //I have a huge crush on this language, I wish I could do more with it | |
| // I'm looking this stuff up in the iBook, which has hilariously | |
| // consequences when trying to copy/paste code snippets | |
| import Cocoa | |
| import XCPlayground | |
| //Ugh, coming from my last project in VanillaJS, having a sweet array constructor rules!! |
| require 'json' | |
| string = { foo: 'bar', baz: { bill: 'bob' } }.to_json | |
| def santize(string) | |
| # Turn string into Hash or Array | |
| result = JSON.parse( | |
| string, | |
| # This option lets us mutate strings | |
| # By default strings are frozen |
| set nocompatible | |
| syntax on | |
| map <Esc> <Nop> | |
| set nu | |
| set mouse=a | |
| execute pathogen#infect() | |
| autocmd vimenter * if !argc() | NERDTree | endif | |
| autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif | |
| "====[ Make the 81st column stand out ]==================== |
| class Array | |
| def flatten | |
| @result = [] | |
| _flatten(self) | |
| end | |
| private | |
| def _flatten(collection) | |
| collection.each do |item| |
| # A library for encoding/cracking the Ceasar Cipher | |
| module CaesarCipher | |
| ALPHABET = ('a'..'z').to_a | |
| ALPHABET_UPCASE = ('A'..'Z').to_a | |
| # Responsible for encrypting a string | |
| # using the Caesar Cipher | |
| class Encoder | |
| attr_reader :encoded_message | |
| def initialize(plaintext:, shift:) | |
| @words = plaintext.split(' ') |
Chart to visualize sleep data.
A Pen by Christopher Saunders on CodePen.
| import Cocoa | |
| enum Status { | |
| case unmarked, prime, composite | |
| } | |
| class SeiveOfEratosthenes { | |
| let ceiling: Int | |
| let ceiling_sqrt: Int | |
| var table = [Int: Status]() |
| # Naive implementation of the Seive of Eratosthenes | |
| # | |
| # # Usage | |
| # SeiveOfEratosthenes.find_primes(10_000) | |
| # | |
| class SeiveOfEratosthenes | |
| attr_reader :set_array | |
| # Return an array of all prime numbers below ceiling | |
| def self.find_primes(ceiling) | |
| new(ceiling).mark_table.filter_table.set_array |
| # A library for encoding/cracking the Ceasar Cipher | |
| module CaesarCipher | |
| ALPHABET = ('a'..'z').to_a | |
| ALPHABET_UPCASE = ('A'..'Z').to_a | |
| # Responsible for encrypting a string | |
| # using the Caesar Cipher | |
| class Encoder | |
| attr_reader :encoded_message | |
| def initialize(plaintext:, shift:) |
| # Dining Philosophers | |
| # \ # / | |
| # # # | |
| # /#|#\ | |
| # | |
| # Philosophers | |
| # \ 0 / | |
| # 4 1 | |
| # /3|2\ | |
| # |