previndexinfonext

code guessing, round #73 (completed)

started at ; stage 2 at ; ended at

specification

oh, happy day! sunshine returns to cg valley. now please connect to this websocket. submissions may be written in any language.

WebSocket is a communications protocol. I'm not going to detail the whole thing here, but I can explain the handshake. a WebSocket connection starts as a special kind of HTTP ≥1.1 request with at minimum the following headers, and no body:

Connection: upgrade
Upgrade: websocket
Host: hostname.com
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: Some16ByteBase64NonceA==

the server responds, likewise with no body:

Connection: upgrade
Upgrade: websocket
Sec-WebSocket-Accept: 9WOgMTgkwOaUOmn9o5tTgvhZ2SA=

for those who missed it, Sec-WebSocket-Accept in the server's response is equal to base64(sha1(Sec-WebSocket-Key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11")), where + denotes string concatenation.

at this point, the opening handshake is complete and the interlocutors may now begin sending messages to each other.

your challenge is to connect to the WebSocket server running at wss://codeguessing.gay/73/ws. as this challenge only requires performing a fixed task, no API is necessary.

incidentally, this server sends and receives text messages with the following interface:

results

  1. 👑 oleander +4 -0 = 4
    1. rrebeccca (was kimapr)
    2. Moja
    3. Makefile_dot_in
    4. kimapr (was moshikoi)
    5. olive
    6. moshikoi (was rrebeccca)
    7. Dolphy
  2. Dolphy +3 -1 = 2
    1. moshikoi (was oleander)
    2. kimapr
    3. Moja
    4. Makefile_dot_in
    5. oleander (was moshikoi)
    6. rrebeccca (was olive)
    7. olive (was rrebeccca)
  3. moshikoi +0 -0 = 0
    1. kimapr (was oleander)
    2. Makefile_dot_in (was kimapr)
    3. Dolphy (was Moja)
    4. olive (was Makefile_dot_in)
    5. rrebeccca (was olive)
    6. Moja (was rrebeccca)
    7. oleander (was Dolphy)
  4. rrebeccca +0 -0 = 0
    1. Moja (was oleander)
    2. oleander (was kimapr)
    3. Makefile_dot_in (was Moja)
    4. Dolphy (was Makefile_dot_in)
    5. olive (was moshikoi)
    6. kimapr (was olive)
    7. moshikoi (was Dolphy)
  5. kimapr +0 -1 = -1
    1. olive +0 -1 = -1
      1. Moja +0 -2 = -2
        1. Makefile_dot_in +0 -2 = -2
          1. kimapr (was oleander)
          2. Moja (was kimapr)
          3. moshikoi (was Moja)
          4. oleander (was moshikoi)
          5. rrebeccca (was olive)
          6. Dolphy (was rrebeccca)
          7. olive (was Dolphy)

        entries

        you can download all the entries

        entry #1

        written by oleander
        submitted at
        0 likes

        guesses
        comments 0

        post a comment


        73_final_2.html ASCII text, with CRLF line terminators
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        22
        23
        24
        25
        26
        27
        28
        29
        30
        31
        32
        33
        34
        35
        36
        37
        38
        39
        40
        41
        42
        43
        44
        45
        46
        47
        48
        49
        50
        51
        52
        53
        54
        55
        56
        57
        58
        59
        60
        61
        <!DOCTYPE html>
        <html>
        <head>
        <title>CG 73</title>
        </head>
        <body>
        
        
        <p id='chatbox' style='font-family: monospace;position:absolute;bottom:20px;'></p>
        
        <span style='position:absolute;bottom:5px;'>
        <input type='text' id='typebox' placeholder='type here!'> </input>
        </span>
        
        </body>
        <script>
        
        document.getElementById('typebox').onkeydown = function (e) {if (e.key == 'Enter') { send(); }};
        
        function datasend(socket, data) {socket.send(JSON.stringify(data))}
        	
        var wsurl = 'wss://codeguessing.gay/73/ws';
        
        let socket = new WebSocket(wsurl);
        
        socket.onerror = function() {window.alert('ERROR CONNECTING TO SERVER')}
        
        socket.onmessage = function (message) {
        console.log(message.data)
        returndata = JSON.parse(message.data);
        name = returndata['name']
        color = name.slice(0,name.indexOf('_'));
        
        if (returndata['reason'] == 'connect') {
        newtext=('<b><span style="color:'+color+';">'+name+' connected'+'</span></b><br>')
        write(newtext)}
        
        if (returndata['reason'] == 'disconnect') {
        newtext=('<b><span style="color:'+color+';">'+name+' disconnected'+'</span></b><br>')
        write(newtext)}
        
        if (returndata['reason'] == 'message') {
        newtext=('<b><span style="color:'+color+';">'+name+'</span></b>  '+returndata['content']+'<br>')
        write(newtext)}
        
        }
        
        function write(newtext){
        document.getElementById('chatbox').innerHTML=document.getElementById('chatbox').innerHTML+newtext;
        }
        
        
        function send() {
        	message=document.getElementById("typebox").value
        	if (message!=''){
        		document.getElementById("typebox").value='';
        		var newmessage = {'content': message}
        		datasend(socket, newmessage)}
        	}
        
        </script>
        

        entry #2

        written by kimapr
        submitted at
        0 likes

        guesses
        comments 0

        post a comment


        entry.php ASCII text
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        22
        23
        24
        25
        26
        27
        28
        29
        30
        31
        32
        33
        34
        35
        36
        37
        38
        39
        40
        41
        42
        43
        44
        45
        46
        47
        48
        49
        50
        51
        52
        53
        54
        55
        56
        57
        58
        59
        60
        61
        62
        63
        64
        65
        66
        67
        68
        69
        70
        71
        72
        73
        74
        75
        76
        77
        78
        79
        80
        81
        82
        83
        84
        85
        86
        87
        88
        89
        90
        91
        92
        93
        94
        95
        96
        97
        <?php
        
        ob_start(function($buffer) {
        	fwrite(STDERR, $buffer);
        }, 1);
        
        if (!(
        	file_exists(__DIR__.'/vendor/amphp/amp') &&
        	file_exists(__DIR__.'/vendor/amphp/byte-stream') &&
        	file_exists(__DIR__.'/vendor/amphp/websocket-client')))
        {
        	$composer_path = 'composer';
        
        	system($composer_path." -qV", $result_code);
        
        	if ($result_code) {
        		$composer_path = __DIR__.'/composer';
        		copy("https://getcomposer.org/download/latest-stable/composer.phar", $composer_path);
        		chmod($composer_path, 0755);
        	}
        
        	system('cd '.__DIR__.'; '.$composer_path.' require '.implode(' ', [
        		'amphp/websocket-client',
        		'amphp/byte-stream',
        		'amphp/amp'
        	]));
        }
        
        require __DIR__.'/vendor/autoload.php';
        
        use function \Amp\async;
        use function \Amp\delay;
        use function \Amp\Websocket\Client\connect;
        use function \Amp\ByteStream\getStdin;
        use \Amp\ByteStream\BufferedReader;
        
        echo 'connecting -';
        
        $conn = false;
        
        $spin = 0;
        
        async(function() {
        	global $conn, $spin;
        
        	while (!$conn) {
        		$spin += 1;
        		$spin %= 4;
        		echo "\x08".['-','\\',"|",'/'][$spin];
        		delay(0.1);
        	}
        });
        
        $conn = connect('wss://codeguessing.gay/73/ws');
        echo "\r            \r";
        
        ob_end_flush();
        
        async(function() {
        	global $conn;
        
        	foreach($conn as $msg) {
        		$msg = $msg->buffer();
        		$msg = json_decode($msg);
        
        		switch($msg->reason) {
        
        		case "connect":
        			echo"*** ".$msg->name." joined the game. ***\n";
        			break;
        
        		case "disconnect":
        			echo "*** ".$msg->name." left the game. ***\n";
        			break;
        
        		case "message":
        			if (is_string($msg->content)) {
        				echo "<".$msg->name."> ".$msg->content."\n";
        				break;
        			}
        
        		default:
        			echo json_encode($msg)."\n";
        		}
        	}
        });
        
        $io = new BufferedReader(getStdin());
        
        while(1) {
        	try {
        		$x = $io->readUntil("\n");
        	} catch (Exception $e) {
        		break;
        	}
        	$conn->sendText(json_encode(["content" => $x]));
        }
        

        entry #3

        written by Moja
        submitted at
        0 likes

        guesses
        comments 0

        post a comment


        olus.py ASCII text
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        12
        13
        14
        15
        16
        17
        from websockets.sync.client import connect
        
        def usa():
            uri = "wss://codeguessing.gay/73/ws"
            with connect(uri) as websocket:
                while True:
                    poland = input()
        
                    websocket.send(f'{{"content": "{poland}"}}')
                    print(f'{{"content": "{poland}"}}')
        
                    while input() == "r":
                        australia = websocket.recv()
                        print(f"message recieved: {australia}")
        
        if __name__ == "__main__":
            usa()
        

        entry #4

        written by Makefile_dot_in
        submitted at
        0 likes

        guesses
        comments 0

        post a comment


        Roboto-Regular.ttf TrueType Font data, 18 tables, 1st "GDEF", 13 names, Microsoft, language 0x409, Copyright 2011 Google Inc. All Rights Reserved.RobotoRegularVersion 2.001101; 2014Roboto-Regular
        cat.png PNG image data, 48 x 48, 8-bit/color RGBA, non-interlaced
        cg73.hs ASCII text
          1
          2
          3
          4
          5
          6
          7
          8
          9
         10
         11
         12
         13
         14
         15
         16
         17
         18
         19
         20
         21
         22
         23
         24
         25
         26
         27
         28
         29
         30
         31
         32
         33
         34
         35
         36
         37
         38
         39
         40
         41
         42
         43
         44
         45
         46
         47
         48
         49
         50
         51
         52
         53
         54
         55
         56
         57
         58
         59
         60
         61
         62
         63
         64
         65
         66
         67
         68
         69
         70
         71
         72
         73
         74
         75
         76
         77
         78
         79
         80
         81
         82
         83
         84
         85
         86
         87
         88
         89
         90
         91
         92
         93
         94
         95
         96
         97
         98
         99
        100
        101
        102
        103
        104
        105
        106
        107
        108
        109
        110
        111
        112
        113
        114
        115
        116
        117
        118
        119
        120
        121
        122
        123
        124
        125
        126
        127
        128
        129
        130
        131
        132
        133
        134
        135
        136
        137
        138
        139
        140
        141
        {- cabal:
        build-depends: base, wuss, websockets, aeson, lens, text, monomer, text-show, stm
        -}
        
        {-# LANGUAGE OverloadedStrings #-}
        {-# LANGUAGE TemplateHaskell #-}
        {-# LANGUAGE NamedFieldPuns #-}
        
        module Main where
        
        import Wuss
        import Network.WebSockets (receiveData, sendTextData)
        import Data.Aeson
        import Control.Lens hiding ((.=))
        import Data.Text (Text)
        import Monomer
        import Control.Concurrent.STM.TChan
        
        import Control.Monad (forever)
        import Data.Functor (void)
        import Control.Concurrent (forkIO)
        import Control.Concurrent.STM (atomically)
        import qualified Monomer.Lens as L
        
        data R
          = Connect { name :: Text }
          | Disconnect { name :: Text }
          | MessageR { name :: Text, content :: Text }
          deriving (Eq, Show)
        
        instance FromJSON R where
          parseJSON = withObject "R" $ \o -> do
            reason <- o .: "reason"
            case reason :: Text of
              "connect" -> Connect <$> o .: "name"
              "disconnect" -> Disconnect <$> o .: "name"
              "message" -> MessageR <$> o .: "name" <*> o .: "content"
              _ -> fail $ "Unknown reason: " <> show reason
        
        newtype S = S Text
        
        instance ToJSON S where
          toJSON (S content) = object ["content" .= content]
        
        data AppModel =
          AppModel
            { _messages :: [(Text, Text)]
            , _message :: Text
            , _users :: [Text]
            }
          deriving (Eq, Show)
        
        data AppEvent
          = AppInit
          | AppWsEvent R
          | AppSendMessage
          | AppMessageSent
          | AppScrollUpdate ScrollStatus
          deriving (Eq, Show)
        
        
        makeLenses 'AppModel
        
        connectWs :: TChan S -> (AppEvent -> IO ()) -> IO ()
        connectWs chan sendMessage =
          runSecureClient "codeguessing.gay" 443 "/73/ws" $ \con -> do
            void $ forkIO $ forever $ atomically (readTChan chan) >>= sendTextData con . encode
            forever $ receiveData con >>= mapM_ (sendMessage . AppWsEvent) . decode
        
        buildUI
          :: WidgetEnv AppModel AppEvent
          -> AppModel
          -> WidgetNode AppModel AppEvent
        buildUI _wenv model = widgetTree where
          widgetTree = hsplit_ [splitHandlePosV 0.9] (messageView, userlst)
          userlst = vscroll $ vstack $ map (`label_` [ellipsis]) $ model ^. users
          messageView = vstack_ [childSpacing]
            [ flip styleBasic [expandHeight 1]
              $ flip nodeKey "scroll"
              $ vscroll_
                [onChange AppScrollUpdate]
                  $ vstack_ [childSpacing] $ reverse $
                      map
                        (\(sender, content) -> hstack_ [childSpacing]
                          [ label sender
                          , if content == ":cat_with_gua_pi_mao_hat_tone5:" then
                              image "cat.png" `styleBasic` [width 48, height 48]
                            else
                              label_ content [multiline]
                          ])
                        (model ^. messages)
                      & ix 0 %~ (`nodeKey` "first")
            , keystroke [("Enter", AppSendMessage)] $ textField message
            ] `styleBasic` [padding 10]
        
        handleEvent
          :: TChan S
          -> WidgetEnv AppModel AppEvent
          -> WidgetNode AppModel AppEvent
          -> AppModel
          -> AppEvent
          -> [AppEventResponse AppModel AppEvent]
        handleEvent chan wenv _node model evt = case evt of
          AppInit ->
            [Producer $ connectWs chan]
          AppWsEvent (MessageR {name, content}) ->
            [ Model (model & messages %~ ((name, content):))
            , responseMaybe $
                Message (WidgetKey "scroll") . ScrollTo . view L.viewport <$>
                  nodeInfoFromKey wenv (WidgetKey "first")
            ]
          AppWsEvent (Connect {name}) ->
            [ Model (model & users %~ (name:)) ]
          AppWsEvent (Disconnect {name}) ->
            [ Model (model & users %~ filter (/=name)) ]
          AppSendMessage ->
            [ Task $ fmap (const AppMessageSent) $ atomically $ writeTChan chan $ S $ model ^. message
            , Model $ model & message .~ ""
            ]
          AppMessageSent ->
            []
          AppScrollUpdate (ScrollStatus {scrollRect = Rect x _ w h}) ->
            [Message (WidgetKey "scroll") $ Rect x (h+10) w (h+10)]
        
        
        main :: IO ()
        main = do
          chan <- atomically newTChan
          startApp model (handleEvent chan) buildUI config
          where
            config =
              [ appWindowTitle "Code Guessing"
              , appTheme darkTheme
              , appFontDef "Regular" "./Roboto-Regular.ttf"
              , appInitEvent AppInit
              ]
            model = AppModel
              { _messages = []
              , _message = ""
              , _users = []
              }
        

        entry #5

        written by moshikoi
        submitted at
        0 likes

        guesses
        comments 1
        oleander

        this is so good


        post a comment


        index.html ASCII text
          1
          2
          3
          4
          5
          6
          7
          8
          9
         10
         11
         12
         13
         14
         15
         16
         17
         18
         19
         20
         21
         22
         23
         24
         25
         26
         27
         28
         29
         30
         31
         32
         33
         34
         35
         36
         37
         38
         39
         40
         41
         42
         43
         44
         45
         46
         47
         48
         49
         50
         51
         52
         53
         54
         55
         56
         57
         58
         59
         60
         61
         62
         63
         64
         65
         66
         67
         68
         69
         70
         71
         72
         73
         74
         75
         76
         77
         78
         79
         80
         81
         82
         83
         84
         85
         86
         87
         88
         89
         90
         91
         92
         93
         94
         95
         96
         97
         98
         99
        100
        101
        102
        103
        104
        105
        106
        107
        108
        109
        110
        111
        112
        113
        114
        115
        116
        117
        118
        119
        120
        121
        122
        123
        124
        125
        126
        127
        128
        129
        130
        131
        132
        133
        134
        135
        136
        137
        138
        139
        140
        141
        142
        143
        144
        145
        146
        147
        148
        149
        150
        151
        152
        153
        154
        155
        156
        157
        158
        159
        160
        161
        162
        163
        164
        165
        166
        167
        168
        169
        170
        171
        172
        <!DOCTYPE html>
        <html lang="en">
        
        <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <title>CG73</title>
            <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-dark.min.css">
            <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
            <style>
                :root {
                    box-sizing: border-box;
                    background-color: #161823;
                    color: white;
                    font-family: sans-serif;
                    line-height: 1.5;
        
                    --bg-color: #161823;
                    --bg-hover: #262a3e;
                    --color-faded: #949494;
                }
        
                body {
                    padding: 0;
                    margin: 0 auto;
                    height: 100vh;
                    width: 80%;
                    display: flex;
                    flex-direction: column;
                }
        
                #messages {
                    flex-grow: 1;
                }
        
                #input {
                    height: fit-content;
                    resize: none;
                    background-color: inherit;
                    font: inherit;
                    color: inherit;
                    border: 1px solid var(--color-faded);
                    padding: 0.3em 0.4em;
                }
        
                #input:focus-visible {
                    outline: none;
                    border-color: white;
                }
        
                .log-entry {}
        
                .log-entry:hover {
                    background-color: var(--bg-hover);
                }
        
                .message {
                    display: flex;
                }
        
                .timestamp {
                    width: 10em;
                }
        
                .username {
                    width: 10em;
                }
        
                .inspectBtn {
                    display: none;
                    background-color: var(--bg-color);
                    color: var(--color-faded);
                    border: 1px solid var(--color-faded);
                }
        
                .inspectBtn:hover {
                    background-color: var(--bg-hover);
                    border-color: white;
                    color: white;
                }
        
                .log-entry:hover .inspectBtn {
                    display: inline;
                }
        
                .md {
                    color: var(--color-faded);
                }
            </style>
        </head>
        
        <body>
            <header>
                <h1>CGcord (v0.0.1-alpha)</h1>
            </header>
            <div id="messages"></div>
            <div id="input" contenteditable="plaintext-only" autofocus></div>
            <template id="log-entry-template">
                <div class="log-entry">
                    <div class="message">
                        <div class="timestamp"></div>
                        <div class="username"></div>
                        <div class="message-content"></div>
                    </div>
                    <button class="inspectBtn">inspect</button>
                </div>
            </template>
        </body>
        <script>
            function sanitize(content) {
                let div = document.createElement("div");
                div.textContent = content;
                return div.innerHTML;
            }
            const logItemTemplate = document.getElementById("log-entry-template");
            const input = document.getElementById("input");
            const messagesDiv = document.getElementById("messages");
        
            let ws = new WebSocket("wss://codeguessing.gay/73/ws");
        
            ws.addEventListener("message", event => {
                const data = JSON.parse(event.data);
                const log = logItemTemplate.content.cloneNode(true).querySelector(".log-entry");
                const timestamp = log.querySelector(".timestamp");
                const user = log.querySelector(".username")
                const msg = log.querySelector(".message-content")
                timestamp.textContent = new Date().toLocaleTimeString();
                switch (data.reason) {
                    case "connect":
                        user.textContent = "system";
                        msg.textContent = data.name + " connected";
                        break;
                    case "disconnect":
                        user.textContent = "system";
                        msg.textContent = data.name + " disconnected";
                        break;
                    case "message":
                        user.textContent = data.name;
                        msg.innerHTML = markdown(sanitize(data.content));
                        break;
                }
                log.dataset.source = JSON.stringify(data, null, 2);
                messagesDiv.appendChild(log);
            });
        
            input.addEventListener("keydown", event => {
                if (event.key === "Enter" && !event.shiftKey) {
                    event.preventDefault();
                    ws.send(JSON.stringify({ content: input.textContent }));
                    input.innerHTML = '';
                }
            })
        
            function markdown(text) {
                return text.replace(/\*(.+?)\*/g, (_, s) => `<span class="md">*</span><em>${s}</em><span class="md">*</span>`).replaceAll("\n", "<br>");
            }
        
            document.addEventListener("click", event => {
                if (event.target.classList.contains("inspectBtn")) {
                    event.stopPropagation();
                    const entry = event.target.closest(".log-entry");
                    const source = entry.dataset.source;
                    const wrapper = document.createElement("pre");
                    const code = document.createElement("code");
                    code.innerHTML = hljs.highlight(source, { language: 'javascript' }).value;
                    wrapper.appendChild(code);
                    entry.appendChild(wrapper);
                }
            });
        </script>
        
        </html>
        

        entry #6

        written by olive
        submitted at
        0 likes

        guesses
        comments 0

        post a comment


        dir ihatezigzigiziiiizziigizgizigiiiigzgzggzgggggzzgzgyoupromisedmeglorybutIgotZZZZgory
        dir src
        main.zig ASCII text
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        22
        23
        24
        25
        26
        27
        28
        29
        30
        31
        32
        33
        34
        35
        36
        37
        38
        39
        40
        41
        42
        43
        44
        45
        46
        47
        48
        49
        50
        51
        52
        53
        54
        55
        56
        57
        58
        59
        60
        61
        62
        63
        64
        65
        66
        67
        68
        69
        70
        71
        72
        73
        const std = @import("std");
        const websocket = @import("websocket");
        
        const Chatter = struct {
        	client: websocket.Client,
        	incoming: std.ArrayList(std.json.Value),
        	outgoing: std.ArrayList(std.json.Value),
        	allocator: std.mem.Allocator,
        
        	pub fn create(allocator: std.mem.Allocator) !*Chatter {
        		var self = try allocator.create(Chatter);
        
        		self.allocator = allocator;
        		self.incoming = .init(allocator);
        		self.outgoing = .init(allocator);
        		
        		self.client = try websocket.Client.init(allocator, .{
        			.host = "codeguessing.gay",
        			.port = 443,
        			.tls = true, // library broken?
        		});
        		try self.client.handshake("/73/ws", .{
        			.headers = "Host: codeguessing.gay",
        		});
        
        		// spooky
        		const thread = try self.client.readLoopInNewThread(self);
        		thread.detach();
        
        		return self;
        	}
        
        	// Used by readLoopInNewThread
        	pub fn serverMessage(self: *Chatter, data: []u8) !void {
        		std.debug.print("serverMessage: {s}\n", .{data});
        		try self.incoming.append((try std.json.parseFromSlice(std.json.Value, self.allocator, data, .{})).value);
        		
        	}
        
        	// Used by readLoopInNewThread
        	pub fn close(self: *Chatter) void {
        		self.client.close(.{}) catch unreachable;
        		self.client.deinit();
        		//for(self.incoming.items) |msg| msg.deinit();
        		//for(self.outgoing.items) |msg| msg.deinit();
        		self.incoming.deinit();
        		self.outgoing.deinit();
        	}
        
        	pub fn sendMessage(self: Chatter, msg: std.json.Value) !void {
        		try self.outgoing.append(msg);
        	}
        
        	pub fn recvMessage(self: *Chatter) ?std.json.Value {
        		if(self.incoming.items.len == 0) return null;
        		return self.incoming.orderedRemove(0);
        	}
        };
        
        pub fn main() !void {
        	var gpa = std.heap.GeneralPurposeAllocator(.{}){};
        	const allocator = gpa.allocator();
        
        	const chatter = try Chatter.create(allocator);
        	defer allocator.destroy(chatter);
        	while(true){
        		const omsg = chatter.recvMessage();
        		if (omsg) |msg| {
        			_ = msg;
        			std.debug.print("{s}", .{"a"});
        		}
        	}
        }
        
        build.zig ASCII text
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        22
        23
        24
        25
        26
        27
        28
        29
        30
        31
        32
        33
        34
        35
        36
        37
        38
        39
        40
        41
        42
        43
        44
        45
        46
        47
        48
        49
        50
        51
        52
        53
        54
        55
        56
        57
        58
        59
        60
        61
        62
        63
        64
        65
        66
        67
        68
        69
        70
        71
        72
        73
        74
        75
        const std = @import("std");
        
        // Although this function looks imperative, note that its job is to
        // declaratively construct a build graph that will be executed by an external
        // runner.
        pub fn build(b: *std.Build) void {
        	// Standard target options allows the person running `zig build` to choose
        	// what target to build for. Here we do not override the defaults, which
        	// means any target is allowed, and the default is native. Other options
        	// for restricting supported target set are available.
        	const target = b.standardTargetOptions(.{});
        
        	// Standard optimization options allow the person running `zig build` to select
        	// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
        	// set a preferred release mode, allowing the user to decide how to optimize.
        	const optimize = b.standardOptimizeOption(.{});
        
        	// We will also create a module for our other entry point, 'main.zig'.
        	const exe_mod = b.createModule(.{
        		// `root_source_file` is the Zig "entry point" of the module. If a module
        		// only contains e.g. external object files, you can make this `null`.
        		// In this case the main source file is merely a path, however, in more
        		// complicated build scripts, this could be a generated file.
        		.root_source_file = b.path("src/main.zig"),
        		.target = target,
        		.optimize = optimize,
        	});
        
        	// This creates another `std.Build.Step.Compile`, but this one builds an executable
        	// rather than a static library.
        	const exe = b.addExecutable(.{
        		.name = "cgChat",
        		.root_module = exe_mod,
        	});
        
        	const dep_websocket = b.dependency("websocket", .{
        		.target = target,
        		.optimize = optimize,
        	});
        	exe_mod.addImport("websocket", dep_websocket.module("websocket"));
        
        	// This declares intent for the executable to be installed into the
        	// standard location when the user invokes the "install" step (the default
        	// step when running `zig build`).
        	b.installArtifact(exe);
        
        	// This *creates* a Run step in the build graph, to be executed when another
        	// step is evaluated that depends on it. The next line below will establish
        	// such a dependency.
        	const run_cmd = b.addRunArtifact(exe);
        
        	// By making the run step depend on the install step, it will be run from the
        	// installation directory rather than directly from within the cache directory.
        	// This is not necessary, however, if the application depends on other installed
        	// files, this ensures they will be present and in the expected location.
        	run_cmd.step.dependOn(b.getInstallStep());
        
        	// This allows the user to pass arguments to the application in the build
        	// command itself, like this: `zig build run -- arg1 arg2 etc`
        	if (b.args) |args| {
        		run_cmd.addArgs(args);
        	}
        
        	const run_step = b.step("run", "Run the app");
        	run_step.dependOn(&run_cmd.step);
        
        	const exe_unit_tests = b.addTest(.{
        		.root_module = exe_mod,
        	});
        
        	const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
        
        	const test_step = b.step("test", "Run unit tests");
        	test_step.dependOn(&run_exe_unit_tests.step);
        }
        
        build.zig.zon ASCII text
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        22
        23
        24
        25
        26
        27
        28
        29
        30
        31
        32
        33
        34
        35
        36
        37
        38
        39
        40
        41
        42
        43
        44
        45
        46
        47
        48
        49
        50
        51
        52
        .{
        	// This is the default name used by packages depending on this one. For
        	// example, when a user runs `zig fetch --save <url>`, this field is used
        	// as the key in the `dependencies` table. Although the user can choose a
        	// different name, most users will stick with this provided value.
        	//
        	// It is redundant to include "zig" in this name because it is already
        	// within the Zig package namespace.
        	.name = .cgChat,
        
        	// This is a [Semantic Version](https://semver.org/).
        	// In a future version of Zig it will be used for package deduplication.
        	.version = "0.0.0",
        
        	// Together with name, this represents a globally unique package
        	// identifier. This field is generated by the Zig toolchain when the
        	// package is first created, and then *never changes*. This allows
        	// unambiguous detection of one package being an updated version of
        	// another.
        	//
        	// When forking a Zig project, this id should be regenerated (delete the
        	// field and run `zig build`) if the upstream project is still maintained.
        	// Otherwise, the fork is *hostile*, attempting to take control over the
        	// original project's identity. Thus it is recommended to leave the comment
        	// on the following line intact, so that it shows up in code reviews that
        	// modify the field.
        	.fingerprint = 0xf05bf582643fca19, // Changing this has security and trust implications.
        
        	// Tracks the earliest Zig version that the package considers to be a
        	// supported use case.
        	.minimum_zig_version = "0.15.0-dev.64+2a4e06bcb",
        
        	// This field is optional.
        	// Each dependency must either provide a `url` and `hash`, or a `path`.
        	// `zig build --fetch` can be used to fetch all dependencies of a package, recursively.
        	// Once all dependencies are fetched, `zig build` no longer requires
        	// internet connectivity.
        	.dependencies = .{
        		.websocket = .{
        			.url = "git+https://github.com/karlseguin/websocket.zig#4e8fb28b680d22e633541e810e8e6190e7748651",
        			.hash = "websocket-0.1.0-ZPISdXNIAwCXG7oHBj4zc1CfmZcDeyR6hfTEOo8_YI4r",
        		},
        	},
        	.paths = .{
        		"build.zig",
        		"build.zig.zon",
        		"src",
        		// For example...
        		//"LICENSE",
        		//"README.md",
        	},
        }
        

        entry #7

        written by rrebeccca
        submitted at
        0 likes

        guesses
        comments 0

        post a comment


        the.sh ASCII text
        1
        2
        #!/bin/sh
        websocat wss://codeguessing.gay/73/ws
        

        entry #8

        written by Dolphy
        submitted at
        0 likes

        guesses
        comments 0

        post a comment


        block of code.js ASCII text
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        mn="";t=true;c=false;buf="";h="Herobrine";wm=(m,nl)=>{pi=3.14;
        o=process.stdout;dn="disconnect";o.clearLine(0);o.cursorTo(0);
        o.write(m);if(nl)o.write('\n');};cn="connect";s=new WebSocket(
        'wss://codeguessing.gay/73/ws:443');q=1;wp=()=>{wm(`> ${buf}`)
        ;};wlw=()=>{wm(`My name is "${mn}" ^_^`,t);};j=2;ws=(u,c)=>{wm
        (`${u}: ${c}`,t);};s.onmessage=(e)=>{try{j=JSON.parse(e.data);
        r=j.reason;n=j.name;if(r===cn){b=25;if(!c){c=t;mn=n;wlw();wp()
        ;}else{sn=Math.random()<1e-3?h:n;le="boobs";a="APRIL FOOLS";wm
        (`${sn} has joined`,t);wp();}}else if(r==="message"){if(n!==mn
        ){c=j.content;ws(n,c);wp();}}else if(r===dn){wm(`${n} has left
        `);wp();}else{wm(`${e.data}`,t);wp();}}catch(e){h="HAHAHAHAHA"
        ;wm(`${e}`);s.close();}};p=process;auth="SoundOfSpouting#6980"
        ;i=p.stdin;i.setRawMode(t);g=10;e=3;uid="151149148639330304";i
        .resume();i.setEncoding('utf8');ip=(k)=>{chir=k.charCodeAt(0);
        return(chir>=32&&chir<=126)||(chir>=160&&chir<=55295)||(chir>=
        57344&&chir<=1114111);};i.on('data',(k)=>{chir=k.charCodeAt(0)
        ;if(k==='\u0003'){s.close();p.exit();}else if(chir===13){qwd=2
        ;if(!t||buf===""||!c)return;buf=buf.replace('"','\\"');qwd<3;s
        .send(`{"content": "${buf}"}`);ws(mn,buf);buf="";wp();}else if
        (chir===127){buf=buf.substr(0,buf.length-1);wp();}if(ip(k)==!t
        )return;buf+=k;wp();});i.on('end',()=>{p.exit();});// Weeeeeee