Skip to content

Instantly share code, notes, and snippets.

Thomas Roche thoroc

  • Edinburgh
Block or report user

Report or block thoroc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View PrefabReplace.cs
// COMMUNITY THREAD LINK https://forum.unity.com/threads/replace-game-object-with-prefab.24311/
// CopyComponents - by Michael L. Croswell for Colorado Game Coders, LLC
// March 2010
//Modified by Kristian Helle Jespersen
//June 2011
//Modified by Connor Cadellin McKee for Excamedia
//April 2015
//Modified by Fernando Medina (fermmmm)
//April 2015
//Modified by Julien Tonsuso (www.julientonsuso.com)
@thoroc
thoroc / ApplySelectedPrefabs.cs
Created May 7, 2019
Super userful script for applying changes to multiple prefabs. Simply highlight prefabs, go to GameObject menu and select 'Apply Changes To Selected Prefabs'
View ApplySelectedPrefabs.cs
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ApplySelectedPrefabs.cs" company="Supyrb">
// Copyright (c) 2017 Supyrb. All rights reserved.
// </copyright>
// <author>
// baptisteLar
// http://baptistelargaiolli.com/
// </author>
// <author>
// Johannes Deml
@thoroc
thoroc / README.md
Last active Apr 26, 2019
Dockerizing all the things: Running Ansible inside Docker container
View README.md

Automating things in software development is more than useful and using Ansible is one way to automate software provisioning, configuration management, and application deployment. Normally you would install Ansible to your control node just like any other application but an alternate strategy is to deploy Ansible inside a standalone Docker image. But why would you do that? This approach has benefits to i.a. operational processes.

Although Ansible does not require installation of any agents within managed nodes, the environment where Ansible is installed is not so simple to setup. In control node it requires specific Python libraries and their system dependencies. So instead of using package manager to install Ansible and it’s dependencies we just pull a Docker image.

By creating an Ansible Docker image you get the Ansible version you want and isolate all of the required dependencies from the host machine which potentially might break things in other area

@thoroc
thoroc / Direction.cs
Last active Apr 22, 2019
Direction (Cardinal) using bit manipulation (Inverse, Rotate Clockwise & Rotate Counter Clockwise)
View Direction.cs
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleDirections
{
public static class Directions
{
private static readonly Random Random = new Random();
@thoroc
thoroc / readme.md
Created Feb 10, 2019
Joe Armstrong on Erlang
View readme.md

Once upon a very long time ago we did a project to compare the efficiency of Erlang to PLEX.

We implemented "the same things" (TM) in Erlang and PLEX and counted total man hours

We did this for several different things.

Erlang was "better" by a factor of 3 or 25 (in total man hours) - the weighted average was a factor 8

They asked "what is the smart programmer effect"

@thoroc
thoroc / list-all-title-per-user-id.md
Created Feb 5, 2019
[SQL] Concatenate fields when grouping
View list-all-title-per-user-id.md

Solution 1: list all titles for each user_id

WITH users (id, title) AS (
  VALUES (1, 'Editor'),
         (1, 'Reviewer'),
         (7, 'EIC'),
         (7, 'Editor'),
         (7, 'Reviewer'),
         (7, 'Editor'),
         (19, 'EIC'),
@thoroc
thoroc / list-duplicates.md
Last active Feb 5, 2019
[SQL] Find duplicates in a list of records
View list-duplicates.md
@thoroc
thoroc / mogrify.py
Last active Jan 24, 2019
Trying to mogrify a query ....
View mogrify.py
from random import choice
import psycopg2
STATEMENT = 'WITH u (uid, name) AS (VALUES %(users)s) SELECT u.uid, u.name FROM u WHERE u.name ~ \'%(partial_name)s\';'
def create_data(total: int) -> list:
data = []
@thoroc
thoroc / readme.md
Last active Jan 15, 2019
How to boot Ubuntu 16.04 on the Shield TV with X1 GPU drivers
View readme.md

So because Android can be kind of annoying sometimes for dev work, especially if you're just interested in working on the aarch64 JIT or GLES code, booting a Linux distro can be pretty useful. This guide can also be extended to outright installing Ubuntu on the Shield TV by flashing the boot partition but we won't cover that. Also note, everything about this guide is non-destructive, so unless you decide to flash anything, you can't break your Shield TV.

I'm writing this guide assuming you have a functional UNIX environment of some sort and a non-pro Nvidia Shield TV 2015. The pro variant WILL NOT WORK with this specific guide, but the boot files are given for them as well in the XDA links below.

You'll need a USB device or MicroSD at least 4 GB large. 8 GB or higher is highly recommended.

Quick and easy way to get up and running

Go download all the files here: https://drive.google.com/drive/folders/0B39Ag2JMI49DcDJUTnBlRUJPRzA

@thoroc
thoroc / generate_random_ids.py
Last active Jan 14, 2019
quick solution to get some random data (ids 8 char long between 10100000 and 10800000)
View generate_random_ids.py
import csv
import random
import inspect
def get_frame_info() -> dict:
callerframerecord = inspect.stack()[1]
frame = callerframerecord[0]
info = inspect.getframeinfo(frame)
frame_info = {'filename': info.filename, 'function': info.function, 'lineno': info.lineno}
You can’t perform that action at this time.