Skip to content

Instantly share code, notes, and snippets.

@LarsBergqvist
LarsBergqvist / cd.yml
Created July 28, 2021 18:23
GitHub Actions workflow for the memory card game
name: Continuous Deployment
on:
push:
branches: [master]
jobs:
test-build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
@LarsBergqvist
LarsBergqvist / .travis.yml
Created July 28, 2021 18:17
Old travis-file for the memory card game appplication
dist: xenial
sudo: false
language: node_js
node_js:
- "10"
cache:
directories:
- ./node_modules
@LarsBergqvist
LarsBergqvist / cd.yaml
Created July 28, 2021 11:08
deploy job
deploy:
needs: test-and-build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download build artifacts
uses: actions/download-artifact@v2
with:
name: build-artifacts
name: Continuous Deployment
on:
push:
branches: ['**']
jobs:
test-and-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
name: Continuous Deployment
on:
push:
branches: ['**']
jobs:
yarn-install-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
const initialState = {
moves: 0,
gameComplete: false,
imageNumber: 1,
tiles: [],
size: undefined,
gameId: undefined,
gameName: undefined
};
import React from 'react';
import { connect } from 'react-redux'
import TileView from './TileView'
import { selectTile } from '../reducers/actions';
import PropTypes from 'prop-types';
const Puzzle = (props) => {
const width = Math.min(window.innerWidth, window.innerHeight);
const tileWidth = width / props.size;
const tileWrapperStyle = {
@LarsBergqvist
LarsBergqvist / tile-game-reducer.js
Created July 23, 2021 06:32
Reducer for image puzzle game
const initialState = {
turnNo: 1,
numClicksWithinTurn: 0,
selectedId: undefined,
gameComplete: false,
imageNumber: 1,
tiles: [],
size: undefined, // number of rows/columns in the puzzle matrix
gameId: undefined,
gameName: undefined
@LarsBergqvist
LarsBergqvist / map-functions.ts
Created January 23, 2021 12:17
Helper functions for working with Features/Markers in OpenLayers
import { click } from 'ol/events/condition';
import Feature from 'ol/Feature';
import Select, { SelectEvent } from 'ol/interaction/Select';
import VectorLayer from 'ol/layer/Vector';
import Map from 'ol/Map';
import { Fill, Icon, Style, Text } from 'ol/style';
export function styleMarkersAsDeselected(features: Feature[]) {
if (!features) return;
features.forEach((f) => {
@LarsBergqvist
LarsBergqvist / map.component.ts
Created January 23, 2021 12:16
Update an OpenLayers map with markers
private setupMap(input: MapInput) {
this.positions = input.markerPosisitons;
this.userPos = input.userPos;
if (!this.map) {
this.initilizeMap();
}
const view = this.map.getView();
if (this.positions.length > 0) {