<FromGitter>
<jwaldrip> is it possible to get the type of a var passed to a macro?
<FromGitter>
<jwaldrip> doesnt look like it :-(
<FromGitter>
<jwaldrip> even though the compiler should know the type
<FromGitter>
<jwaldrip> just looking to see if I can convert a named tuple to inline vars.
<postmodern>
where do you / how do you compile benchmark scripts for shards? Coming from ruby, I'd inject lib/ into $LOAD_PATH, but with crystal i assume i'd want to compile src/ along with the benchmark script?
oprypin has quit [Ping timeout: 256 seconds]
FromGitter has quit [Ping timeout: 272 seconds]
FromGitter has joined #crystal-lang
oprypin has joined #crystal-lang
<FromGitter>
<Daniel-Worrall> `sleep 0.seconds`
<FromGitter>
<mixflame> thx
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 240 seconds]
<postmodern>
nm, remembered that i could use macros to generate a bunch of explicit requires to pull in stuff from ./src/
<FromGitter>
<jwaldrip> can you get the protocol from an http request?
<woodruffw>
@jwaldrip: both HTTP::Request and HTTP::Response have a `#version` getter
<woodruffw>
(assuming that's what you mean by the protocol)
<postmodern>
why are crystal binaries not compiled with --release significantly slower than --release compiled binaries?
<FromGitter>
<naqvis> should be due to compiler optimization
<postmodern>
ah, wondering if there are extra checks for debugging in non-release builds or something
<FromGitter>
<naqvis> I would say that debug info just bloat the size, but shouldn't have any impact on the speed. Its just LLVM optimizations aren't set during the normal build
<FromGitter>
<naqvis> for sure, some one from core team need to provide the exact details :P
<FromGitter>
<naqvis> or you can do a quick spike to see if binaries built in release mode with and without full symbolic debug info shows any differences ⏎ ` `` ⏎ crystal build --no-debug --release xxxxxxx ⏎ crystal build -d --release xxxxxx ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5f0d29f746c75b1e5e442350]
<FromGitter>
<wontruefree> Sushi Chain also has a lot of c extensions and I find is a good example for using C extensions in their libs https://github.com/SushiChain/
<postmodern>
wontruefree, when I say embed, I mean putting the C code directly into the shard repo, instead of binding to a pre-installed C library.
<postmodern>
I'm guessing LD_LIBRARY_PATH would give me problems?
<FromGitter>
<mixflame> Can you guys identify anything about my server that I'm doing asynchonously that I'm doing wrong?
<FromGitter>
<mixflame> When I send large data (large amount of POINTs) the client can't receive chats at the same time.
<FromGitter>
<mixflame> Or am I just simply pushing the client socket to it's limit?
sorcus has joined #crystal-lang
<FromGitter>
<mixflame> I haven't found a good place to `sleep` or `sleep 0.seconds` yet
<woodruffw>
postmodern: building a static library and linking to it _should_ work -- i think i did that a year or so ago
<woodruffw>
assuming that you're linking to things the usual way, passing `--static` to either `shards` or `crystal` should do the trick
<FromGitter>
<naqvis> postmodern you can link the `.o` file when building your crystal app
<postmodern>
woodruffw, naqvis, good to know. i'll look into static linking
<postmodern>
hmm but how does one do that via a shard that isn't meant to be executable, but be compiled into other projects?
<postmodern>
has to be some way of propegating linking flags from the shard
<FromGitter>
<wontruefree> if people are interesting in hearing more about Athena we also are now able to upload to youtube https://youtu.be/VVuLZvpCUAs
alexherbo2 has joined #crystal-lang
<FromGitter>
<naqvis> postmodern link flags will be placed in your shard via `@[Link...]` annotation and compiler will take care of that
<FromGitter>
<naqvis> but if your shard need to compile some C code, then you can use `postinstall` hook of Shards, provide Makefile and invoke that during `postinstall` hook
<postmodern>
naqvis, excellent information, thank you
<FromGitter>
<naqvis> you are welcome 👍
alexherbo2 has joined #crystal-lang
oddp has joined #crystal-lang
postmodern has quit [Quit: Leaving]
Liothen has quit [Ping timeout: 244 seconds]
Liothen has joined #crystal-lang
oddp has quit [Quit: quit]
<FromGitter>
<jaitaiwan_gitlab> Evening everyone! Would someone have a learning resource suggestion for learning about how to take an integer (such as the unix file mode flags) and split it out into "sections" like Crystal has done with File::Permissions, File::Type and File::Info?
<FromGitter>
<jaitaiwan_gitlab> I assume it's something to do with bit-shifting, I'm just not certain.
<FromGitter>
<jaitaiwan_gitlab> Thanks for that yxhuvud. I have already looked at that... the issue is that I need to convert from a unix integer to the Enum's I mentioned above (File::Type, File::Permissions, File::Info)
<FromGitter>
<Blacksmoke16> @jwaldrip if you pass it like `var : Int32` yes
deavmi has quit [K-Lined]
<FromGitter>
<andrewc910> Best way to encrypt/decrypt a serialized object? Can't find anything in the api docs :/
<FromGitter>
<naqvis> This will depend on how "Best" is defined, also which stdlib api did you try?
<FromGitter>
<jwaldrip> @Blacksmoke16 will that give me whether its http/https?
<FromGitter>
<Blacksmoke16> got an example of what you're trying to do?
<FromGitter>
<andrewc910> @naqvis best as in most conventional? I was looking into Openssl::Cipher as it was the only `encrypt` method. Couldn't really figure it out.
<FromGitter>
<andrewc910> `Digest::SHA1.base64digest("foo")` I believe i might of found it
<FromGitter>
<naqvis> @andrewc910 compression related modules are located under `Compress` namespace
<FromGitter>
<naqvis> stdlib comes with `Zip`, `Gzip`, `ZLib`, `Deflate`
<FromGitter>
<naqvis> but if you need other compression formats then you will need to use external shards
<FromGitter>
<naqvis> my github account has few like `Brotli`, `XZ`, `LZ4`, `Snappy` etc
<FromGitter>
<naqvis> similarly you can find others via different shards
<FromGitter>
<andrewc910> `got an example of what you're trying to do?` oh, maybe this wasn't aimed at me! If not, my apologies for pinging ya
<FromGitter>
<Blacksmoke16> yea sorry, that was to @jwaldrip
<FromGitter>
<andrewc910> NP
<FromGitter>
<naqvis> @andrewc910 Sorry I thought your question was regarding compression :P
<FromGitter>
<naqvis> but seems you are after Encryption
<FromGitter>
<Blacksmoke16> that is what he said :P
<FromGitter>
<Blacksmoke16> 🙈
<FromGitter>
<naqvis> lol
<FromGitter>
<naqvis> apologies
<FromGitter>
<naqvis> please take a look at `Crypto` module in stdlib
<FromGitter>
<naqvis> also `OpenSSL` provides some Algos like SHAXX
<FromGitter>
<andrewc910> Is crypto::base64 what I am looking for? encode/decode?
<FromGitter>
<Blacksmoke16> theres a diff between encoding and encrypting
<FromGitter>
<Blacksmoke16> to be clear you want encrypting yes?
<FromGitter>
<Blacksmoke16> i guess the question to ask whats the goal with this? To prevent people from seeing the content, or making sure no one tampered with the content?
<FromGitter>
<andrewc910> Hmm, i believe encrypt. I am doing something like this: https://github.com/unabridged/motion ⏎ ⏎ TLDR: Serialize objects, store in html doc. User clicks on event, JS sends serialized object to server, server recreates object, invokes the event, sends new state back for rendering. ⏎ ⏎ Because i have to store the state of the object in an HTML doc and the user has access to this, i believe
<FromGitter>
<Blacksmoke16> sounds like a lot of work
<FromGitter>
<andrewc910> It's a lot more work when you can't even figure out how encrypt a dang json!
<FromGitter>
<Blacksmoke16> this is something that could deff be improved on, is kinda a pita ;P
<FromGitter>
<jwaldrip> @Blacksmoke16 I am trying to provide a url helper for views and I want to be able to link to a particular asset and know whether or not the incoming request is over http or https
<FromGitter>
<naqvis> if its plain Ajax/WS like communication, then JSON is already the format. But if remote server is expecting the contents to be encrypted using some specific encryption algorithm, then you can encrypt them and send the encrypted data via base64 encoding (if other side is expecting text) or you can simply send the encrypted binary
<FromGitter>
<naqvis> encryption methods, turns data into binary format
<FromGitter>
<naqvis> but plz. bear in mind encryption/decryption is cpu-intensive activity
<FromGitter>
<Blacksmoke16> what would be the data tho
<FromGitter>
<Blacksmoke16> i.e. dont you need the data to encrypt + a key used to encrypt it?
<FromGitter>
<andrewc910> The actual data is serialized component. A component is just like a react component. Here is an example with ruby: https://github.com/unabridged/motion-demos/blob/master/app/components/calculator_component.rb ⏎ ⏎ The object is serialized and store in the view so the state can pick up where it left off. ⏎ ⏎ If i leave is as a plain json, that opens up the door to users tampering with the data. If
<FromGitter>
<andrewc910> Yes the key would be stored on the server. Right now it just just hardcoded to a file.
<FromGitter>
<naqvis> if data isn't that sensitive, i would say you can calculate the signature and store that along with json contents, on receiving side, you can validate the contents by calculating the signature and comparing that with the provided one. This will save you effort of encrypting/decrypting whole data on both sides
<FromGitter>
<andrewc910> Hmm, can you point me at the api docs or an article? I don't understand `calculate the signature`
<raz>
andrewc910: do you control both the encrypting and decrypting side?
<FromGitter>
<naqvis> by signature i mean hash of JSON contents, it could be either MD5 or any SHAXX
<FromGitter>
<andrewc910> Yes
<raz>
andrewc910: and https (encrypted transport) is not enough?
<FromGitter>
<andrewc910> @naqvis so hash the json. Then when i get the request, rehash the json and make sure they are the same?
<FromGitter>
<naqvis> yeah
<raz>
andrewc910: ah, it looks like what you want is a JWT
<FromGitter>
<andrewc910> The json is the state of the view being store in the html doc. I am not worried about the state being manipulated in transit. I am worried users will manually manipulate the state in the inspector tool, fire off a request & now a manipulated object is running on the sever.
<FromGitter>
<andrewc910> I am no security expert. I have no idea what could happen with a user manipulating the state of a view object but i don't really want to find out.
<FromGitter>
<naqvis> if json contents are modified, their hash will be different
<FromGitter>
<andrewc910> @ali, i will give it a go! Thanks :)
<FromGitter>
<naqvis> 👍
<raz>
(would advise against trying custom stuff with signatures unless you know what you're doing - the standard thingers exist because it's easy to get it subtly wrong)
postmodern has joined #crystal-lang
<FromGitter>
<tenebrousedge> o/
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 260 seconds]
renich has joined #crystal-lang
alexherbo2 has joined #crystal-lang
deavmi has joined #crystal-lang
renich has quit [Quit: renich]
renich has joined #crystal-lang
alexherbo20 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 246 seconds]
alexherbo20 is now known as alexherbo2
_whitelogger has joined #crystal-lang
renich has quit [Ping timeout: 256 seconds]
alexherbo23 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 256 seconds]
alexherbo23 is now known as alexherbo2
renich has joined #crystal-lang
renich has quit [Ping timeout: 264 seconds]
renich has joined #crystal-lang
<FromGitter>
<nolyoi> def initialize(index = 0, data = "data", previous_hash = "hash") ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Error: instance variable '@index' of CrystalChain::Block must be Int32, not String [https://gitter.im/crystal-lang/crystal?at=5f0e27ee26b22649721e95e7]
<FromGitter>
<nolyoi> any clues why I'm getting this error that @index is being interpreted as a string?
<FromGitter>
<Blacksmoke16> can you share more of the code/error?
<FromGitter>
<Blacksmoke16> well you're passing `"Hello, Crypto!"` as the `index` argument
<FromGitter>
<Blacksmoke16> `index = 0` doesnt restrict the type, just sets a default value
<FromGitter>
<Blacksmoke16> so id imagine somewhere else you are doing `@index : Int32`, when its essentially doing `@index = "Hello, Crypto!"`, hence the error
<FromGitter>
<nolyoi> hmm, type was never set anywhere. so technically it shouldve still ran right? thats the entire code there. I get what youre saying though. I forgot to add the data: in `CrystalChain::Block.new("Hello, Crypto!").hash`
<FromGitter>
<Blacksmoke16> actually `index = 0` prop infers the type
<FromGitter>
<nolyoi> I'm following a tutorial to try and help learn things a bit. Running into another problem. ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Why am I having to call variables like this: previous_node.@index? if I dont, im getting the undefined method error. seems very odd. [https://gitter.im/crystal-lang/crystal?at=5f0e323b1cc043695962d8ea]
<FromGitter>
<Blacksmoke16> as the error says, there isnt a method called `.index`
<FromGitter>
<Blacksmoke16> just defining an ivar doesnt expose it
<FromGitter>
<Blacksmoke16> and you shouldnt do `.@index` thats a low level hack
<FromGitter>
<Blacksmoke16> add getters for the ivars you want to expose