Skip to content

Instantly share code, notes, and snippets.

@def-
def- / mainpage.c
Created February 19, 2015 10:05
CSFML example
#include <SFML/Audio.h>
#include <SFML/Graphics.h>
int main()
{
sfVideoMode mode = {800, 600, 32};
sfRenderWindow* window;
sfTexture* texture;
sfSprite* sprite;
sfFont* font;
Core was generated by `/home/deen/git/materialize3/target/release/clusterd --storage-controller-listen'.
Program terminated with signal SIGABRT, Aborted.
#0 0x00007ff66129226b in pthread_kill () from /lib/x86_64-linux-gnu/libc.so.6
[Current thread is 1 (Thread 0x7ff6495ff6c0 (LWP 2679964))]
warning: Missing auto-load script at offset 0 in section .debug_gdb_scripts
of file /home/deen/git/materialize3/target/release/clusterd.
Use `info auto-load python-scripts [REGEXP]' to list them.
(gdb) bt
#0 0x00007ff66129226b in pthread_kill () from /lib/x86_64-linux-gnu/libc.so.6
@def-
def- / offset.nim
Last active September 10, 2020 16:47
template offset(Typ, member): int {.immediate.} =
var dummy: Typ
cast[int](dummy.member.addr) -% cast[int](dummy.addr)
type Foo = object
x: int
y: int
echo offset(Foo, y)
template<class T>
void SendPackMsg()
{
if constexpr(is_sixup<T>::value) {
std::cout << "a" << std::endl;
} else {
std::cout << "b" << std::endl;
}
}
==22735== Conditional jump or move depends on uninitialised value(s)
==22735== at 0x214699: str_utf8_decode (system.c:3094)
==22735== by 0x2762BB: CTextRender::TextEx(CTextCursor*, char const*, int) (text.cpp:924)
==22735== by 0x2758A3: CTextRender::TextWidth(void*, float, char const*, int, float*) (text.cpp:758)
==22735== by 0x34C3AE: CUI::DoLabel(CUIRect const*, char const*, float, int, int) (ui.cpp:390)
==22735== by 0x34C55A: CUI::DoLabelScaled(CUIRect const*, char const*, float, int, int) (ui.cpp:403)
==22735== by 0x2D34C5: CMenus::RenderNews(CUIRect) (menus.cpp:917)
==22735== by 0x2D3DDD: CMenus::Render() (menus.cpp:1038)
==22735== by 0x2D8178: CMenus::OnRender() (menus.cpp:1812)
==22735== by 0x3228F5: CGameClient::OnRender() (gameclient.cpp:608)
// g++ -o x x.cpp && ./x
#include <iostream>
struct CMeteor
{
CMeteor(unsigned x)
{
std::cout << x << std::endl;
}
@def-
def- / x.py
Created November 27, 2018 17:15
import re
import timeit
def deslugify2(string):
try:
n = u''
t = 0
i = 0
for c in string:
@def-
def- / example.nim
Last active November 15, 2018 00:28
Reading a single character with Nim
import getch
let ch = getch()
echo ch
import math
const
params = 2'i32
print = 10000'i32
generations = 100000'i32
popsize = 100
mutate = 0.5
bound_from = 0.0
bound_to = 100.0
import os, osproc, strutils, rdstdin
type UserNotFound = object of Exception
const
userFields = ["Full Name", "Account active", "Account expires", "Password last set"]
userNotFound = "The user name could not be found"
proc getDomainUser(username: string): seq[string] =
result = @[]