Skip to content

Instantly share code, notes, and snippets.

// Utility functions
function populateNumbers(startNum, endNum, missingNum) {
let numbers = [];
for (let i = startNum; i <= endNum; ++i) {
if (i !== missingNum) {
numbers.push(i)
}
}
return numbers;
export CATALOG_URL=$(curl -s \
--header "authorization: Basic $CCD_AUTH_KEY" \
--header "content-type: application/json" \
--request GET \
--url "https://content-api.cloud.unity3d.com/api/v1/buckets/${CCD_BUCKET_ID}/entries/" | \
jq -r '[[.[] | select(.path | contains(".json"))] | sort_by(.last_modified) | reverse[]] | .[0] | .content_link')
EXCLUDED_CONFIG_CONTENT=$(echo ${UNITY_REMOTE_CONFIG_CONTENT} | \
jq \
@ApprenticeGC
ApprenticeGC / Grid.cs
Created March 21, 2020 11:29
Get neighbors of one particular cell defined by x and y index
public int[] GetStatusOfCellNeighbors(int xIndex, int yIndex)
{
// Use x from left to right, y from bottom to top
// 2,0 2,1, 2,2
// 1,0 1,1, 1,2
// 0,0 0,1, 0,2
(int, int)[] GetIndicesOfNeighbors()
{
return new (int, int)[]
@ApprenticeGC
ApprenticeGC / Grid.cs
Created March 21, 2020 09:09
Create empty grid cell
private void Start()
{
Assert.IsNotNull(gridCellPrefab);
for (var y = 0; y < height; ++y)
{
for (var x = 0; x < width; ++x)
{
var cellPosition = new Vector3(x, y, 0);
var createdInstance = GameObject.Instantiate(gridCellPrefab, cellPosition, Quaternion.identity);
@ApprenticeGC
ApprenticeGC / Main.cs
Created March 21, 2020 08:41
Show rule validation from Debug
void Start()
{
int GetAliveCountOfNeighbors(int[] neighbors) => neighbors.Aggregate(0, (acc, next) => acc + next);
{
// 0 0 0
// 0 1 0
// 0 0 0
var statusOfCurrentCell = 1;
var statusOfCurrentNeighbors = new[] {0, 0, 0, 0, 0, 0, 0, 0};
@ApprenticeGC
ApprenticeGC / Main.cs
Last active March 21, 2020 08:20
Game of Life main rule
int GetNextGenerationStatus(int statusOfCurrentCell, int[] statusOfCurrentNeighbors)
{
var count = statusOfCurrentNeighbors.Length;
var aliveNeighborCount = 0;
for (var i = 0; i < count; ++i)
{
var statusOfCurrentNeighbor = statusOfCurrentNeighbors[i];
if (statusOfCurrentNeighbor == 1)
{
aliveNeighborCount += 1;
@ApprenticeGC
ApprenticeGC / MagicStone.cs
Created October 11, 2019 09:50
For coding game Magic Stone
namespace ConsoleApplication1
{
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
public class Solution
@ApprenticeGC
ApprenticeGC / index.js
Last active December 14, 2017 10:18
Using blessed to show job board in console.
var blessed = require('blessed')
const employeeWantedDataCollection = [
{
title: 'Game Programmer',
salary: 'NT 80000/Month',
description: 'Fluent in C++/C# and strong knowledge in Unity',
contact: 'hr@ubihard.com'
},
{
@ApprenticeGC
ApprenticeGC / next.config.js
Created December 7, 2017 00:35
Custom Webpack setting in Next.js
const webpack = require('webpack')
module.exports = {
webpack: function (config) {
config.plugins.push(
new webpack.DefinePlugin({
'process.env': {
S3_ACCESS_KEY: JSON.stringify(process.env.S3_ACCESS_KEY),
S3_SECRET_KEY: JSON.stringify(process.env.S3_SECRET_KEY)
@ApprenticeGC
ApprenticeGC / playmaker.json
Last active October 13, 2017 03:55
Create symlink to import plugins to Unity project
{
"name": "PlayMaker",
"toSymlink": [
{
"name": "PlayMaker",
"to": "Standard Assets/PlayMaker"
},
{
"name": "Gizmos/PlayMakerFSM Icon.tiff",
"to": "Gizmos/PlayMakerFSM Icon.tiff"