Skip to content

Instantly share code, notes, and snippets.

defmodule ColonyGame.Game.ForagingServer do
use GenServer
alias ColonyGame.Game.PlayerProcess
# Food regrows every 10 ticks
@tick_interval 30
def start_link(_arg) do
GenServer.start_link(__MODULE__, %{}, name: __MODULE__)
end
@romanmt
romanmt / takehome-test-ui-readme.md
Last active September 9, 2019 19:07
Take Home Test UI

For this assignment, we'd like you to: Create a simple web UI for creating and displaying dental appointments. The appointments can be stored in memory so you can avoid the need for a server or database.

The appointments should conform to the following interface:

DentalAppointment

  startTime: DateTime or unix timestamp
  endTime: DateTime or unix timestamp
 dentistName: String
@romanmt
romanmt / anagram.js
Last active September 2, 2016 22:39
Anagram Dictionary
import _, {reject, every, includes} from 'lodash'
const dictionary = [ "a", "sand", "car", "ester", "reset", "steer", "terse", "trees" ]
export function getMatches(characterString) {
let characters = characterString.split("")
return reject(dictionary, (entry) => {
return !every(characters, (character) => {
return includes(entry, character)
@romanmt
romanmt / function.snippets
Created January 23, 2013 15:29
Snippet file for a function
# -*- mode: snippet -*-
# name: f
# key: f
# binding: C-q f
# type: command
# --
function $1($2) {
$0
}
var _ = require('underscore')
var levers = [
{ id: '1', val: 'one'},
{ id: '2', val: 'two'},
{ id: '3', val: 'three'},
]
var ids = ['1', '3']
@romanmt
romanmt / gist:4485038
Created January 8, 2013 16:13
join problem
var Levers = function() {
var exports = {
select: function(ids, levers, defaults) {
function mapper(element) {
return levers[element] || _(defaults).extend({id: element});
}
return _(ids).map(mapper);
},
objectify: function(levers) {
@romanmt
romanmt / gist:4453642
Created January 4, 2013 15:55
epsilon greedy algo implemented as jquery
(function(global) {
"use strict";
// Just some hardcoded stuff until i wire up the backend
$(document).ready(function initializeTest() {
var test = $('.epsilon-test')
var name = test.attr('id')
var levers = _.map(test.find('.epsilon-lever'), function (lever) {
$(lever).hide();
return $(lever).attr('id');
@romanmt
romanmt / coinchange.spec.coffee
Created November 14, 2012 17:08
Coin change kata
_ = require 'underscore'
changeForDenomination = (denomination, amount) ->
to = Math.floor(amount / denomination)
if to > 0 then [1..to].map () -> denomination else []
makeChange = (amount, denominations = [25, 10, 5 , 1]) ->
denomination = _.first denominations
if denomination
changeForDenomination(denomination, amount)
@romanmt
romanmt / promotion.js
Created July 31, 2012 18:52
mongoose promise
Promotion.methods.isActive = function isActive(cb) {
var promise = new mongoose.Promise;
if(cb) promise.addBack(cb);
Click.findOne({_promotion: this._id}, function(err, click) {
if(err) return promise(err);
promise.complete(!!click)
})
return promise;
}
Promotion.pre('save', true, function(next, done) {
next();
var self = this;
short.generate(settings.baseURL + '/promotion/' + this._id + '/show', function(err, url) {
self.url = settings.baseURL + '/' + url.hash;
done();
})
})
Promotion.pre('save', true, function(next, done) {