Skip to content

Instantly share code, notes, and snippets.

{
"nodes": [
{
"id": "Markus_Stenz"
},
{
"id": "Erik_Bergman"
},
{
"id": "William_Blezard"
findColumn : Location -> Board -> [Location]
findColumn (x,y) board = (findAbove (x,y) board) ++ (findBelow (x,y) board)
findAbove : Location -> Board -> [Location]
findAbove (x,y) board =
if Dict.member (x,y+1) board
then [(x,y)] ++ findAbove (x,y+1) board
else [(x,y)]
@AlexNisnevich
AlexNisnevich / shuffle.elm
Last active February 13, 2017 15:07
Shuffling a list in Elm
import List
import Random
without : Int -> [a] -> [a]
without i arr =
let before = take i arr
after = drop (i+1) arr
in
before ++ after
@AlexNisnevich
AlexNisnevich / request_example.rs
Created October 7, 2014 02:07
JSON requests with rust-http
extern crate serialize;
extern crate http;
extern crate url;
use std::string::String;
use serialize::json;
use serialize::json::Json;
use serialize::json::ToJson;
use http::client::RequestWriter;
use http::headers::content_type::MediaType;
@AlexNisnevich
AlexNisnevich / Sound Effects
Created August 25, 2014 10:43
I think these are all the sound effects?
General effects:
- jump
- fall off screen
- get key and move to next level
- overlay world (maybe different for each world type?)
Zombie world:
- zombie growl
- player killed by barbed wire
- player killed by zombie
@AlexNisnevich
AlexNisnevich / Tips
Last active January 4, 2016 13:08
RailsBridge tips [ http://git.io/WCKhtA ]
Thanks for coming to RailsBridge!!
If you have any questions at any time, feel free to email us at
alex [dot] nisnevich [at] gmail [dot] com
markmillan [at] gmail.com
lindseysugino [at] gmail.om
Resources
=========
if (map.getPlayer().getX()>10) me.move('right');
if (map.getPlayer().getX()<10) me.move('left');
if (map.getPlayer().getY()>10) me.move('down');
if (map.getPlayer().getY()<10) me.move('up');
[num_features, num_states] = size(backup_states_phi); % [22, 92]
num_actions = size(R{1}{1}); % 40
num_blocks = block_idx; % 7
mu0 = ones(num_states, 1) / num_states;
% cvx_solver sedumi
cvx_begin
variable theta(num_features)
variable V(num_states, num_blocks)
minimize sum(dot(mu0, (transpose(theta) * backup_states_phi))) + C * norm(theta)
@AlexNisnevich
AlexNisnevich / lucky_numbers.rb
Created April 26, 2013 11:37
Calculates lucky numbers up to a given limit, and prints the list of unlucky numbers removed for each lucky number
limit = 1000
nums = (1..limit).to_a
([1] + nums).each do |a|
lucky_num = nums[a]
unlucky_nums = nums.values_at(* nums.each_index.select {|i| (i+1) % lucky_num == 0})
if unlucky_nums.size == 0
break
else
@AlexNisnevich
AlexNisnevich / ling_diversity.rb
Last active December 10, 2015 23:29
Calculating the "Linguistic Diversity Index" (% chance that two random residents of a given country have different native languages)
require 'mechanize'
agent = Mechanize.new
language_regex = Regexp.new(/]\r\n\t\t\t\t\t\t([0-9,]*)(\.| )/)
index_page = agent.get('http://www.ethnologue.com/country_index.asp?place=all')
index_page.links_with(:href => /show_country.asp/).each do |country_link|
country = country_link.text().strip()
speakers = []