Skip to content

Instantly share code, notes, and snippets.

On vacation

Joseph An josephan

On vacation
View GitHub Profile
View CameraViewHotkeys.cs
using System.Collections;
using UnityEngine;
using UnityEditor;
/// <summary>
/// Adds a 'Camera' menu containing various views to switch between in the current SceneView
/// </summary>
public static class CameraViewHotkeys {
/// <summary>
josephan / CloseActiveWindow.cs
Last active Jun 22, 2022
Unity Editor keyboard shortcut to close active undocked window
View CloseActiveWindow.cs
using UnityEngine;
using UnityEditor;
using System.Reflection;
public static class CloseActiveWindow
[MenuItem("Edit/Close Active Window ^w", false, -101)]
public static void CloseWindow()
var window = EditorWindow.focusedWindow;
josephan /
Last active Jul 1, 2022
Windows 10: From the start menu, focus Google Chrome if it's open otherwise open a new window.


Out of habit from using Ubuntu, to focus Google Chrome I hit the Start Menu button and type "ch" (which autocompletes to Chrome) and hit enter to open Chrome. This is faster than using Alt+Tab and using mental energy trying to find Chrome window. However in Windows 10 this always opens a new window and I'm left with a bunch of windows open and a cluttered desktop.


To mimic the behaviour of opening Google Chrome from macOS's Spotlight or Ubuntu's start menu where if you already have a Google Chrome instance, it will focus the open window rather than create a new window. Windows 10 by default always open a new Chrome window from the start menu.


josephan / settings.json
Created May 6, 2020
Settings for VSCode and Vim extension
View settings.json
"workbench.colorTheme": "Atom One Dark",
"window.zoomLevel": 0,
"workbench.activityBar.visible": true,
"workbench.startupEditor": "welcomePage",
"editor.minimap.enabled": true,
"editor.fontSize": 14,
"editor.formatOnSave": true,
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
josephan /
Last active Dec 16, 2021
Add Tailwind CSS to an Elixir/Phoenix Project with PurgeCSS
View vimr-crash-log
Process: VimR [1273]
Path: /Applications/
Identifier: com.qvacua.VimR
Version: SNAPSHOT-294 (294)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: VimR [1273]
User ID: 2113678394
Date/Time: 2018-11-29 09:54:17.375 -0500
josephan /
Last active Oct 29, 2018
How To Add React To Phoenix 1.4

1. cd into assets/ and install the following NPM packages:

npm i react react-dom -S
npm i @babel/preset-react -D

2. add the following line to assets/.babelrc file:

    "presets": [
josephan /
Last active Nov 2, 2018
Phoenix WebSocket Notes

Phoenix WebSocket Notes

The Websocket protocol allows for ongoing, persistent connections between a client and a server, allowing for real-time two-way communication.

In a Phoenix app, it starts in the endpoint.

defmodule AppWeb.Endpoint do
  use Phoenix.Endpoint, otp_app: :app
  socket "/socket", AppWeb.UserSocket
josephan / game_of_life.rb
Created Jul 29, 2017
Conway's Game Of Life
View game_of_life.rb
class GameOfLife
attr_reader :height, :width
def initialize
@board = {
[10,10] => true,
[10,11] => true,
[10,12] => true,
@height = 40
josephan / lecture1.ex
Last active Jul 17, 2017
Computer Science 61A - Lecture 1: functional programming 1
View lecture1.ex
defmodule Lecture1 do
def add(list), do: add(list, 0)
defp add([h | t], acc), do: add(t, acc + h)
defp add([], acc), do: acc
def mult(list), do: mult(list, 1)
defp mult([h | t], acc), do: mult(t, acc * h)
defp mult([], acc), do: acc