This works most of the time
def handle(data) do
with {:ok, product} <- Jason.decode!(data),
{:ok, category} <- Category.load(data.category_id)
do
# todo
end
end
const std = @import("std"); | |
const LOOPS = 1000; | |
pub fn main() !void { | |
var in: [10000]u8 = undefined; | |
try std.os.getrandom(&in); | |
var fbs = std.io.fixedBufferStream(&in); | |
var out: [10000]u8 = undefined; |
// in your build.zig, you can specify a custom test runner: | |
// const tests = b.addTest(.{ | |
// .target = target, | |
// .optimize = optimize, | |
// .test_runner = "test_runner.zig", // add this line | |
// .root_source_file = b.path("src/main.zig"), | |
// }); | |
const std = @import("std"); | |
const builtin = @import("builtin"); |
const std = @import("std"); | |
const ITERATIONS = 1_000_000; | |
pub fn main() !void { | |
benchmark("needle.len == 1, haystack.len == 11 ", "hello world", "w", 6); | |
benchmark("needle.len == 1, haystack.len == 3091", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sit amet erat elit. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Mauris cursus quis eros quis vestibulum. Vestibulum in convallis nulla. Nulla mauris velit, tempus id varius sit amet, sodales et magna. Aenean vel augue vitae erat luctus maximus. Nam dignissim diam felis, id fermentum neque dapibus quis. Quisque volutpat ac nibh a blandit. Aenean id felis aliquam, aliquet lorem vel, lobortis ligula. Morbi lacinia risus ac dictum accumsan. Maecenas dapibus elit in magna porta tempus. Proin luctus neque sed erat sagittis gravida. Praesent at lacinia libero.Curabitur sagittis risus ut suscipit cursus. Maecenas at gravida turpis, id malesuada felis. Praesent velit dui, pulvinar eget vehicula sed, semper |
const std = @import("std"); | |
const mem = std.mem; | |
const ITERATIONS = 20_000; | |
pub fn main() !void { | |
try benchmark("empty", "", true); | |
try benchmark("short.ascii", "it's over 9000!!", true); | |
try benchmark("long.ascii", "Lorem ipsum dolor sit amet, pri legere suscipit repudiare at, cu vix aliquip pertinacia quaerendum, in eam dicat cetero eripuit. Duo odio nonumy viderer at, et sea vidit dolor animal, has persius conceptam id. Vide idque copiosae ut qui, ut lorem atomorum mei, in eos suscipit eleifend. Illud principes no eos, pri dolorem singulis ne, ex pri malorum argumentum scribentur. Et altera regione per. Disputando contentiones no mei, et vel discere meliore constituam. Te quo legere nostrum deleniti, ad eros putent tritani per.Repudiandae mediocritatem ut est, ex sea dicit evertitur. Per tritani detraxit an. Pro no fastidii tractatos, per purto affert accusata no, affert consequat mel ea. Cum ex postulant gubergren, has quot vidit argumentum no.Eu est esse feugait, mea no augue debet constituam. Sea s |
# see https://www.openmymind.net/Elixir-Without-Ecto/ | |
defmodule A.DB do | |
defmacro __using__(_) do | |
quote location: :keep do | |
@name __MODULE__ | |
def child_spec(opts) do | |
%{ | |
id: __MODULE__, |
// For Zig 0.12 | |
const std = @import("std"); | |
const net = std.net; | |
const ArenaAllocator = std.heap.ArenaAllocator; | |
pub fn main() anyerror!void { | |
var gpa = std.heap.GeneralPurposeAllocator(.{}){}; | |
const allocator = gpa.allocator(); |
# WAFs are a waste of time. False positives negatively impact actual users. | |
# And for what? Protection against vulnerabilities that, if you still have | |
# in this day in age, you're in more trouble than you think. | |
# Still, to keep my logs clean, I like to run something like the follwoing: | |
location ~ \.php$ { access_log off; return 444; } | |
location ~ \.asp$ { access_log off; return 444; } | |
location ~ \.aspx$ { access_log off; return 444; } | |
location ~ /Admincenter/ { access_log off; return 444; } | |
location /console/ { access_log off; return 444; } |
var Util util | |
type util struct{} | |
func (_ util) PadLeft(s string, n int) string { | |
//... | |
} | |
// ... |
This works most of the time
def handle(data) do
with {:ok, product} <- Jason.decode!(data),
{:ok, category} <- Category.load(data.category_id)
do
# todo
end
end
timestamp | method | uri | ip | |
---|---|---|---|---|
Oct 18, 2019 @ 09:41:02.000 | - | - | 61.219.11.153 | |
Oct 18, 2019 @ 09:34:37.000 | GET | / | 164.52.24.162 | |
Oct 18, 2019 @ 09:33:12.000 | - | - | 61.219.11.153 | |
Oct 18, 2019 @ 09:32:28.000 | - | - | 61.219.11.153 | |
Oct 18, 2019 @ 09:26:41.000 | GET | /otsmobile/app/mgs/mgw.htm | 110.105.80.110 | |
Oct 18, 2019 @ 09:23:42.000 | GET | /ftpsync.settings | 185.234.216.20 | |
Oct 18, 2019 @ 09:23:41.000 | GET | /deployment-config.json | 185.234.216.20 | |
Oct 18, 2019 @ 09:23:40.000 | GET | /.vscode/ftp-sync.json | 185.234.216.20 | |
Oct 18, 2019 @ 09:23:40.000 | GET | /.vscode/sftp.json | 185.234.216.20 |