Skip to content

Instantly share code, notes, and snippets.

View jasper-lyons's full-sized avatar
💭
Full time educator, part time developer

Jasper Lyons jasper-lyons

💭
Full time educator, part time developer
View GitHub Profile
data = (-10...10).map { |n| [n, n * 5] }
weight = 0
30.times do
input, expected = data.sample # [[input, expected]]
output = weight * input
weight = weight - (expected - output)
puts([input, expected, output].inspect)
end
storage <- list()
numbers <- c(4, 1, 15, 12, 0, 9, 9, 5, 5, 8, 7, 3, 14, 5, 12, 3)
count <- 0
while (!(list(numbers) %in% storage)) {
storage <- append(storage, list(numbers))
largest <- max(numbers)
largestIndex <- which.max(numbers)
numbers[largestIndex] = 0
index <- largestIndex

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@jasper-lyons
jasper-lyons / lspec.lua
Created February 22, 2018 11:31
A lua testing framework in 30 lines
local function describe(name, descriptor)
local errors = {}
local successes = {}
function it(spec_line, spec)
local status = xpcall(spec, function (err)
table.insert(errors, string.format("\t%s\n\t\t%s\n", spec_line, err))
end)
if status then
@jasper-lyons
jasper-lyons / trello-api-oop.rb
Last active April 12, 2018 11:16
Fluent / OOP wrapper for trello api.
require 'net/http'
require 'uri'
require 'openssl'
require 'json'
require 'time'
class Http
def initialize(headers = {}, params = {})
@headers = headers
@params = params
@jasper-lyons
jasper-lyons / email_via_microsoft.rb
Created April 24, 2018 10:22
Send email, in ruby with mail gem through microsoft email accounts!
require 'mail'
Mail.defaults do
delivery_method :smtp, {
address: 'smtp.live.com',
port: 587,
user_name: '<your email>',
password: '<your password>',
authentication: :login,
enable_starttls_auto: true
@jasper-lyons
jasper-lyons / react-in-100-lines.html
Created April 29, 2019 17:30
React in 100 lines
<html>
<head>
<script>
// fn - a function
// arg - anything
//
// Saves us having to pass the same variable into the function over
// and over again.
function curry(fn, arg) {
return function () {

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@jasper-lyons
jasper-lyons / error
Created June 5, 2019 19:31
Primero Vagrant up error
==> default: [2019-06-05T15:42:27+00:00] DEBUG: Re-raising exception: Chef::Exceptions::FileNotFound - template[/var/solr/cores/production/core.properties] (primero::solr line 65) had an error: Chef::Exceptions::FileNotFound: Cookbook 'primero' (0.1.0) does not contain a file at any of these locations:
==> default: templates/ubuntu-16.04/solr/core.properties.erb
==> default: templates/ubuntu/solr/core.properties.erb
==> default: templates/default/solr/core.properties.erb
==> default:
==> default: This cookbook _does_ contain: ['/tmp/vagrant-chef/eb442c9d9bbf02f71a986e63524b8810/cookbooks/primero/templates/default/aliases.erb','/tmp/vagrant-chef/eb442c9d9bbf02f71a986e63524b8810/cookbooks/primero/templates/default/couchdb/couch_config.yml.erb','/tmp/vagrant-chef/eb442c9d9bbf02f71a986e63524b8810/cookbooks/primero/templates/default/couchdb/vm.args.erb','/tmp/vagrant-chef/eb442c9d9bbf02f71a986e63524b8810/cookbooks/primero/templates/default/couchdb/local.ini.erb','/tmp/vagrant-chef/eb442c9d9bbf02f71a986e63524
@jasper-lyons
jasper-lyons / CML.lua
Created March 5, 2020 12:23
Light weight Channel, Fibers and Task scheduler in Lua
-- This is just me working through this blog post:
-- https://www.wingolog.org/archives/2018/05/16/lightweight-concurrency-in-lua
--
-- My goal was just to explore how one can make concurrency in lua more expressive without
-- compiling your own c extensions. Eventually I want to explore using such a system to build
-- a concurrent socket server but I suspect that will need c. Can't escape the blocking.
local Tasks = {
queue = {}
}