Skip to content

Instantly share code, notes, and snippets.

View jxxcarlson's full-sized avatar

James Carlson jxxcarlson

View GitHub Profile
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
For the Schelling model, there is one file of interest, https://github.com/jxxcarlson/schelling/blob/master/src/Schelling.elm.
The main data structures are Cell, an opaque type, and Array Cell.
I use 1D arrays, but process them as if they were 2D arrays using
the functions
location :(Int, Int) -> Int
location (row, col) =
nRows * row + col
@jxxcarlson
jxxcarlson / heat.fut
Last active March 14, 2021 18:07
Discrete heat equation in Futhark
-- Apply the transformation field -> updated field for
-- a discrete temperature field f)i,j)
--
-- f'(i,j) = (1-beta)*f(i,j) + beta*average(i,j)
--
-- where average(i,j) is the average of the
-- temperatures of the cells to the North, South,
-- East. and West.
-- This example is adapted from blur.fut
@jxxcarlson
jxxcarlson / gist:8202938cd4c5eb72d8b5086995880700
Created June 12, 2019 16:10
Bash script to switch between Agda libraries
#!/bin/sh
STD_LIB=/usr/local/lib/agda/src/
IAL_LIB=/Users/carlson/dev/agda/ial/
case $1 in
show) cat ~/.agda/defaults
;;
@jxxcarlson
jxxcarlson / server.py
Last active March 29, 2020 10:17
Get hardware generated random number via HTTP. Uses /dev/random
#!/usr/bin/env python3
"""
I have hacked the code at
https://gist.github.com/bradmontgomery/2219997#file-dummy-web-server-py
to make a server that responds to get requests by returning
a random integer generated using the /dev/random hardware
random number generator. Assuming that this file is named
"server.py", just do
@jxxcarlson
jxxcarlson / gist:b0fa7ac257a7005332636eea0f36aa3e
Last active April 27, 2020 07:13
Issue depolying svgChat
Made the changed indicated below
newAttributes : Random.Seed -> Float -> Float -> ClientStatus -> (ClientAttributes, Random.Seed)
newAttributes seed maxX maxY clientStatus =
let
(handle, seed1) = map String.toUpper (word 3 seed)
(x, seed2) = Random.step (Random.float 0 maxX) seed1
(y, seed3) = Random.step (Random.float 0 maxY) seed2
(k, seed4) = Random.step (Random.int 0 11) seed3
(color, fontColor) = getColors k
@jxxcarlson
jxxcarlson / gist:024724704390623efa7d93daa736b7bd
Created May 15, 2020 06:53
Lamdera error message on deploy of chattest
emote: It appears you're all set to deploy v32 of 'chattest'.
remote:
remote: There are no Evergreen type changes for this version.
remote: [============================================ ] - 16 / 18-- TYPE MISMATCH --------------------------------- src/Evergreen/Migrate/V31.elm
remote:
remote: Something is off with the body of the `frontendModel` definition:
remote:
remote: 23|> ModelMigrated
remote: 24|> ( { key = old.key
remote: 25|> , userId = ""
@jxxcarlson
jxxcarlson / gist:2af50265f66d822eb933d323140be5ec
Created June 1, 2020 16:31
Deno - CORS problem with this function
export const addDocument = async ({
request,
response,
}: {
request: any
response: any
}) => {
response.headers.set('Access-Control-Allow-Origin', '*')
console.log("processing POST request")
module Parse exposing (AST(..), toAST)
{-
Parse a string of Lisp text, return Just AST if it is legal, Nothing if not.
-}
import Parser exposing (..)
import ParserHelpers exposing (..)
# Elm Warrior: Notes
## Overall comments
The Dev.to article is very clear. Just a few very minor suggestions/comments below.
I did get some errors running `npm` (what's new?). The second error was
especially misleading/disconcerting, but it turns out that if you ignore it,
all is good. I was able to play the game.