Inspired by YouTube video, Advanced Topics in Programming Languages: Concurrency/message passing Newsqueak.
public IEnumerable<int> Primes(int max)
{
int count = 0;
int candidatePrime = 2;
var primes = new List<int>(max);Inspired by YouTube video, Advanced Topics in Programming Languages: Concurrency/message passing Newsqueak.
public IEnumerable<int> Primes(int max)
{
int count = 0;
int candidatePrime = 2;
var primes = new List<int>(max);Features:
undefinedfunction binarySearch(arr, number) {
let start = 0
let end = arr.length - 1See: https://sampleprograms.io/projects/baklava/javascript/
My attempt at backlava in JS.
Fetaures and difference to other implementation:
spaces and starssubstr to print the number of spaces and starsbacklava()backlava() returns a string rather than printing directly to the consoleUpon researching GraphQL, the question immediately came to my mind:
Why do we need another query language when we already have SQL?
A second question then came to mind:
Can we use SQL for API endpoints?
After asking this question, it now seems odd that REST style APIs would even be considered a good choice.
| function medianSplit(array) { | |
| let midPoint = array.length / 2 | |
| array = array.sort((a, b) => a - b) | |
| let firstHalf = array.slice(0, Math.floor(midPoint)) | |
| let middle = array.slice(Math.floor(midPoint), Math.ceil(midPoint))[0] | |
| let lastHalf = array.slice(Math.ceil(midPoint), array.length) | |
| return [firstHalf, middle, lastHalf] | |
| } | |
| function median(array) { |
| #!/usr/bin/env ruby | |
| # Aside from removing Ruby on Rails specific code this is taken verbatim from | |
| # mislav's git-deploy (http://github.com/mislav/git-deploy) and it's awesome | |
| # - Ryan Florence (http://ryanflorence.com) | |
| # | |
| # Install this hook to a remote repository with a working tree, when you push | |
| # to it, this hook will reset the head so the files are updated | |
| if ENV['GIT_DIR'] == '.' |
One of the earliest Ruby constructs I learned about was Hash.new {|h, k| h[k] = {} }.
This small one-liner is explored in many Ruby tutorials and it completely captured my imagination.
I've never been able to use this in a production app as I've always found a better solution.
However, one thing it might be good for is to take you on a short journey.
This journey will be interactive, so you will need to copy snippets of code into an irb or pry console. I recommend using ruby 2.6 or higher as the copy-paste functionality is better (and I havn't debugged on lower versions).
UPDATE: I've now added the caves_of_lemaria.rb script which will run through the whole adventure!
Need to be able to encapsulate collection logic, and chain together with Generic collection logic.
E.g. when you have a list of Node and Edge, there are certain collection functions which encapsulaet business logic that you may want to create which returns additional collections of objects, which may also have their own collection functions.
These collection functions may encapsulate specific map() or filter() behaviour for example.
The problem with may typed languages is that there is a generic class like List which provides the collection interface, but the functions return some generic interface, so when we implement in a subclass, we need to override all methods to wrap and return value in the subclass, and specify the type as the subclass instead of the interface. This is a lot of boilerplate code! But if we dont override all the methods, we can't chain our collection functions and return our specific collection functions.
###Sketch trial non stop
Open hosts files:
$ open /private/etc/hosts
Edit the file adding:
127.0.0.1 backend.bohemiancoding.com
127.0.0.1 bohemiancoding.sketch.analytics.s3-website-us-east-1.amazonaws.com
| # frozen_string_literal: true | |
| module SecureAttribute | |
| extend ActiveSupport::Concern | |
| # BCrypt hash function can handle maximum 72 bytes, and if we pass | |
| # password of length more than 72 bytes it ignores extra characters. | |
| # Hence need to put a restriction on password length. | |
| MAX_PASSWORD_LENGTH_ALLOWED = 72 |