sevensidedmarble has quit [Remote host closed the connection]
blove has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 244 seconds]
kandayo has quit [Read error: Connection reset by peer]
rohitpaulk has joined #crystal-lang
<FromGitter>
<redcodefinal> Hey been working with `UDPSocket` and I'm trying to get it to send packets to a broadcast address (255.255.255.255). I can't really find much in the way of documentation on how to use the `Socket#setsockopt` method. Currently I have a working version of this in ruby ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ This gives a permission denied error. ... [https://git
<FromGitter>
<jemc> Trying to write a Crystal program that uses the `llvm` library. Here's the example program I'm trying to compile (https://play.crystal-lang.org/#/r/5lhk). I get a similar link error locally as the one seen there. I have `llvm-config50` present on my `$PATH`. What else do I need to do to get LLVM to link properly with my Crystal program?
<FromGitter>
<j8r> @proyb6 you can declare a Pointer like `var = pointerof(true)`. The type will be `Pointer(Bool)`. You can modify the value with `var.value = false`
<FromGitter>
<icyleaf> Hi guys, Is there has solution to reflecting a struct or class outside itself in Crystal?
<FromGitter>
<proyb6> @j8r I see, like your CON shard!
rohitpaulk has joined #crystal-lang
korzybski has joined #crystal-lang
korzybski has quit [Client Quit]
rohitpaulk has quit [Ping timeout: 268 seconds]
<FromGitter>
<j8r> @icyleaf what's reflecting? You can have a method returning `self` to have the current object
<FromGitter>
<kingsleyh> Hi - if anyone with Dev skills is interested in helping out on SushiChain (blockchain project) please contact me - I’m open to giving out coins or future equity - obviously we have no worth right now - but once listed on an exchange then we will have some worth - we have lots of interesting things to do :)
<FromGitter>
<vladfaust> @j8r are you intending to keep the naming as Cretin ..?
<FromGitter>
<j8r> @vladfaust haha I think yes, second degree humor. I've purposely started with C to have alternative names like Configuration Object Notation or Crystal Object Notation.
<FromGitter>
<j8r> Cretin is similar to Git
<FromGitter>
<j8r> (https://en.wikipedia.org/wiki/Git#Naming) . Con can also means scam, and dumb in French. ⏎ All of this means this serialization format is designed to be used by even the dumbest person, like me 😄
<FromGitter>
<rishavs> Is there an elegant way to convert an array into a hash or json? Currently i am using map and doing gnarly string operations. ⏎ my input is `["tag1", "tag2", "tag3"]` and the expected output is `{"tag1" => true, "tag2" => true, "tag3" => true}`
<FromGitter>
<yxhuvud> if you have true for all the values, have you looked at Set?
<FromGitter>
<rishavs> I am fine with any recurring dummy value. I generally use true or 1. I haven't used sets before
<FromGitter>
<rishavs> My keys are unique, so sets might be good here
<FromGitter>
<j8r> @rishavs what do you need at the end?
<FromGitter>
<j8r> a list of non duplicated values?
<FromGitter>
<rishavs> I generally convert this hash into json to insert into my database
<FromGitter>
<rishavs> For example, if I do ⏎ ⏎ ```myarray = ["nature", "news"] ⏎ pp [myarray, [true, true]].to_h ``` ⏎ ⏎ i get `{"nature" => "news", true => true}` but I want `{"nature" => true, "news"=> true}` [https://gitter.im/crystal-lang/crystal?at=5bf6a72aed6bcf1ef841c08e]
<FromGitter>
<rishavs> Thanks! Can I also do this with map?
<FromGitter>
<vladfaust> Any way to get a *NamedTuple* which is a diff between two NamedTuples?
<FromGitter>
<vladfaust> NM, expanding namedtuple for myself
<jokke>
RX14: hey there o/ i'm testing out the pub-relay and i get a 503 back from my mastodon instance when i try to subscribe to the pub-relay. Any idea what that means? The instance is accessible from the pub-relay and responds correctly for other routes.
<RX14>
what does the log say
<jokke>
which one?
<RX14>
the relay...
<jokke>
sec
<RX14>
if its a 503 there should be a fairly clear error in the logs
<FromGitter>
<fenicks> I'm looking a way to set which core a crystal program can use. It's called cpu affinity most of the time.
<FromGitter>
<vladfaust> Have no idea what are you talking about :)
<FromGitter>
<fenicks> @vladfaust , ok you now when you build and run a program on multi-core machine, you can specify which core your program will use. On Windows odd core ID are master (more powerful), on linux even core Id are master.
<FromGitter>
<fenicks> @Sija Thanks. I was looking for a crystal shards if not I'll use a C binding. Nice!
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 244 seconds]
<FromGitter>
<rishavs> Need some help with creating json like strings. I have a hash which I convert to json. But now inside the string a lot of "\" come which I dont want. https://carc.in/#/r/5ls2
<FromGitter>
<Blacksmoke16> use `puts`
<FromGitter>
<bararchy> yeha `pp` shows escape letters, if you print or `puts` those strings you wont see it
<FromGitter>
<rishavs> or a better example is `INSERT INTO books VALUES (1, '{"title": "Sleeping Beauties", "genres": ["Fiction", "Thriller", "Horror"], "published": false}'); `
<FromGitter>
<bararchy> oh no
<FromGitter>
<bararchy> this is an SQLi waiting to happen
<FromGitter>
<bararchy> never interpolate inside a query string, always use Parameterized Queries and Prepared Statements
<FromGitter>
<sdzyba> I remember a discussion regarding dependency importing in Crystal. ⏎ Just saw an interesting (although not "native") way to do explicit imports in Ruby: https://github.com/ciconia/modulation
<FromGitter>
<rishavs> dont SQLi only happen when you are accepting user input? If my app itself is generating the query, i dont think anyone can inject anything in the sql
<FromGitter>
<bararchy> @rishavs if the data is never from user input you should be "safe" unless a change occuer and you forget about this part of the code and then half a year later your whole DB is in pastebin
<FromGitter>
<rishavs> gotcha. good point. so I will have to do something like this ⏎ `INSERT INTO books VALUES (1, $1), "'{"title": "Sleeping Beauties", "genres": ["Fiction", "Thriller", "Horror"], "published": false}'"`
<FromGitter>
<rishavs> but my original problem still remains, getting a json like string without \
<FromGitter>
<bararchy> @rishavs your example have `\` only because you print with `pp`, it's not really there
<FromGitter>
<rishavs> oh! did i really waste an hour over something like ?? T_T
<FromGitter>
<jemc> Still having trouble linking LLVM to compile a program that uses the `llvm` library in Crystal. I have tried with both LLVM 5 and LLVM 6 (installed with `dnf`, my package manager). I downloaded this sample from the main crystal repo (https://github.com/crystal-lang/crystal/blob/master/samples/llvm/brainfuck.cr) as `~/1/llvm-example.cr` and ran `env LLVM_CONFIG=/usr/bin/llvm-config-64 crystal ~/1/llvm-example.cr
<FromGitter>
<jemc> summary: ⏎ `undefined reference to 'llvm::User::anchor()'` ⏎ `clang-6.0: error: linker command failed with exit code 1`
<FromGitter>
<jemc> is there anything special I need to do to get crystal to link properly to LLVM?
<FromGitter>
<jemc> I wonder if it is an issue where the LLVM version I am using in my Crystal program needs to be exactly the same version that was used to compile Crystal itself? That would be a pain, but maybe not surprising?
DTZUZO has quit [Ping timeout: 240 seconds]
korzybski has quit [Quit: korzybski]
<FromGitter>
<jemc> Yeah, that seemed to do it. With `crystal --version`, I learned that my `crystal` binary was compiled against `LLVM 4.0.0`. I installed that and switched to `LLVM_CONFIG=/usr/bin/llvm-config-4.0-64`, and no more linker error 🎉
<FromGitter>
<Blacksmoke16> nice oen
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter>
<jgaskins> Since shard dependencies mostly just pull from GitHub, is there a convention in Crystal for setting a version while the next version is in development so that, for example, version `1.5` isn't potentially every commit between `1.5` and `1.6`?
<FromGitter>
<vladfaust> @jgaskins didn't fully understand the question, but usually shards use Semantic Versioning and minor versions only - e.g. `0.1.0`, `0.2.0` - because the language is not 1.0 yet
<FromGitter>
<vladfaust> We use patch versions for breaking functionality (i.e. `0.1.0` -> `0.2.0`) and minor versions for bugfixes and new non-breaking functionality (i.e. `0.1.0` -> `0.1.1`)
<FromGitter>
<vladfaust> Was confused about naming, looked at https://semver.org/
<FromGitter>
<jgaskins> @vladfaust Those numbers were made up to have a reference point. :-)
<FromGitter>
<jgaskins> What I mean is, if I set my shard to version `1.5`, and someone installs it as a dependency for their app, then I push a commit, version `1.5` now points to a new version of the code.
<oprypin>
jgaskins, it looks at tags in the repo primarily
<FromGitter>
<jgaskins> ahhh, cool. I was thinking of using tags, but just wanted to make sure there wasn't already a convention for it.
<FromGitter>
<jgaskins> thanks!
<oprypin>
it is normal to change this version only on release, then tag it, then leave it alone even if it's not really that version anymore
<FromGitter>
<Blacksmoke16> and when making the version be sure to add a `v` before it
<FromGitter>
<vladfaust> I can't know instance vars in macros, that's why
<FromGitter>
<vladfaust> Cannot hook `name=`
<FromGitter>
<Blacksmoke16> i had an idea for the serializeable stuff, have a `path` annotation property that will go thru the json obj and set that ivar to the value at the end
<FromGitter>
<Blacksmoke16> as currently its not simple to do if you dont want to define a bunch of nested objects, and just want 1 value from it