Skip to content

Instantly share code, notes, and snippets.

xianny /
Last active Sep 3, 2021
Google Apps Script to sync personal calendar with work calendar
Google Drive > New > Apps Script
Paste below into file
On the left sidebar, look for triggers menu to add a time-based trigger.
const ID = "" // FILL IN secondary calendar ID
const EVENT_NAME = "busy (autosync)" // change event name
const DAYS_TO_SYNC = [1,2,3,4,5] // add 6, 7 to monitor weekends too
const DAYS_BUFFER = 14 // how many days in advance to monitor
xianny / tictactoe.go
Created Mar 17, 2017
Tic Tac Toe in Go with Minimax AI
View tictactoe.go
package main
import (
func playerToken(b bool) (c string) {
xianny / Board.scala
Created Feb 28, 2017
General purpose board for grid-based board games
View Board.scala
package com.xianny.gameutils
1 2 3
1 (1,1) (2,1) (3,1)
2 (1,2) (2,2) (3,2)
3 (1,3) (2,3) (3,3)
// object BoardTest {
xianny / jekyll-new
Last active Feb 28, 2017
View jekyll-new
# This script creates a new post or draft in jekyll with pre-filled front matter
# ./script some title for your post
# use -d option for draft
while getopts "d" opt; do
case $opt in
View tictactoe.scala
object Game {
val cols = Seq("1", "2", "3")
val rows = Seq("A", "B", "C")
val default = "_"
def token(player: Boolean) = if (player) "X" else "O"
View edge-contraction.js
/* Small script for edge contraction of graphs. I was reading about
randomised algorithms, which led to Karger's algorithm for finding
min-cut of a graph, which led to reading about graphs and cutsets,
and then wanting to find out how graphs and edge contraction can be
represented in code...
To run, just do `node edge-contraction.js` */
var graph =
[ ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'],
View Scala Days Berlin


Scaladays Keynotes

Scala 2.12 is the new big thing! It has 33 near features, but more importantly it contains optimizations for Java 8 using Java 8 language features such as lambdas and default methods, while still being backwards compatible with Java 6.

Scala 2.13 more focused on improving scala’s built-in libraries, including the collections library. Particularly, it will become more inline with spark collections and more have more robust lazy collection support. There are also plans to separate Scala into a core and platform module.

Neat things happening with Scala:

  • Scala.js
  • Scala native

Poppin' Bottles

You've just been hired at Lighthouse Markets, a reputable (and thoroughly fictional) grocery store chain. One of the primary features of Lighthouse Markets is their recycling program on pop bottles. Here is how the program works:

  • For every two empty bottles, you can get one free (full) bottle of pop
  • For every four bottle caps, you can get one free (full) bottle of pop
  • Each bottle of pop costs $2 to purchase

Given these parameters, write a program so that you can figure out how many total bottles of pop can be redeemed given a customer investment.