Skip to content

Instantly share code, notes, and snippets.

View SPY's full-sized avatar

Ilya Rezvov SPY

  • Google
  • Denver, USA
View GitHub Profile
@SPY
SPY / gist:5684674
Last active December 17, 2015 22:49
Simple Maybe implementation
(function(window) {
function Some(v) {
this.value = v;
}
Some.prototype = {
map: function(f) {
return some(f(this.value));
},
isNone: false,
@SPY
SPY / gist:5378202
Created April 13, 2013 12:30
i have error rbtree.rs:53:24: 53:33 error: assigning to mutable field prohibited due to outstanding loan rbtree.rs:53 None => self.left = Some(self.make_child(k, v)) ^~~~~~~~~ rbtree.rs:51:18: 51:27 note: loan of mutable field granted here rbtree.rs:51 match self.left { ^~~~~~~~~
pub fn insert(&mut self, k: K, v: V) {
if k < self.key {
match self.left {
Some(ref mut l) => l.insert(k, v),
None => self.left = Some(self.make_child(k, v))
}
}
else if k > self.key {
match self.right {
Some(ref mut r) => r.insert(k, v),
@SPY
SPY / gist:4756905
Last active December 12, 2015 10:08
typescript module usage
module Game.Player {
class Player {
public skills: Skill[];
}
export class Skill {
}
}
observe_search_query({search_query, {product, PropsSorted}, OffsetLimit}, Context) ->
%% io:format("~p~n", [PropsSorted]),
#search_sql{select="*", from="product", tables=[{product, "product"}]};
observe_search_query({search_query, Req, OffsetLimit}, Context) ->
z_notifier:first({search_query, Req, OffsetLimit}, Context).
%begin
{R, cmsg_player_login, D} ->
{ok, CharId} = realm_patterns:cmsg_player_login(D),
Char = char_helper:find(CharId),
ok = set_dungeon_difficulty(S, -1),
MapPid = verify_world(S, Char),
ok = send_account_data(S),
ok = set_rest_start(S),
ok = set_tutorial_flags(S),
ok = send_spells_and_cooldowns(S),
authenticate(Opcode, Data, State) ->
case logon_patterns:auth_request(Data) of
{ok, Build, Account} ->
case account_helper:find_by_name(Account) of
[AccountRecord] ->
H = srp6:challenge(AccountRecord),
NewState = State#logon_state{authenticated=no, account=AccountRecord, hash=H},
{send, logon_patterns:auth_reply(H), NewState};
_ ->
{send, logon_patterns:error(Opcode, account_missing), State}