Skip to content

Instantly share code, notes, and snippets.

View lloydjatkinson's full-sized avatar
🌧️
Chilling

Lloyd Atkinson lloydjatkinson

🌧️
Chilling
View GitHub Profile
@lloydjatkinson
lloydjatkinson / AhoCorasickTree.cs
Created April 24, 2017 07:53 — forked from alexandrnikitin/AhoCorasickTree.cs
Aho-Corasick C# implementation
using System.Collections.Generic;
using System.Linq;
namespace AhoCorasickTree
{
public class AhoCorasickTree
{
internal AhoCorasickTreeNode Root { get; set; }
public AhoCorasickTree(IEnumerable<string> keywords)
@lloydjatkinson
lloydjatkinson / gist:9760d08e5651222639fea15f499a87b8
Created September 1, 2017 13:05
moment.js + moment-timezone.js
<h3>Converting current time</h3>
<div>
UTC: <span class="align" id="utc"></span>
</div>
<div>
London: <span class="align" id="london"></span>
</div>
<div>
public static class SerializationSettings
{
public static JsonSerializerSettings Json { get; } = new JsonSerializerSettings()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
Formatting = Newtonsoft.Json.Formatting.Indented
};
}
@lloydjatkinson
lloydjatkinson / 00.howto_install_phantomjs.md
Created December 17, 2017 13:27 — forked from julionc/00.howto_install_phantomjs.md
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
@lloydjatkinson
lloydjatkinson / .eslintrc.js
Created January 19, 2018 21:41
My .eslintrc.js file for Vue based projects. Uses default Vue recommended settings but enforces use of 4 space indentation and semicolons.
// https://eslint.org/docs/user-guide/configuring
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint'
},
env: {
browser: true,
},
https://medium.com/@lachlanmiller_52885/mocking-vuex-in-vue-unit-tests-b6eda1c4d301
@lloydjatkinson
lloydjatkinson / CustomerController.cs
Created April 23, 2018 21:02 — forked from vkhorikov/CustomerController.cs
Handling failures and input errors in a functional way
[HttpPost]
public HttpResponseMessage CreateCustomer(string name, string billingInfo)
{
Result<BillingInfo> billingInfoResult = BillingInfo.Create(billingInfo);
Result<CustomerName> customerNameResult = CustomerName.Create(name);
return Result.Combine(billingInfoResult, customerNameResult)
.OnSuccess(() => _paymentGateway.ChargeCommission(billingInfoResult.Value))
.OnSuccess(() => new Customer(customerNameResult.Value))
.OnSuccess(
internal class Program
{
private readonly static ManualResetEvent _manualResetEvent = new ManualResetEvent(false);
internal static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Console.CancelKeyPress += HandleExit;
// Application logic here.
@lloydjatkinson
lloydjatkinson / gist:4c1130a42e8847d344b1c9c5333d8eb7
Created June 13, 2018 21:25 — forked from ChickenProp/gist:3050085
Simple Raspberry Pi GPIO example

Introduction

This is a dead-simple way to test that GPIO on the Raspberry Pi is working. I have an SKPang Raspberry Pi starter kit A. But all you need is

  • A Raspberry Pi.
  • An LED.
  • A button.
  • A resistor, approximately 270Ω.
  • Some way to connect these to each other and the GPIO pins.
@lloydjatkinson
lloydjatkinson / boolean-filter.js
Created June 19, 2018 09:59
Vue filter for user friendly display of boolean values
/**
* Returns a string representing the truthy/falsy value of the given value. Defaults to "Yes" or "No".
* @param {*} value The value to determine the truthy/falsy value of.
* @param {String} truthyString The string to use if the value is truthy.
* @param {String} falsyString The string to use if the value is falsy.
* @example {{ userSelected | boolean }}
* @example {{ userSelected | boolean('Included', 'Not Included') }}
*/
const booleanFilter = (value, truthyString, falsyString) =>
value