Skip to content

Instantly share code, notes, and snippets.

View imjacobclark's full-sized avatar
:shipit:
Shipping

Jacob Clark imjacobclark

:shipit:
Shipping
  • Manchester, United Kingdom
  • 05:22 (UTC +01:00)
View GitHub Profile
@imjacobclark
imjacobclark / pad-numbers-to-same-length.lisp
Last active February 3, 2019 17:57
Pad numbers to same length
(defun pad(thing)
(concatenate 'string "0" thing))
(defun pad-if-length-not-same(thing length)
(cond
((not
(= (length thing) length))
(pad thing))
(t thing)))
@imjacobclark
imjacobclark / number-pad.lisp
Created February 2, 2019 23:34
Number padder in Lisp
(defun pad(num)
(concatenate 'string "0" num))
(defun should-pad(num)
(= (length num) 1))
(defun apply-padding(num)
(cond
((should-pad num) (pad num))
(t num)))
@imjacobclark
imjacobclark / DFA.hs
Created January 21, 2019 13:51
Simple DFA in Haskell
module DFASpec (spec) where
import Test.Hspec
data State = S1 | S2 deriving (Eq, Show)
data Symbols = Zero | One deriving (Eq, Show)
data Alphabet = Alphabet [Symbols] deriving (Eq, Show)
data FiniteStates = FiniteStates [State] deriving (Eq, Show)
@imjacobclark
imjacobclark / lex.rs
Last active January 11, 2019 22:45
A Lexer in Rust
#[derive(Debug, PartialEq)]
enum Token {
Symbol(Symbol),
Type(Type),
Keyword(Keyword),
Word(Word),
Char(char),
}
#[derive(Debug, PartialEq)]
package xyz.jacobclark.day3;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
@imjacobclark
imjacobclark / index.js
Created December 7, 2018 12:01
API Gateway -> Lambda -> Apollo -> AppSync -> GitHub API
const query = require('./query.js');
require('es6-promise').polyfill();
exports.handler = function(event, context, callback) {
query(event["queryStringParameters"]['username']).then(function(data){
var resp = {
"isBase64Encoded": false,
"statusCode": 200,
module Main where
import Network.HTTP.Conduit
import qualified Data.ByteString.Lazy as L
import Text.Regex.PCRE
findNewsroundLinks :: String -> [String]
findNewsroundLinks = map read . getAllTextMatches . (=~ "href=\"/newsround([^\"#]+)")
bytestringToString :: L.ByteString -> [String]
@imjacobclark
imjacobclark / LinearRegression.java
Created January 4, 2018 23:03
Simple Linear Regression implementation in Java
package xyz.jacobclark;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static java.util.Arrays.asList;
public class LinearRegression {
private static final List<Integer> x = asList(2, 3, 5, 7, 9, 11, 14); // Consecutive hours developer codes
@imjacobclark
imjacobclark / AND-single-layer-neurone.py
Last active April 23, 2017 14:40
A single layer neural network to determine AND boolean logic
def nn(input1, input2):
bias = 1
weight0 = -1
weight1 = 0.5
weight2 = 0.5
net = (bias*weight0)+(input1*weight1)+(input2*weight2)
return "1" if net >= 0 else "0"
@imjacobclark
imjacobclark / README.md
Last active February 26, 2017 16:41
Association Lisps 💥

Association Lisps 💥

Running:

$ brew install sbcl
$ sbcl --script association.cl