Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴
On vacation

Joseph An josephan

🌴
On vacation
View GitHub Profile
@josephan
josephan / _instructions.md
Last active Dec 16, 2020
Windows 10: From the start menu, focus Google Chrome if it's open otherwise open a new window.
View _instructions.md

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

  1. Create a Windows Powershell Script in any directory called chrome.ps1. Example: C:\Users\<USERNAME>\Documents\chrome.ps1
@josephan
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
josephan / setup_tailwind_in_phoenix.md
Last active Aug 17, 2021
Add Tailwind CSS to an Elixir/Phoenix Project with PurgeCSS
View setup_tailwind_in_phoenix.md
View vimr-crash-log
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 Oct 29, 2018
How To Add React To Phoenix 1.4
View guide.md

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 Nov 2, 2018
Phoenix WebSocket Notes
View websocket.md

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 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
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
end
@josephan
josephan / mix.md
Created Jun 21, 2017
Dependency issues
View mix.md
  defp deps do
    [{:phoenix, "~> 1.2.1"},
     {:phoenix_pubsub, "~> 1.0"},
     {:phoenix_ecto, "~> 3.0"},
     {:postgrex, ">= 0.0.0"},
     {:phoenix_html, "~> 2.6"},
     {:phoenix_live_reload, "~> 1.0", only: :dev},
     {:gettext, "~> 0.11"},
     {:cowboy, "~> 1.0"},
View deprecation_message.ex
# Programming Phoenix Version: P1.0 (April 2016)
# I have the following changeset for my User model:
def changeset(model, params \\ :empty) do
model
|> cast(params, ~w(name username), [])
|> validate_length(:username, min: 1, max: 20)
end
# but I get the following deprecation warning