Skip to content

Instantly share code, notes, and snippets.

@Yardanico
Yardanico / test.py
Last active October 12, 2017 11:36
async def show_list(msg, args, role):
if not await get_or_none(Role.select(Role.user_id).where(Role.role == role)):
return await msg.answer(f'Группа {role} пуста 🙄')
message = f"Список пользователей {role}:\n"
for u in await db.execute(Role.select(Role.user_id).where(Role.role == role)):
users = await msg.vk.method('users.get', {'user_ids': u.user_id, 'fields': 'online'})
user = users[0]
message += f"[id{user['id']}|{user['first_name']} {user['last_name']}] {' - онлайн' if user['online'] else ''}\n"
nim compile -f --symbolfiles:off --compileonly --gen_mapping --cc:gcc --skipUserCfg --os:android --cpu:arm -d:release compiler/nim.nim
command line(1, 2) Error: unknown OS: 'android'
Error: call to nim compiler failed
Error: execution of an external program failed: 'C:\Users\Tiberium\Nim\tools\niminst\niminst.exe --var:version=0.17.0 --var:mingw=none csource --main:compiler/nim.nim compiler/installer.ini -d:release'
FAILUR
$ sh build.sh
# OS: android
# CPU: arm64
gcc -o bin/nim -lrt -landroid-glob -ldl -lm -lrt -landroid-glob
/data/data/com.termux/files/usr/bin/../lib/crtbegin_dynamic.o: In function `do_arm64_start':
crtbegin.c:(.text+0x20): undefined reference to `main'
crtbegin.c:(.text+0x4c): undefined reference to `main'
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
$
template debug*(body: untyped) =
when not defined release:
body
debug echo "hello"
import math
import unittest, strutils # Только для тестов
proc arithmetic[T](a, b: T, op: char): float =
# Тут используются дженерики для того, чтобы процедура принимала разные числа :)
case op
of '+': result = float(a + b)
of '-': result = float(a - b)
of '*': result = float(a * b)
of '/': result = float(a / b)
foo MyType:
doStuff
foo:
doAnotherStuff
proc gen_event(ad: AddressDirection) {.async.} =
let href = ("http://$1:$2/sub$3" % [ cts.host, $cts.port, $sid ])
let ev = %* CallEventNotification(
callingParticipant: calling,
calledParticipant: called,
eventDescription: EventDescription(callEvent: evtype),
notificationType: "callEvent",
callSessionIdentifier: $ id,
addressDirection: ad,
if (let data = "hello"; data.len > 0):
echo data
Traceback (most recent call last)
vkbot.nim(104) vkbot
asyncdispatch.nim(1010) runForever
asyncdispatch.nim(1045) poll
asyncdispatch.nim(179) processPendingCallbacks
asyncmacro.nim(34) cb0
asyncmacro.nim(126) handler9Iter
gc.nim(278) asgnRefNoCycle
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
import httpclient, asyncdispatch, strutils, tables, unicode, json, math, times
const
ForecastUrlFormat = "http://api.openweathermap.org/data/2.5/forecast/daily?APPID=$1&lang=en&q=$2&cnt=$3"
ResultFormat = """$1:
$2
Temperature: $3 °C
Humidity: $4%
Clouds: $5%