Skip to content

Instantly share code, notes, and snippets.

View SPY's full-sized avatar

Ilya Rezvov SPY

  • Google
  • Denver, USA
View GitHub Profile
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}
%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),
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).
@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 {
}
}
@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: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 / Hello.hs
Last active December 29, 2015 00:48
{-# LANGUAGE BangPatterns, DeriveDataTypeable, FlexibleInstances, MultiParamTypeClasses #-}
module Proto.King.Hello (Hello(..)) where
import Prelude ((+), (/))
import qualified Prelude as Prelude'
import qualified Data.Typeable as Prelude'
import qualified Data.Data as Prelude'
import qualified Text.ProtocolBuffers.Header as P'
import qualified Proto.King.NodeDescription as King (NodeDescription)
data Hello = Hello{hNodeDesc :: !King.NodeDescription}
@SPY
SPY / gen_server.hs
Last active December 30, 2015 06:19
instance GenServerState Command Int CounterState where
handle_call Get = gets counter
handle_cast Inc =
modify $ \st -> st { counter = counter st + 1 }
-- another instance for CounterState
instance GenServerState Command Float CounterState where
handle_call Get = gets (fromIntegral . counter)
@SPY
SPY / andb_eq_orb.v
Last active January 1, 2016 22:38
(** **** Exercise: 2 stars (andb_eq_orb) *)
(** Prove the following theorem. (You may want to first prove a
subsidiary lemma or two.) *)
Lemma orb_always_true :
forall b,
orb true b = true.
Proof. reflexivity. Qed.
Lemma andb_always_false :
@SPY
SPY / index.html
Last active August 29, 2015 14:14
Minimal webpack for ReactJS with ES6
<!DOCTYPE html>
<html>
<head><title>Example</title></head>
<body>
<script type="text/javascript" src="http://localhost:8090/webpack-dev-server.js"></script>
<script type="text/javascript" src="http://localhost:8090/assets/bundle.js"></script>
</body>
</html>