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
@jasper-lyons
jasper-lyons / main.swift
Created November 14, 2021 14:27
Smallest Valid SwiftUI Program - Works without loading the XCode UI (Still needs to be installed)
import SwiftUI
struct app: App {
var body: some Scene {
WindowGroup {
Text("Hello").padding()
}
}
}
function useTable([]) {
const [id, setId] = useState(0)
const [records, setRecords] = useState([])
function find(attrs) {
return records.filter(
record => Object
.entries(attrs)
.every(([key, value]) => record[key] === value)
)
@jasper-lyons
jasper-lyons / solr-query-generator.rb
Created March 25, 2020 12:36
A rough implementation of a ruby interface to generate solr queries using ruby code.
module Search
@@searchable_attributes = []
def searchable(&block)
block.call(@@searchable_attributes)
end
def searchable_attributes
@@searchable_attributes
end
@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 = {}
}
@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

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@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 () {
@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 / 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 / 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