Skip to content

Instantly share code, notes, and snippets.

View jackbrookes's full-sized avatar
🌱

Dr Jack Brookes jackbrookes

🌱
View GitHub Profile
@jackbrookes
jackbrookes / example_image_cowplot.R
Last active July 25, 2017 17:14
Example of how to combine plots with images side-by-side in cowplot for publication ready figures.
library(png)
library(grid)
library(tidyverse)
# generate random data
my.data <- data.frame(x = c(1:10), y = rnorm(10))
# plot random data
g <- ggplot(my.data, aes(x = x, y = y)) +
geom_point()
library(tidyverse)
library(gridExtra)
plot_cars_var <- function(col_name){
ggplot(mtcars, aes_string(x = "mpg", y = col_name)) +
geom_smooth() +
geom_point()
}
mtcars %>%
@jackbrookes
jackbrookes / S3Example.cs
Created August 6, 2018 22:38
A working version of the AWSSDK ./Examples/S3Example.cs (Modified AWSConfigs, changed POST request to PUT)
//
// Copyright 2014-2015 Amazon.com,
// Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the AWS Mobile SDK For Unity
// Sample Application License Agreement (the "License").
// You may not use this file except in compliance with the
// License. A copy of the License is located
// in the "license" file accompanying this file. This file is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
{
"n_practice_trials": 5,
"n_main_trials": 10,
"size": 1
}
@jackbrookes
jackbrookes / SteamVROverlayCheck.cs
Last active August 18, 2018 16:00
Unity script that enables/disables a gameobject (like a warning text) when the user presses the System Button in SteamVR
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SteamVROverlayCheck : MonoBehaviour
{
public GameObject warningDisplay;
void OnEnable()
@jackbrookes
jackbrookes / Texture2DExtensions.cs
Last active April 27, 2019 16:06
Extensions for the Unity Texture2D class allowing add/subtract/multiply operations on other textures as well as singe colours.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public static class Texture2DExtensions
{
public static void Add(this Texture2D tex1, Texture2D tex2)
@jackbrookes
jackbrookes / PositionAdjuster.cs
Last active September 11, 2019 20:12
Adjust height of a GameObject, and/or re-center your VR CameraRig with a keyboard press.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PositionAdjuster : MonoBehaviour
{
// amount by which each button press changes the height by
public float heightIncrement = 0.01f;
// keys on the keyboard we wish to use for adjusting position
{
"example_string": "aaa",
"example_bool": true,
"example_int": 3,
"example_float": "3.14",
"example_array": [
1,
2,
3,
4
import pygame
import random
clr_red = (255, 0, 0)
clr_green = (0, 255, 0)
clr_blue = (0, 0, 255)
txt_red = "red"
txt_green = "green"
txt_blue = "blue"
@jackbrookes
jackbrookes / LerpEnumerator.cs
Last active June 23, 2021 10:17
Unity3D Lerp (Linear Interpolation) Coroutines. Contains methods for creating routines which can be used as coroutines to easy lerp over a time period.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Contains methods for creating routines which can be used as coroutines to easy lerp over a time period.
///
/// Example moves an object between two points over 5 seconds: