Skip to content

Instantly share code, notes, and snippets.

View nathancyam's full-sized avatar

Nathan Yam nathancyam

  • Melbourne, Australia
  • 00:50 (UTC +10:00)
View GitHub Profile
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View viewFrag = inflater.inflate(R.layout.fragment_prop, container, false);
propArrayAdapter = new ArrayAdapter<Prop>(getActivity(), android.R.layout.simple_list_item_1, android.R.id.text1, ServerLink.properties);
setListAdapter(propArrayAdapter);
return viewFrag;
}
public Event createEvent(String location, String dateString, String timeString, String nameString){
ContentValues values = new ContentValues();
values.put(MySQLiteHelper.COLUMN_LOCATION, location);
values.put(MySQLiteHelper.COLUMN_DATE, dateString);
values.put(MySQLiteHelper.COLUMN_TIME, timeString);
values.put(MySQLiteHelper.COLUMN_NAME, nameString);
// This inserts the entry to the database
long insertId = database.insert(MySQLiteHelper.TABLE_EVENTS, null, values);
// This makes sure that the database points to the new product
@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) {
@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());
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++) {
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);
using UnityEngine;
namespace EnemyBehaviour
{
public class Attack : IEnemyBehaviour
{
public EnemyController EnemyCtrl
{
get => mobile.m_EnemyController;
}
@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'
@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 / 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