This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Shell do | |
| def escape_value(value), do: escape_value(value, "") | |
| defp escape_value("", res), do: "\"#{res}\"" | |
| defp escape_value("\"" <> value, res), do: escape_value(value, res <> "\\\"") | |
| defp escape_value("\\" <> value, res), do: escape_value(value, res <> "\\\\") | |
| defp escape_value(<<char :: utf8, rest :: binary>>, res), | |
| do: escape_value(rest, res <> <<char>>) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| is_primary_for_doc(BKey) -> | |
| {ok, CHBin} = riak_core_ring_manager:get_chash_bin(), | |
| DocIdx = riak_core_util:chash_key(BKey), | |
| Itr = chashbin:iterator(DocIdx, CHBin), | |
| MyNode = node(), | |
| case chashbin:itr_value(Itr) of | |
| {Idx, Node} when Node == MyNode -> true; | |
| {_Idx, _Node} -> false | |
| end. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -module(udp_test). | |
| -behaviour(gen_server). | |
| -define(SERVER, ?MODULE). | |
| -define(PORT, 9876). | |
| %% ------------------------------------------------------------------ | |
| %% API Function Exports | |
| %% ------------------------------------------------------------------ | |
| -export([start_link/2, send/1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #lang scheme | |
| ;;; lambda-dictionary | |
| ;;; | |
| (define (make-dict pairs) | |
| (define (pair-key p) (car p)) | |
| (define (find key pairs) | |
| (define (target? p) | |
| (equal? key (pair-key p))) | |
| ;; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (define-syntax class | |
| (syntax-rules (extends rmethods method) | |
| ((_ rmethods () r) `r) | |
| ((_ rmethods ((method (name arg1 ...) body ...) . methods) r) | |
| (class rmethods methods ((name . ,(lambda (self arg1 ...) body ...)) . r))) | |
| ((_ header (extends parent) body ...) | |
| (define header | |
| (define methods (class rmethods (body ...) ())) | |
| (make-dispatcher-self (extends (make-dict methods) parent)))) | |
| ((_ header body ...) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data IntSet = Empty | |
| | Node { val :: Int, | |
| left :: IntSet, | |
| right :: IntSet } deriving Show | |
| incl Empty x = Node x Empty Empty | |
| incl node x | x < val node = node { left = incl (left node) x } | |
| | x > val node = node { right = incl (right node) x } | |
| | otherwise = node |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cowboy_config() -> | |
| {ok, App} = application:get_application(), | |
| Disp = [ | |
| {'_', [ | |
| {[<<"combiners">>, <<"test">>], combiner_test_src, []}, | |
| {[<<"combiners">>, <<"list">>], combiners_list, []}, | |
| {[<<"combiners">>, <<"info">>, comb_name], combiner_info, []}, | |
| {[<<"combiners">>, '...'], cowboy_http_static, [ | |
| {directory, {priv_dir, App, []}}, | |
| {mimetypes, [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -module(pdscope). | |
| -export([pput/1, pget/0, pdscope/1, example/0]). | |
| pput(X) -> | |
| erlang:put(?MODULE, X). | |
| pget() -> | |
| erlang:get(?MODULE). | |
| pdscope(Scope, F) -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -module(sp_config_srv). | |
| -behaviour(gen_server). | |
| -define(NODEUP_PAUSE, 100). | |
| %% ------------------------------------------------------------------ | |
| %% API Function Exports | |
| %% ------------------------------------------------------------------ | |
| -export([ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {- | |
| Bal ::= (Bal)Bal | [Bal]Bal | "" | |
| -} | |
| import Control.Monad | |
| brackets = [('[',']'), ('(',')')] | |
| isObr b = elem b (map fst brackets) | |
| isCoBr b1 b2 = elem (b1,b2) brackets || elem (b2,b1) brackets |
NewerOlder