Skip to content

Instantly share code, notes, and snippets.

View nathancyam's full-sized avatar

Nathan Yam nathancyam

  • Melbourne, Australia
  • 11:55 (UTC +10:00)
View GitHub Profile
@nathancyam
nathancyam / .projections.json
Last active December 6, 2023 06:09
Elixir projectionist setup
{
"lib/*.ex": {
"alternate": "test/{}_test.exs",
"type": "source"
},
"test/*_test.exs": {
"alternate": "lib/{}.ex",
"type": "test"
}
}
@nathancyam
nathancyam / routing.ex
Created October 10, 2023 02:42
PID to strings
# See https://youtu.be/E315pukytFI?t=1251
defmodule PidString do
def to_string(pid \\ self()) do
pid
|> :erlang.term_to_binary()
|> Base.encode64()
end
def to_pid(s) do
s
@nathancyam
nathancyam / config.lua
Last active June 1, 2023 08:37
Lunarvim setup
--[[
lvim is the global options object
Linters should be
filled in as strings with either
a global executable or a path to
an executable
]]
-- THESE ARE EXAMPLE CONFIGS FEEL FREE TO CHANGE TO WHATEVER YOU WANT
@nathancyam
nathancyam / worker.go
Last active August 31, 2022 12:03
Naive worker pool with job drainer behaviour
package main
import (
"fmt"
"os"
"os/signal"
"runtime"
"sync"
"syscall"
"time"
@nathancyam
nathancyam / init.vim
Created November 26, 2019 05:39
Neovim setup
call plug#begin('~/.config/nvim/plugged')
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'ycm-core/YouCompleteMe', { 'do': './install.py' }
Plug 'slashmili/alchemist.vim'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'elixir-editors/vim-elixir'
Plug 'itchyny/lightline.vim'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
using UnityEngine;
namespace EnemyBehaviour
{
public class Attack : IEnemyBehaviour
{
public EnemyController EnemyCtrl
{
get => mobile.m_EnemyController;
}
function disco() {
function randomElement(arr) {
return arr[Math.floor(Math.random() * (arr.length - 1))];
}
var blocks = Array.prototype.slice.call(document.querySelectorAll("#wallboard .build > .result"));
var colours = ["pink", "blue", "white", "purple", "grey", "red", "yellow"];
var randomBlock = randomElement(blocks)
randomBlock.style.background = randomElement(colours);
public String getMD5(String mobilePassword) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("MD5");
String fullHash = mobilePassword + getDate();
md.update(fullHash.getBytes());
byte byteData[] = md.digest();
StringBuffer hexString = new StringBuffer();
for (int i=0;i<byteData.length;i++) {
@nathancyam
nathancyam / AuthHttpHandler.java
Created June 16, 2013 06:47
Auth Http Handler
public class AuthHttpHandler {
private String URI_GET_AUTH = "http://melfridinbot.appspot.com/mobile/checkauth";
protected void authRequest(String mobilePassword, String userEmail) throws NoSuchAlgorithmException, IOException {
HttpClient client = new DefaultHttpClient();
HttpGet getRequest = new HttpGet(URI_GET_AUTH);
getRequest.addHeader("token", getMD5(mobilePassword));
getRequest.addHeader("tokenDate", getDate());
@nathancyam
nathancyam / EventAdd.java
Created June 10, 2013 02:25
EventAdd desu
public class EventAdd extends Fragment {
Date simpleDateFormat;
TextView dateText;
TextView timeText;
EditText locationText;
EditText nameText;
Button addEventBtn;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {