hash function naming
This commit is contained in:
parent
08496afa11
commit
c17c72d59f
Binary file not shown.
@ -1,9 +1,9 @@
|
||||
Noise Functions
|
||||
Noise/Hash Functions
|
||||
|
||||
draw_float
|
||||
draw_int
|
||||
generate_float
|
||||
generate_int
|
||||
noise01
|
||||
noise32
|
||||
noise64
|
||||
gen_noise01
|
||||
gen_noise32
|
||||
gen_noise64
|
||||
gen_float
|
||||
gen_int
|
||||
|
||||
@ -25,9 +25,9 @@ RENDER()
|
||||
String page = first(context->get["p"], "index");
|
||||
|
||||
<><html>
|
||||
<header>
|
||||
<link rel="stylesheet" href='style.css'></link>
|
||||
</header>
|
||||
<head>
|
||||
<link rel="stylesheet" href='style.css?v=<?= time() ?>'></link>
|
||||
</head>
|
||||
<body>
|
||||
<h1>
|
||||
<a href="index.uce">UCE Docs</a>:
|
||||
@ -72,9 +72,10 @@ RENDER()
|
||||
{
|
||||
auto doc = split(file_get_contents("pages/"+page+".txt"), "\n");
|
||||
String layout_class = "text";
|
||||
?><div><?
|
||||
u32 line_idx = 0;
|
||||
for(auto s : doc)
|
||||
{
|
||||
line_idx++;
|
||||
if(s == "")
|
||||
{
|
||||
|
||||
@ -82,7 +83,11 @@ RENDER()
|
||||
else if(s.substr(0, 1) == ":")
|
||||
{
|
||||
layout_class = s.substr(1);
|
||||
?></div><?
|
||||
if(line_idx > 1)
|
||||
{
|
||||
?></div><?
|
||||
}
|
||||
?><div class="<?= layout_class ?>"><?
|
||||
if(layout_class == "params")
|
||||
{
|
||||
?><h3>Parameters</h3><?
|
||||
@ -101,13 +106,12 @@ RENDER()
|
||||
}
|
||||
else if(layout_class == "see")
|
||||
{
|
||||
?><h3>Related</h3><?
|
||||
/*?><h3>Related</h3><?*/
|
||||
}
|
||||
else
|
||||
{
|
||||
?><h3><?= layout_class ?></h3><?
|
||||
}
|
||||
?><div class="<?= layout_class ?>"><?
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -122,7 +126,6 @@ RENDER()
|
||||
}
|
||||
else if(layout_class == "see")
|
||||
{
|
||||
?><div style="margin-left: 2em"><?
|
||||
if(s[0] == '>')
|
||||
{
|
||||
render_see_section(s.substr(1));
|
||||
@ -131,7 +134,6 @@ RENDER()
|
||||
{
|
||||
?><div><a href="index.uce?p=<?= trim(s) ?>"><?= trim(s) ?><span style="opacity:0.5">()</span></a></div><?
|
||||
}
|
||||
?></div><?
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -6,9 +6,15 @@
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-family: monospace;
|
||||
font-size: 200%;
|
||||
padding-top: 8px;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
body {
|
||||
max-width: 1024px;
|
||||
margin: 0;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
padding-left: 16px;
|
||||
@ -16,22 +22,19 @@ body {
|
||||
font-family: Tahoma, Helvetica, Arial;
|
||||
font-size: 1.2em;
|
||||
box-sizing: border-box;
|
||||
background: #24f;
|
||||
background: #139;
|
||||
color: white;
|
||||
line-height: 150%;
|
||||
}
|
||||
|
||||
a {
|
||||
color: yellow;
|
||||
body > * {
|
||||
background: rgba(255,255,255,0.1);
|
||||
padding: 32px;
|
||||
margin: 16px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 200%;
|
||||
padding-top: 16px;
|
||||
padding-bottom: 16px;
|
||||
border-bottom: 8px solid rgba(0,0,0,0.5);
|
||||
margin: 0;
|
||||
margin-bottom: 8px;
|
||||
a {
|
||||
color: yellow;
|
||||
}
|
||||
|
||||
form > div, label {
|
||||
@ -79,7 +82,11 @@ pre {
|
||||
}
|
||||
|
||||
h3 {
|
||||
|
||||
margin: 0;
|
||||
font-family: monospace;
|
||||
font-size: 1.4em;
|
||||
margin-bottom: 0.8em;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.sig {
|
||||
|
||||
@ -257,7 +257,7 @@ unsigned char c;
|
||||
/* ================ end of sha1.c ================ */
|
||||
|
||||
String
|
||||
sha1(String s, bool as_binary)
|
||||
gen_sha1(String s, bool as_binary)
|
||||
{
|
||||
unsigned char v[20];
|
||||
SHA1_CTX ctx;
|
||||
@ -279,7 +279,7 @@ sha1(String s, bool as_binary)
|
||||
#define BIT_NOISE3 0x1B56C4E9
|
||||
|
||||
// based on Squirrel3 https://www.youtube.com/watch?v=LWFzPP8ZbdU&t=2666s
|
||||
u32 noise32(u32 index, u32 seed)
|
||||
u32 gen_noise32(u32 index, u32 seed)
|
||||
{
|
||||
u32 r = index;
|
||||
r *= BIT_NOISE1;
|
||||
@ -296,7 +296,7 @@ u32 noise32(u32 index, u32 seed)
|
||||
#define BIT_NOISE62 0xb8E31DA41B56C4E9
|
||||
#define BIT_NOISE63 0x18cd227aaa1168c1
|
||||
|
||||
u64 noise64(u64 index, u64 seed)
|
||||
u64 gen_noise64(u64 index, u64 seed)
|
||||
{
|
||||
u64 r = index;
|
||||
r *= BIT_NOISE61;
|
||||
@ -311,31 +311,31 @@ u64 noise64(u64 index, u64 seed)
|
||||
|
||||
#define MAX_64 0xffffffffffffffff
|
||||
|
||||
f64 noise01(u64 index, u64 seed)
|
||||
f64 gen_noise01(u64 index, u64 seed)
|
||||
{
|
||||
return((float)noise64(index, seed)/(float)MAX_64);
|
||||
return((float)gen_noise64(index, seed)/(float)MAX_64);
|
||||
}
|
||||
|
||||
u64 generate_int(u64 from, u64 to, u64 index, u64 seed)
|
||||
u64 gen_int(u64 from, u64 to, u64 index, u64 seed)
|
||||
{
|
||||
u64 b = 1 + to - from;
|
||||
return(from + (noise64(index, seed) % b));
|
||||
return(from + (gen_noise64(index, seed) % b));
|
||||
}
|
||||
|
||||
#include <tgmath.h>
|
||||
f64 generate_float(f64 from, f64 to, u64 index, u64 seed, f64 decimal_precision)
|
||||
f64 gen_float(f64 from, f64 to, u64 index, u64 seed, f64 decimal_precision)
|
||||
{
|
||||
f64 b = to - from;
|
||||
return(from + fmod( decimal_precision*(f64)noise64(index, seed), b));
|
||||
return(from + fmod( decimal_precision*(f64)gen_noise64(index, seed), b));
|
||||
}
|
||||
|
||||
u64 draw_int(u64 from, u64 to)
|
||||
{
|
||||
return(generate_int(from, to, context->random_index++, context->random_seed));
|
||||
return(gen_int(from, to, context->random_index++, context->random_seed));
|
||||
}
|
||||
|
||||
f64 draw_float(f64 from, f64 to, f64 decimal_precision)
|
||||
{
|
||||
return(generate_float(from, to, context->random_index++, context->random_seed, decimal_precision));
|
||||
return(gen_float(from, to, context->random_index++, context->random_seed, decimal_precision));
|
||||
}
|
||||
|
||||
|
||||
@ -6,14 +6,14 @@ By Steve Reid <steve@edmweb.com>
|
||||
*/
|
||||
|
||||
|
||||
String sha1(String s, bool as_binary = false);
|
||||
String gen_sha1(String s, bool as_binary = false);
|
||||
|
||||
u32 noise32(u32 index, u32 seed = 0);
|
||||
u64 noise64(u64 index, u64 seed = 0);
|
||||
f64 noise01(u64 index, u64 seed = 0);
|
||||
u32 gen_noise32(u32 index, u32 seed = 0);
|
||||
u64 gen_noise64(u64 index, u64 seed = 0);
|
||||
f64 gen_noise01(u64 index, u64 seed = 0);
|
||||
|
||||
u64 generate_int(u64 from, u64 to, u64 index, u64 seed = 0);
|
||||
f64 generate_float(f64 from, f64 to, u64 index, u64 seed = 0, f64 decimal_precision = 0.000000000001);
|
||||
u64 gen_int(u64 from, u64 to, u64 index, u64 seed = 0);
|
||||
f64 gen_float(f64 from, f64 to, u64 index, u64 seed = 0, f64 decimal_precision = 0.000000000001);
|
||||
|
||||
u64 draw_int(u64 from, u64 to);
|
||||
f64 draw_float(f64 from, f64 to, f64 decimal_precision = 0.000000000001);
|
||||
|
||||
@ -147,7 +147,7 @@ String to_string(s64 v) { return(std::to_string(v)); }
|
||||
|
||||
struct ServerSettings {
|
||||
|
||||
String BIN_DIRECTORY = "work";
|
||||
String BIN_DIRECTORY = "/tmp/uce/work";
|
||||
String COMPILE_SCRIPT = "scripts/compile";
|
||||
String LIT_ESC = "3d5b5_1";
|
||||
String CONTENT_TYPE = "text/html; charset=utf-8";
|
||||
|
||||
@ -47,7 +47,7 @@ int handle_complete(FastCGIRequest& request) {
|
||||
request.header["Content-Type"] = context->server->config.CONTENT_TYPE;
|
||||
request.get = parse_query(request.params["QUERY_STRING"]);
|
||||
request.random_index = 0;
|
||||
request.random_seed = noise64(*reinterpret_cast<u64*>(&request.stats.time_start));
|
||||
request.random_seed = gen_noise64(*reinterpret_cast<u64*>(&request.stats.time_start));
|
||||
request.ob_start();
|
||||
|
||||
if(request.params["HTTP_COOKIE"].length() > 0)
|
||||
@ -118,8 +118,6 @@ int main(int argc, char** argv)
|
||||
|
||||
printf("Compiler base path: %s\n", server_state.config.COMPILER_SYS_PATH.c_str());
|
||||
|
||||
server_state.config.BIN_DIRECTORY =
|
||||
server_state.config.COMPILER_SYS_PATH + "/" + server_state.config.BIN_DIRECTORY;
|
||||
server_state.config.COMPILE_SCRIPT =
|
||||
server_state.config.COMPILER_SYS_PATH + "/" + server_state.config.COMPILE_SCRIPT;
|
||||
if(server_state.config.LISTEN_PORT)
|
||||
@ -131,6 +129,7 @@ int main(int argc, char** argv)
|
||||
dirname(server_state.config.COMPILER_SYS_PATH);
|
||||
basename(server_state.config.COMPILER_SYS_PATH);
|
||||
|
||||
mkdir(server_state.config.BIN_DIRECTORY);
|
||||
mkdir(server_state.config.TMP_UPLOAD_PATH);
|
||||
mkdir(server_state.config.SESSION_PATH);
|
||||
|
||||
|
||||
2
start.sh
2
start.sh
@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
rm -r work/* ; ./build_linux.sh && bin/uce_fastcgi.debug.linux.bin
|
||||
rm -r /tmp/uce/work/* ; ./build_linux.sh && bin/uce_fastcgi.debug.linux.bin
|
||||
|
||||
4
test/empty.uce
Normal file
4
test/empty.uce
Normal file
@ -0,0 +1,4 @@
|
||||
void hello()
|
||||
{
|
||||
|
||||
}
|
||||
@ -6,7 +6,7 @@ RENDER()
|
||||
p.set(context->params);
|
||||
|
||||
<>
|
||||
<link rel="stylesheet" href='style.css'></link>
|
||||
<link rel="stylesheet" href='style.css?v=<?= time() ?>'></link>
|
||||
<h1>
|
||||
<a href="index.uce">UCE Test</a>:
|
||||
Index
|
||||
|
||||
@ -14,6 +14,7 @@ h1 {
|
||||
font-size: 200%;
|
||||
padding-top: 8px;
|
||||
padding-bottom: 8px;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
body {
|
||||
@ -25,11 +26,17 @@ body {
|
||||
font-family: Tahoma, Helvetica, Arial;
|
||||
font-size: 1.2em;
|
||||
box-sizing: border-box;
|
||||
background: #24f;
|
||||
background: #139;
|
||||
color: white;
|
||||
line-height: 150%;
|
||||
}
|
||||
|
||||
body > * {
|
||||
background: rgba(255,255,255,0.1);
|
||||
padding: 32px;
|
||||
margin: 16px;
|
||||
}
|
||||
|
||||
form > div, label {
|
||||
display: block;
|
||||
padding-top: 8px;
|
||||
@ -69,7 +76,7 @@ pre {
|
||||
overflow: auto;
|
||||
padding: 8px;
|
||||
border: 2px solid rgba(0,0,0,0.2);
|
||||
background: rgba(100,100,100,0.15);
|
||||
background: rgba(255,255,255,0.1);
|
||||
font-family: monospace;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user