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
spawn: | |
var socket = newSocket() | |
print "1" | |
socket.connectFi("localhost", Port(12321)) | |
print "2" | |
socket.sendFi("spawn #1\c\L") | |
print "4" | |
echo socket.recvFi() | |
socket.close() | |
print "5" |
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
let a = html: | |
html: | |
lang "en" | |
head: | |
meta: | |
charset "utf-8" | |
title "myTitle" | |
meta: | |
name "description" | |
content "myDescription" |
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
## Bare-bones SDL2 example | |
import sdl2 | |
import typography, vmath, flippy, chroma, tables, times | |
discard sdl2.init(INIT_EVERYTHING) | |
var | |
window: WindowPtr | |
render: RendererPtr |
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
## Bare-bones SDL2 example | |
import sdl2 | |
discard sdl2.init(INIT_EVERYTHING) | |
var | |
window: WindowPtr | |
render: RendererPtr | |
window = createWindow("SDL Skeleton", 100, 100, 640,480, SDL_WINDOW_SHOWN) |
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
const | |
cbWebSafe64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" | |
proc encodeWebSafeNoPadding*(s: string): string = | |
## encodes `s` into web safe base64 representation. | |
proc encodeSize(size: int): int = | |
return (size * 4 div 3) + 6 | |
result.setLen(encodeSize(s.len)) |
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
# Get the log itself | |
var | |
logStr = cast[ptr GLchar](alloc(logSize)) | |
logLen: GLsizei | |
glGetShaderInfoLog(vertShader, logSize.GLsizei, logLen.addr, logStr) | |
# Print the log | |
echo $logStr |
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
import ws, asyncdispatch, asynchttpserver | |
proc cb(req: Request) {.async.} = | |
var ws = await newWebSocket(req) | |
echo "Got ws connecting with protocol ", ws.protocol | |
if ws.protocol == "alpha": | |
await ws.send("Welcome Protocol Alpha") | |
ws.close() | |
var server = newAsyncHttpServer() |
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
import ws, asyncdispatch, asynchttpserver | |
proc cb(req: Request) {.async.} = | |
var ws = await newWebSocket(req) | |
await ws.send("Welcome") | |
ws.close() | |
var server = newAsyncHttpServer() | |
waitFor server.serve(Port(9001), cb) |
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
import strutils | |
proc initDecodeTable*(): array[256, char] = | |
# computes a decode table at compile time | |
for i in 0 ..< 256: | |
let ch = char(i) | |
var code = 255 | |
if ch >= 'A' and ch <= 'Z': code = i - 0x00000041 | |
if ch >= 'a' and ch <= 'z': code = i - 0x00000047 |
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
{.compile: "openwl/source/osx-cocoa/MainThreadExecutor.mm".} | |
{.compile: "openwl/source/osx-cocoa/WLAppDelegate.mm".} | |
{.compile: "openwl/source/osx-cocoa/WLContentView.mm".} | |
{.compile: "openwl/source/osx-cocoa/WLWindowObject.mm".} | |
{.compile: "openwl/source/osx-cocoa/globals.mm".} | |
{.compile: "openwl/source/osx-cocoa/keystuff.mm".} | |
{.compile: "openwl/source/osx-cocoa/miscutil.mm".} | |
{.compile: "openwl/source/osx-cocoa/openwl.mm".} | |
{.compile: "openwl/source/osx-cocoa/private_defs.mm".} | |
{.passL: "-framework Foundation" .} |