Skip to content

Instantly share code, notes, and snippets.

int doCheck(int check) {
switch (check) {
case TYPE_1:
return afterCheck();
case TYPE_2:
return afterCheck();
default:
return 0;
@b4284
b4284 / test.cpp
Created September 21, 2017 22:41
#include <iostream>
#include <vector>
#include <memory>
class A {
public:
A() {}
A(int i) {
std::cout << i << std::endl;
}
-- A easy to use multiple-return-value is equivalent of having
-- an automatic packing & unpacking mechanism of the functions'
-- input & output.
function mv(n)
if n == 0 then
return
else
return n, mv(n - 1)
end
#include <sys/random.h>
#include <lauxlib.h>
static int l_getrandom(lua_State *L) {
luaL_Buffer B;
size_t d = lua_tointeger(L, 1); /* get argument */
char *buf = luaL_buffinitsize(L, &B, d);
int len = getrandom(buf, d, 0);
luaL_pushresultsize(&B, len);
local iter = 0
if #arg < 1 then
error("Input number of iterations")
else
iter = tonumber(arg[1])
end
local rng = io.open("/dev/urandom", "rb")
local sqlite3 = require("lsqlite3")
local db = sqlite3.open("pk_search.db")
#include <stdio.h>
#include <stdint.h>
static inline void print_nums(const uint8_t *u8)
{
for (int i = 0; i < 5; ++i) {
printf(" %d", u8[i]);
}
putchar('\n');
}
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <stdint.h>
#define JSON_THINGS_SIZE 256
#define JSON_STRINGS_SIZE 1024
#define JSON_COMPOUNDS_SIZE 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <stdint.h>
#define JSON_THINGS_SIZE 256
#define JSON_STRINGS_SIZE 1024
#define JSON_COMPOUNDS_SIZE 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <stdint.h>
#define JSON_THINGS_SIZE 256
#define JSON_STRINGS_SIZE 1024
#define JSON_COMPOUNDS_SIZE 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <stdint.h>
#define JSON_THINGS_SIZE 256
#define JSON_STRINGS_SIZE 1024
#define JSON_COMPOUNDS_SIZE 256