jhass changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.1 | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
<oprypin> heck, i keep running into `Invalid memory access (signal 11) at address 0x4` with Halite
<oprypin> well at least it's the same cause as before
<oprypin> hmm is there any rate limiting solution? say i know how many calls i am allowed in an hour, but i don't want to just wait hour/N before allowing a next request. some burst should be allowed.
jrayhawk has joined #crystal-lang
jrayhawk has quit [Read error: Connection reset by peer]
jrayhawk has joined #crystal-lang
<FromGitter> <Blacksmoke16> Group the requests into 1 hour buckets, keeping track of the total made per bucket. When the bucket is full, sleep till start of next
<FromGitter> <Blacksmoke16> I have some code I can share for what we use at work
<FromGitter> <Blacksmoke16> Uses redis as the backend
<oprypin> Blacksmoke16, the api can block me itself, i dont want to reach that point 😂
<oprypin> "some burst should be allowed." but not too much burst
<oprypin> exceptions are such amazing control flow, i cant even. poor c++ users having to avoid them
<FromGitter> <Blacksmoke16> Right, you wouldn't hit the limit with this approach
<FromGitter> <Blacksmoke16> And would all for bursts of up to the limit
<FromGitter> <Blacksmoke16> Allow
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<oprypin> Blacksmoke16, oh i see. was just confused because the api itself happens to track quota in hour increments
<FromGitter> <munjalpatel> Hey folks,
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5fc1b1008292a93eb102c0f8]
<FromGitter> <Blacksmoke16> prob can do without the multiplier part
<oprypin> mm
<FromGitter> <munjalpatel> Hey folks, ⏎ ⏎ I am trying to make a very simple piece of code work for last few hours but really going no where. ⏎ I am using `Kemal` and trying to simply get `String` from the posted `json` like this: ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5fc1b1650219b46a26636ef6]
<FromGitter> <Blacksmoke16> `.as(String)`?
<FromGitter> <Blacksmoke16> the value of `"name"` is a union of all those types, so you just need to tell it, hey i know this should be a string
<FromGitter> <munjalpatel> Thanks @Blacksmoke16 .. that makes sense .. I misunderstood `.json()` to be `JSON::Any` only
<FromGitter> <Blacksmoke16> np
<FromGitter> <munjalpatel> However, I am implementing a validation logic so what would be a good way to raise an exception if someone posts a non-string value for "name"? ⏎ I tried `typeof` however it keeps giving me `(Array(JSON::Any) | Bool | Float64 | Hash(String, JSON::Any) | Int64 | String | Nil))` union
<FromGitter> <Blacksmoke16> `is_a? String`?
<FromGitter> <Blacksmoke16> the union represents the *possible* types, `is_a?` checks the type of the current value
<FromGitter> <munjalpatel> Great .. thanks .. will try that!
<FromGitter> <Blacksmoke16> depending on what you're doing there are also other frameworks that may be better suited than kemal
<oprypin> 😏
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 272 seconds]
avane has quit [Quit: ZNC - https://znc.in]
avane has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <rishavs> @Blacksmoke16 means https://github.com/athena-framework/athena ⏎ Though if you are only doing an api server, I still hold, you do not need any framework. the std lib modules are good enough.
<FromGitter> <watzon> If you feel like reinventing the wheel. Unless your API is very basic that's rarely a good idea.
Seich has quit [Quit: Gone fishing.]
Seich has joined #crystal-lang
Seich has quit [Quit: Gone fishing.]
Seich has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
f1reflyylmao has quit [Quit: bye fags]
f1refly has joined #crystal-lang
jrayhawk has quit [Read error: Connection reset by peer]
jrayhawk has joined #crystal-lang
jrayhawk has quit [Remote host closed the connection]
jrayhawk has joined #crystal-lang
hsh has joined #crystal-lang
<FromGitter> <asterite> oprypin: https://github.com/lbarasti/rate_limiter
<FromGitter> <asterite> just out from the oven
<oprypin> :o
<oprypin> that's amazing
<yxhuvud> odd. make clean && make spec in main crystal repo (latest master) fails with .build/all_spec: symbol lookup error: .build/all_spec: undefined symbol: __libc_start_main, version WeakRef(T)#initialize</home/linus/prog/crystal/spec/std/weak_ref_spec.cr::Foo>:(Int32 | Nil)
riffraff169 has left #crystal-lang [#crystal-lang]
riffraff169 has joined #crystal-lang
* FromGitter * tenebrousedge really wants the `shards` PR that fixes all the tests to be merged 😬
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
postmodern has joined #crystal-lang
<FromGitter> <rishavs> In an HTTP Server, how can I pass arguments/values from one middleware to another? Is adding a custom param to act as a store the way to go?
<straight-shoota> yes
<straight-shoota> you can add a custom ivar to HTTP::Context
<FromGitter> <rishavs> Thanks! So my plan is to have an auth middleware which will extract the userid into a param which can then be used by subsequent middlewares and the response.
<FromGitter> <Blacksmoke16> 👍 thats a common thing
<FromGitter> <j8r> @rishavs I sounds like you should start to look at a web framework
<FromGitter> <j8r> it goes beyond a simple HTTP server
<FromGitter> <j8r> Usually framework have a simple way to put a set of routes behind auth. And some, without even monkey-patching the HTTP context
<FromGitter> <rishavs> I actually want to use the std lib only. There is just so much learning that way. I have only ever used high level frameworks before and i really didn't understand much about how things worked. But using the std lib has been quite a revelation
<FromGitter> <j8r> You know you're starting to make your own web framework. Might be fine, if the goal is to learn
<FromGitter> <rishavs> yeah sort of. 😅 ⏎ I code mostly for fun and stress release. My day job is non coding.
<FromGitter> <j8r> 👍
<FromGitter> <j8r> You're a Program Manager? Not thin one https://en.wikipedia.org/wiki/Program_Manager
<FromGitter> <Dan-Do> How to loop through all the matches of regex: ⏎ ⏎ ``` pp! m[0], m[1]``` ⏎ ⏎ => print foo, bar 2 times [https://gitter.im/crystal-lang/crystal?at=5fc294c7b956e94695a49bf7]
<FromGitter> <j8r> Sounds like Project Manager
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/String.html#scan(pattern:Regex)-instance-method
<FromGitter> <Blacksmoke16> theres also a block version that might be better for what you want to do tho
<FromGitter> <Dan-Do> oops, I was looking at https://crystal-lang.org/api/0.35.1/Regex/MatchData.html
<FromGitter> <Dan-Do> lol
<FromGitter> <rishavs> > You're a Program Manager? Not this one https://en.wikipedia.org/wiki/Program_Manager ⏎ ⏎ :D Program/Product Manager. Definitely not that one
<FromGitter> <j8r> got it
<FromGitter> <j8r> even though you could be Program Manager of the Program Manager product haha 😆
<FromGitter> <rishavs> ^_^
<FromGitter> <Dan-Do> It seems my regex is wrong, it matches the whole string, but I want multiple small matches: ⏎ `"__foo__bar____foo__bar__".match(/.*(foo).*(bar).*/)`
<FromGitter> <Dan-Do> it matches `foo__bar____foo__bar`
<FromGitter> <Blacksmoke16> prob need a `?` in there somewhere to make it lazy
<FromGitter> <Dan-Do> can you help me out? https://regex101.com/r/PCrCVv/1
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/a0kj
<FromGitter> <ImAHopelessDev_gitlab> hi
<straight-shoota> Blacksmoke16, how would you serve a folder of static assets in athena?
<FromGitter> <ImAHopelessDev_gitlab> @rishavs sounds like me. i work at home depot lol, but code for fun
<FromGitter> <Dan-Do> > can you help me out? https://regex101.com/r/PCrCVv/1 ⏎ ⏎ nvm, I did it
<FromGitter> <Blacksmoke16> 👍 nice
<FromGitter> <Blacksmoke16> straight-shoota mm prob would want to do essentially what the stdlib's middleware is doing, but make it a listener
<FromGitter> <Blacksmoke16> i can work up an example if you'd like
<straight-shoota> it's really hard to try to figure such things out with only API docs
<straight-shoota> athena looks great, but some easy tutorials/cookbook recipies would really help to get started
<FromGitter> <Blacksmoke16> in this case its not something built in. So i cant really be expected to document everything thats possible
<straight-shoota> not everything
<FromGitter> <Blacksmoke16> but things that are common, like this, could be added to the cookbook
<straight-shoota> but examples of what you can do with what
<straight-shoota> there is a cookbook?
<FromGitter> <Blacksmoke16> https://github.com/athena-framework/athena/wiki/Cookbook a basic one at least
<FromGitter> <Blacksmoke16> now that i think about it never actually closed the loop on it. I.e. adding links to API docs/readme
<straight-shoota> yeah
<straight-shoota> it's completely hidden
<straight-shoota> I'd recommend to put it on a website, not github wiki
<straight-shoota> next to api docs
<FromGitter> <Blacksmoke16> wiki was a quick solution to get something out there
<FromGitter> <Blacksmoke16> longer term deff need something a bit more robust
<FromGitter> <Blacksmoke16> at least for the stuff that doesnt really relate to any specific thing in the API docs
<FromGitter> <Blacksmoke16> like the cookbook/guides/higher level docs etc
<oprypin> Blacksmoke16, just start the investment right now. put a much lower bar for what "doesnt really relate to any specific thing in the API docs"
<oprypin> wiki is a bunch of markdown files. make an explicit bunch of markdown files instead. in the repo.
<FromGitter> <Blacksmoke16> Sounds like a good winter project
<FromGitter> <Blacksmoke16> good news is a good amount is already written, so would just be moving it around a bit
<yxhuvud> Famous last words. Risk is that you will realize exactly how much is missing :)
FromGitter has quit [Read error: Connection reset by peer]
FromGitter has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> what's up with the acronyms "IMO", "IMHO", and "JMO" used on the internet nowadays? i see it a lot on github and IT related discussions. i don't remember this being a thing 5-7 years ago
sorcus has quit [Quit: WeeChat 2.9]
<straight-shoota> IMO that didn't change. At least I've jused it 10 years ago.
sorcus has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> maybe i just didn't notice it back then and now have
<yxhuvud> nowadays? they have existed at the very least since the 80s.
<FromGitter> <codenoid> how are you