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
| 1> l(pteracuda_nifs). | |
| {module,pteracuda_nifs} | |
| 2> {ok, Ctx} = pteracuda_nifs:new_context(). | |
| {ok,<<>>} | |
| 3> {ok, Buf} = pteracuda_nifs:new_buffer(). | |
| {ok,<<>>} | |
| 4> F = fun(_, _) -> random:uniform(100) > 49 end. | |
| #Fun<erl_eval.12.113037538> | |
| %% Randomize a list | |
| 5> N = lists:sort(F, lists:seq(1, 1000000)). |
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
| Mod = smerl:new(maths), | |
| {ok, Mod1} = smerl:add_func(Mod, "add(X, Y) -> X + Y."), | |
| smerl:compile(Mod1), | |
| 5 = maths:add(2, 3), | |
| {ok, Mod2} = smerl:add_func(Mod1, "mult(X, Y) -> X * Y."), | |
| smerl:compile(Mod2), | |
| 5 = maths:add(2, 3), | |
| 42 = maths:mult(6, 7). |
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
| /* | |
| * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. | |
| * | |
| * Redistribution and use in source and binary forms, with or without | |
| * modification, are permitted provided that the following conditions | |
| * are met: | |
| * | |
| * - Redistributions of source code must retain the above copyright | |
| * notice, this list of conditions and the following disclaimer. | |
| * |
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(test). | |
| -include_lib("eunit/include/eunit.hrl"). | |
| %% A very silly define indeed. | |
| -define(FOO, 1). | |
| -export([test/0, | |
| test/2]). |
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
| 2> F = multi_head:make_fun(). | |
| #Fun<multi_head.0.128697214> | |
| 3> F(foo). | |
| ok | |
| 4> F(bar). | |
| less_ok | |
| 5> F(baz). | |
| really_bad | |
| 6> F(quux). | |
| ** exception error: no function clause matching |
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
| 2> code:unstick_mod(os). | |
| true | |
| 3> meck:new(os). | |
| ok | |
| 4> meck:expect(os, timestamp, fun() -> 123 end). | |
| Crash dump was written to: erl_crash.dump | |
| The code server called the unloaded module `os' |
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
| %% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*- | |
| %% ex: ts=4 sw=4 et | |
| %% @author Kevin Smith <kevin@opscode.com> | |
| %% @copyright 2011 Opscode, Inc. | |
| -module(example). | |
| -behaviour(gen_server). | |
| -export([start_link/0]). |
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
| #!/usr/bin/env escript | |
| %% -*- erlang -*- | |
| %% Find unused exports in a given module | |
| %% Example: deadcode mod_foo deps/foo/ebin deps/bar/ebin | |
| %% Assumes this script is in a file named deadcode | |
| main([Module0|Dirs]) -> | |
| Module = list_to_atom(Module0), | |
| {ok, _Pid} = xref:start(foo), |
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
| g++> #include <unistd.h> | |
| g++> sizeof(pid_t); | |
| g++> #include <stdio.h> | |
| g++> printf("%d\n", sizeof(pid_t)); | |
| 4 | |
| g++> typedef pid_t (*child_fun)(void); | |
| g++> sizeof(child_fun); | |
| g++> printf("%d\n", sizeof(child_fun)); | |
| 8 | |
| g++> |
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
| 1> specs(test). | |
| greeting(string(), integer()) -> [string()] | nil() | |
| foo() -> ok | |
| doit() -> ok | |
| ok | |
| 2> specs({test, greeting, 2}). | |
| greeting(string(), integer()) -> [string()] | nil() | |
| ok | |
| 3> docs({test, greeting, 2}). | |
| greeting/2: "This is another test" |