Skip to content

Instantly share code, notes, and snippets.

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
josephan / CloseActiveWindow.cs
Last active June 22, 2022 15:32
Unity Editor keyboard shortcut to close active undocked window
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
josephan / _instructions.md
Last active February 3, 2024 06:54
Windows 10: From the start menu, focus Google Chrome if it's open otherwise open a new window.

Problem

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.

Goal

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.

Instructions

@josephan
josephan / settings.json
Created May 6, 2020 16:25
Settings for VSCode and Vim extension
{
"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
josephan / setup_tailwind_in_phoenix.md
Last active August 8, 2023 05:50
Add Tailwind CSS to an Elixir/Phoenix Project with PurgeCSS
@josephan
josephan / vimr-crash-log
Created November 29, 2018 14:55
SNAPSHOT-294
Process: VimR [1273]
Path: /Applications/VimR.app/Contents/MacOS/VimR
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
josephan / guide.md
Last active October 29, 2018 01:31
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": [
 "@babel/preset-env",
@josephan
josephan / websocket.md
Last active November 2, 2018 20:56
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
josephan / game_of_life.rb
Created July 29, 2017 02:52
Conway's Game Of Life
class GameOfLife
attr_reader :height, :width
def initialize
@board = {
[10,10] => true,
[10,11] => true,
[10,12] => true,
}
@height = 40
@josephan
josephan / lecture1.ex
Last active July 17, 2017 02:21
Computer Science 61A - Lecture 1: functional programming 1
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
end