This file contains 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 os | |
for i in 0..6: | |
echo("Blah ", i) | |
flushFile(stdout) | |
os.sleep(1000) |
This file contains 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
{-# LANGUAGE OverloadedStrings #-} | |
import Network.SimpleIRC | |
import Data.Maybe | |
import qualified Data.ByteString.Char8 as B | |
onMessage :: EventFunc | |
onMessage s m | |
| msg == "|hai" = do | |
sendMsg s chan "hai thar!" | |
| B.isPrefixOf "|say" msg = do |
This file contains 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 test | |
test = "hello!" | |
echo(test) | |
test = "as" # ERORROEIYYUAIDG KABOOM |
This file contains 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 os, osproc, streams | |
echo(findExe"cat") | |
var p = startProcess(findExe"cat") | |
var err = p.errorStream | |
var outp = p.outputStream | |
var inp = p.inputStream | |
var result = "" |
This file contains 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
# All and any | |
template all(container, cond: expr): expr = | |
block: | |
var result = true | |
for it in items(container): | |
if not cond(it): | |
result = false | |
break | |
result |
This file contains 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
#include <iostream> | |
#include <string> | |
#include <vector> | |
using namespace std; | |
vector<string> split(string s, char sep) { | |
vector<string> result; | |
int i, last = 0; | |
while (i < s.length()-1) { | |
if (s[i] == sep) { |
This file contains 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 os | |
var | |
thr: TThread[char] | |
line = "" | |
lineLock: TLock | |
finished: bool = False | |
initLock(lineLock) | |
var | |
printedLines = 0 |
This file contains 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
type | |
TSomething = object | |
s: string | |
s1: string | |
var s: seq[TSomething] = @[] | |
for i in 0..10240: | |
var obj: TSomething | |
obj.s = "blah" | |
obj.s1 = "asd" | |
s.add(obj) |
This file contains 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 posix, os | |
var hints: TAddrInfo | |
var aiList: ptr TAddrInfo = nil | |
hints.ai_family = AF_INET | |
hints.ai_socktype = SOCK_STREAM | |
hints.ai_protocol = IPPROTO_TCP | |
if getAddrInfo("google.com", "80", addr(hints), aiList) != 0'i32: OSError() | |
var it = aiList |
This file contains 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
type | |
TEnum = enum | |
a, b | |
var foo: TEnum = TEnum(0) | |
echo(foo) |