Skip to content

Instantly share code, notes, and snippets.

View davegurnell's full-sized avatar
🐱

Dave Pereira-Gurnell davegurnell

🐱
View GitHub Profile
@davegurnell
davegurnell / anorm.scala
Last active August 14, 2023 16:42
A short guide to Anorm
/*
Overview
--------
To run a query using anorm you need to do three things:
1. Connect to the database (with or without a transaction)
2. Create an instance of `anorm.SqlQuery` using the `SQL` string interpolator
3. Call one of the methods on `SqlQuery` to actually run the query
@davegurnell
davegurnell / .latexmkrc
Created July 11, 2012 19:31
Sample latexmk file to provide continuous compilation and preview with MacTex on OS X
# Sample latexmk configuration to use xelatex and Preview on OS X.
# Should help if you want to use latexmk with MacTeX.
#
# 1. Install MacTeX
# 2. Put this file in ~/.latexmkrc
# 3. Continuously recompile and preview your document with the command:
# latexmk -pvc myfile.tex
$pdflatex = 'xelatex -interaction=nonstopmode %O %S';
$pdf_previewer = 'open -a Preview "%S"';

Scala Course

Dave Pereira-Gurnell

Objectives

Things that enable a "functional style" in Scala:

  • Scala Language Features
  • Higher Level Theory
points = script.Parent
--[[
This script creates 100 cubes representing "points" on a graph.
It loops through the values of x from 0 to 100, and calculates the correct y value at each position.
For each pair of values, it creates a cube at position x,y.
]]
-- Create a variable called "x" and set it to 0
x = 0
@davegurnell
davegurnell / ColorParser.scala
Created October 13, 2011 14:29
Simple parser for CSS color literals, based on Scala parser combinators
/*
* Copyright (c) 2011 Untyped Ltd, http://untyped.com
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
@davegurnell
davegurnell / functional-brighton-code-of-conduct
Last active January 20, 2022 13:13 — forked from didichanoch/sample-discord-coc.md
A sample code of conduct for discord servers.
Functional Brighton Code of Conduct
===================================
Welcome!
--------
Functional Brighton is a Brighton UK based meetup group that aims to bring together people interested in functional programming. We hope that it will complement London-based groups (eg. the London Scala User Group, Hoodlums, F#unctional Londoners, etc.), giving Londoners an excuse for a trip to the seaside and Brightonians some relief from the train.
The current admins are:
* Dave Pereira-Gurnell (@davepg)
@davegurnell
davegurnell / copy-responses-to-choices.js
Last active November 7, 2021 13:19
Script to copy the responses from a text field in one Google Form as choices in a multiple choice field in another Google Form
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
START OF CONFIGURATION
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~
Configuration: Form URLs
~~~~~~~~~~~~~~~~~~~~~~~~
You can get these from the address bar
@davegurnell
davegurnell / BigData.scala
Last active September 14, 2021 04:53
Slick database mapping of >22 columns using HLists.
/* ===== NOTE =====
*
* This code sample is out-of-date!
*
* If you're looking for support for shapeless HLists in Slick queries,
* check out [Slickless](https://github.com/underscoreio/slickless).
*
* ================
*/
import slick.driver.MySQLDriver.simple._
@davegurnell
davegurnell / MapControl.stores.tsx
Last active August 30, 2021 12:52
Experiment with custom controls in react-native-mapbox-gl/maps
import MapboxGL from "@react-native-mapbox-gl/maps";
import { storiesOf } from "@storybook/react-native";
import React from "react";
import { StyleSheet, Text, TouchableNativeFeedback, View } from "react-native";
/*
Gist to demonstrate an issue I had with @react-native-mapbox-gl/maps.
I'm trying to display a button over a map and allow the user to click it without
the event bubbling up to the map. However, calls to stopPropagation and preventDefault
package sandbox
import cats.data.Kleisli
import cats.implicits._
case class User(username: String, avatarUrl: String, profileId: Int)
case class Avatar(url: String, monochrome: Boolean)
case class Profile(id: Int, age: Int)
object ComposingStuff extends App {