Skip to content

Instantly share code, notes, and snippets.

View stuartwakefield's full-sized avatar

Stuart Wakefield stuartwakefield

View GitHub Profile
@stuartwakefield
stuartwakefield / glfw_glm_boost_libpng_zlib_win10_cmake.md
Last active January 8, 2019 21:54
Notes about building GLFW, GLM, Boost, LibPNG, ZLib on Windows 10 using CMake.

Using [MinGW][mingw] containing the GCC GNU Compiler Collection and CMake to build OpenGL game projects using GLFW. GLM, Boost, LibPNG and ZLib.

ZLib

Get [zlib][zlib] sources and use the certutil executable to verify the SHA256 signature:

certutil -hashfile zlibx.zip SHA256
@stuartwakefield
stuartwakefield / check-git-status.sh
Created January 4, 2019 21:03
Some useful bash scripts for cleaning up code workspaces
#!/bin/bash
# Checks the Git status of all subdirectories of the current directory, i.e.,
# whether it has a Git repository, if the working copy is dirty / has uncommitted files,
# the status and tracking of local branches and whether the local repository is connected
# to a remote repository.
find . -maxdepth 1 -type d | xargs -I '{}' bash -c 'echo ----- {} ; git -C {} status ; git -C {} branch -vv ; git -C {} remote -v'
@stuartwakefield
stuartwakefield / sts_to_credentials.sh
Last active August 13, 2017 11:32
Script to convert STS output to credentials file format
#!/bin/bash
#
# Converts the output of the AWS STS assume role
# CLI command into the correct format for a
# credentials file.
#
jq -r '"[default]\n" +
"aws_access_key_id = " + .Credentials.AccessKeyId + "\n" +
@stuartwakefield
stuartwakefield / cloud-init-format-volume.yaml
Created January 28, 2017 11:20
Cloud init service block to conditionally format an unformatted volume.
name: format-volume.service
command: start
content: |
[Unit]
Description=Formats the volume drive
Requires=dev-vdb.device
After=dev-vdb.device
ConditionFirstBoot=true
[Service]
@stuartwakefield
stuartwakefield / http-request-to-stream.js
Last active June 15, 2016 08:01
Using a HTTP request as a stream
const request = http.request(opts)
// We expect a single response event to be emitted when the response
// to the request is received.
const response$ = _('response', request).head()
// Create an error stream from the error events from the request.
// As this is an event stream it is considered an infinite stream.
const error$ = _('error', request).map(error => { throw error })
@stuartwakefield
stuartwakefield / GLFWWindow.java
Created May 18, 2016 16:30
Basic single monitor setup with OpenGL 3.2 forward compatibility and core profile
public class Window {
private final Long id;
public Window(Long id) {
this.id = id;
}
public void destroy() {
GLFW.glfwDestroyWindow(this.id);
@stuartwakefield
stuartwakefield / GLFWGLViewport.java
Last active May 11, 2016 11:59
Sets the GL viewport based correctly for higher DPI monitors
public class GLFWGLViewport {
public void apply(GLWindow window) {
IntBuffer wbuf = BufferUtils.createIntBuffer(1);
IntBuffer hbuf = BufferUtils.createIntBuffer(1);
GLFW.glfwGetFramebufferSize(window.getId(), wbuf, hbuf);
int w = wbuf.get(0);
@stuartwakefield
stuartwakefield / README.md
Last active July 12, 2016 20:34
CSS guidelines

BEM

  • Block - independent / standalone entity
  • Element - a subcomponent of a block
  • Modifier - a state or variation of an entity

Rather than use strict naming for blocks, elements and modifiers stick to class name for the block, tags for the elements.

Also prefer to use RDFa Lite semantic selectors rather than classes, i.e.:

@stuartwakefield
stuartwakefield / README.md
Last active April 5, 2016 08:18
JavaScript reconciling immutability, lenses with loose typing

Reconciling immutability, lenses with loose typing in JavaScript

WIP

How do we model functions and state, i.e. object orientation in FRP. When JavaScript is loosely typed and we want nice things like immutable updating and lenses. Lenses have to be able to make a copy of the object that has changed.

(Look at shapeless lens https://github.com/milessabin/shapeless to see what

@stuartwakefield
stuartwakefield / entry.js
Last active January 20, 2016 13:59
Pattern for refable entities
/**
* I represent a domain entity within the
* system called "entry". I have a $ref
* property which is a unique identifier
* that can be used to address me.
*/
class Entry {
constructor(data) {
this._$ref = EntryRef.from(data.$ref);