jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.7.1 | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/manastech/crystal - Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
sferik has quit [Quit: Textual IRC Client: www.textualapp.com]
ismaelga has joined #crystal-lang
broz has quit [Remote host closed the connection]
ismaelga has quit [Remote host closed the connection]
ismaelga has joined #crystal-lang
kulelu88 has quit [Quit: Leaving]
willlll has quit [Quit: willlll]
<crystal-gh> [crystal] vonagam opened pull request #667: fix enum bitwise complement (master...fix_enum_bitwise_complement) http://git.io/vTGir
_havenn has joined #crystal-lang
havenwood has quit [Ping timeout: 272 seconds]
notfowl has quit [Excess Flood]
notfowl has joined #crystal-lang
_havenn is now known as havenwood
notfowl has quit [Excess Flood]
notfowl has joined #crystal-lang
notfowl has quit [Excess Flood]
notfowl has joined #crystal-lang
ismaelga has quit [Remote host closed the connection]
BlaXpirit has joined #crystal-lang
notfowl has quit [Excess Flood]
notfowl has joined #crystal-lang
notfowl has left #crystal-lang [#crystal-lang]
JBat has joined #crystal-lang
BlaXpirit has quit [Quit: Quit Konversation]
vikaton has quit [Quit: Connection closed for inactivity]
waterlink has joined #crystal-lang
ponga has joined #crystal-lang
willlll has joined #crystal-lang
waterlink has quit [Quit: Leaving.]
strcmp1 has quit [Ping timeout: 256 seconds]
strcmp1 has joined #crystal-lang
unshadow has quit [Quit: leaving]
ismaelga has joined #crystal-lang
willlll has quit [Quit: willlll]
ismaelga has quit [Ping timeout: 264 seconds]
Ven has joined #crystal-lang
DerisiveLogic has quit [Ping timeout: 264 seconds]
Ven has quit [Read error: No route to host]
DerisiveLogic has joined #crystal-lang
DerisiveLogic has quit [Remote host closed the connection]
strcmp1 has quit [Ping timeout: 245 seconds]
strcmp1 has joined #crystal-lang
unshadow has joined #crystal-lang
<unshadow> How would be the best way to generate all the numbers from 0000000 to 9999999, like 0000001, 0000002 etc.. untill 99999999
datanoise has quit [Ping timeout: 256 seconds]
<unshadow> I was thinking about creating 7 ranges from 0..9 then do each do for each of them, but that fells stupid
Ven has joined #crystal-lang
JBat has quit [Quit: Computer has gone to sleep.]
ponga has quit [Remote host closed the connection]
<unshadow> Ok, so after playing around this is what I came out with, what do you guys think ? http://carc.in/#/r/7d
<unshadow> I was stupid... nm http://carc.in/#/r/7e
ponga has joined #crystal-lang
datanoise has joined #crystal-lang
ponga has quit [Remote host closed the connection]
leafybasil has quit [Remote host closed the connection]
datanoise has quit [Ping timeout: 256 seconds]
ponga has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
leafybasil has joined #crystal-lang
ponga has quit [Remote host closed the connection]
ponga has joined #crystal-lang
ponga has quit [Client Quit]
JBat has joined #crystal-lang
havenwood has quit [Ping timeout: 264 seconds]
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vTn20
<crystal-gh> crystal/master b910038 Ary Borenszweig: Merge pull request #667 from vonagam/fix_enum_bitwise_complement...
<crystal-gh> crystal/master 275251f Dmitry Maganov: fix enum bitwise complement
<travis-ci> manastech/crystal#2344 (master - b910038 : Ary Borenszweig): The build is still failing.
BlaXpirit has joined #crystal-lang
vikaton has joined #crystal-lang
ponga has joined #crystal-lang
datanoise has joined #crystal-lang
datanoise has quit [Ping timeout: 256 seconds]
<unshadow> Someone here with a little C know how ? :) jhass, havenwood ?
<jhass> maybe, just ask your question and be patient :P
Ven has joined #crystal-lang
<strcmp1> the fact that so many people come from #nim im going to guess there's more than just those two ;)
asterite has joined #crystal-lang
<unshadow> Lets try, I want to add a new fun to a lib, checking the file.h in my OS I can see the function is there, but, when calling it from crystal I get : OpenSSL::SSL::Context:(.text+0x146): undefined reference to `SSL_CTX_set_mode'
<unshadow> but in ssl.h I can see in line 785 : # define SSL_CTX_set_options(ctx,op) \
<jhass> crystal doesn't read header files
<jhass> you have to do the lib declaration manually
<asterite> also, that's a macro
<unshadow> @[Link("ssl")]
<asterite> well, it's a #define, so there's no real function there
<unshadow> yeha, I want to add fun ssl_ctx_set_options = SSL_CTX_set_mode(context : SSLContext, text : Int32) : Int32
<asterite> unshadow: I mean, SSL_CTX_set_mode doesn't really exist, only in C programs that use that header. You'll have to do what SSL_CTX_set_mode does in crystal code
<unshadow> ohhh
<asterite> what's the definition of SSL_CTX_set_options ?
<unshadow> # define SSL_CTX_set_options(ctx,op) \ SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,(op),NULL)
<unshadow> this maybe ?
<asterite> Yes
<jhass> long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg);
<jhass> SSL_CTRL_OPTIONS is another macro or a constant
<asterite> These C people don't trust inliners :-P
<jhass> well, back then probably rightfully so^^
<unshadow> So, to create the ssl_ctx_set_options, I actually need to do a fun for SSL_CTX_ctrl ?
<jhass> I see none already, so yeah
<unshadow> what the point of the NULL in the end ?
<jhass> it's passing a null pointer to parg
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jhass> The SSL_*_ctrl() family of functions is used to manipulate settings of the SSL_CTX and SSL objects. Depending on the command cmd the arguments larg, parg, or
<jhass> fp are evaluated. These functions should never be called directly. All functionalities needed are made available via other functions or macros.
<jhass> hf fun reading source to find out why ;)
<unshadow> These functions should never be called directly :(
<jhass> I bet other bindings do
<unshadow> well... fun ssl_ctx_set_options = SSL_CTX_ctrl(context : SSLContext, text : Int32, Void*) : Int32
<jhass> oh, leaving an argument unnamed is valid?
<unshadow> not sure that why text : Int32 haha
<jhass> I don't think that signature is right
<unshadow> jhass, what do you mean ?
<jhass> I'd go for (context : SSLContext, command : LibC::IntT, long_arg : LibC::LongT, pointer_arg : Void*)
<jhass> asterite: somebody wants String#slice badly :D http://carc.in/#/r/7r
<strcmp1> jhass, clicking on "new" doesn't seem to work btw, empty white page appears.
<unshadow> Lol, I do :)
sandelius has joined #crystal-lang
<strcmp1> empty except for Run #7r
<jhass> huh? weird
<strcmp1> just me?
<jhass> strcmp1: mind peeking at your error console?
<strcmp1> sure
<unshadow> nope, if you wait a while and do "new" it gets stuck
<unshadow> for me too
Ven has joined #crystal-lang
<asterite> asterite: what would String#slice be?
<jhass> oh, interesting
<strcmp1> it's empty here, jhass, no errors at all
<unshadow> asterite, returns Slice.new for the string ?
<jhass> okay, the new button is broken here too, but initial load and shortcut is fine
ponga has quit [Remote host closed the connection]
ponga has joined #crystal-lang
<jhass> well, that was dumb, fix deployed for the button
<jhass> unshadow: asterite I'd vote for .to_slice
<jhass> strcmp1: what browser?
<asterite> And it'll be a slice of UInt8?
<unshadow> sure, .to_slice is better
<jhass> I guess
<unshadow> yeha Uint8 array
<asterite> Yes, we can add it
<unshadow> yey !
<asterite> But maybe we need a new type, ImmutableSlice, which doesn't have #[]=
<asterite> Slice would just inherit ImmutableSlice
<asterite> The thing is, String is immutable, wouldn't be nice to accidentally change it
<jhass> well, you could with to_unsafe already too, no?
<asterite> Yes, you can do Slice.new(string.to_unsafe, string.bytesize)
<asterite> and that makes it explicit that you are going into the unsafe world ;-)
<asterite> we should remove the "cstr" method, I think...
<jhass> I view Slice similar unsafe
<asterite> Yeah, me too... it's safer than a pointer, but still kind of like a pointer, so unsafe...
<jhass> so I'd argue what to_unsafe lets you do, to_slice should too
<jhass> being really just a convenience wrapper around Slice.new(to_unsafe, my_length)
<asterite> We could still have ImmutableSlice, it's easy to do and will be a bit safer
<asterite> What do you need to do with that slice?
<strcmp1> jhass, chrome 42.0.2311.135
<unshadow> What would be "const char *str" in Crystal ? I used UInt8* is that right ?
<jhass> strcmp1: works fine here with Chromium Version 42.0.2311.135 (64-bit) :/
<jhass> yes
<unshadow> jhass, yes was for me ?
<jhass> yes
<unshadow> thanks
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vTcth
<crystal-gh> crystal/master 8c29b8b Ary Borenszweig: Parse comments in macros. This allows macros that generate code to also generate doc comments by using interpolation
<crystal-gh> crystal/master 12d3a04 Ary Borenszweig: Added many options to `String#to_i` to make it very flexible: whitespace, underscore, prefix and strict
<crystal-gh> [crystal] bararchy opened pull request #669: Added more functionality to openssl (master...master) http://git.io/vTcmt
<jhass> unshadow: might want to port https://github.com/jhass/DeBot/blob/master/core_ext/src/core_ext/openssl.cr to 0.7 while at it ;P
<unshadow> Oh, I didnt know you were working on SSL too XD
<jhass> eh, look at the commit date ;)
<unshadow> 4 months ago, I see ;)
<unshadow> Btw, this is the first time I think I actually did a PR for a project, I'm kinda happy :)
<jhass> congratz ;)
<unshadow> It still has some issues though, right now the code I wrote in the PR should allow a full functional SSL Socket, but, Something is broken some where, so the client never get a SSL Cipher offer ... it's wierd
<travis-ci> manastech/crystal#2345 (master - 8c29b8b : Ary Borenszweig): The build is still failing.
<asterite> unshadow: we'll probably merge your PR, but I know nothing about openssl so I really can't review the code, I'll ask @waj when I see him next time... or if jhass thinks it's OK too, I'll merge it
<asterite> there are also no equivalent methods in Ruby: http://ruby-doc.org/stdlib-2.0/libdoc/openssl/rdoc/OpenSSL/SSL/SSLSocket.html
<jhass> eh, I know about as much
ismaelga has joined #crystal-lang
<asterite> unshadow: how would you do it in Ruby?
<asterite> (also, maybe instead of set_options, set_cipher_list use options=, cipher_list=)
<jhass> asterite: you need to look at the context
<unshadow> In ruby its hidden :) , it's here
<unshadow> sslContext = OpenSSL::SSL::SSLContext.new
<unshadow> sslContext.ciphers =
<unshadow> sslContext.options
<unshadow> sslContext.options =
<asterite> Well, we can use those names too :-)
<asterite> We'll probably want to move options to a public enum, but I can do that later
<unshadow> In Ruby its here : OpenSSL::SSL::OP_NO_SSLv3
<unshadow> In Ruby its here : OpenSSL::SSL::OP_NO_SSLv2
<unshadow> Oh, I forgat to add OpenSSL::SSL::OP_NO_COMPRESSION, its important to avoid the Crime TLS Vunrabilty
datanoise has joined #crystal-lang
<unshadow> I played around allot with the OpenSSL options in Ruby when I built my SSL Scanner: https://github.com/bararchy/ruby-SSLscanner/blob/master/sslscanner.rb
ponga has quit [Remote host closed the connection]
datanoise has quit [Ping timeout: 265 seconds]
<jhass> we should start calling all these things TLS
<jhass> mh, we should make Crystal's SSLSocket DANE aware
<unshadow> TBH you are right, Using SSLv3 or SSLv2 is insecure, SSLv2 is long dead, and SSLv3 has POODLE for CBC based ciphers, and BMA for RC4 based ciphers
<asterite> Department of Advanced Nursing Education?
<unshadow> DNS-based Authentication of Named Entities
<asterite> Oh
<unshadow> Basic need for DNS-SEC
<jhass> I think there are OpenSSL callbacks to hook into validation, the hard part would be getting authenticated DNS replies
<jhass> uh, no DNSSEC doesn't depend on DANE, it's the other way around ;)
<jhass> DANE replaces the CA system with DNSSEC
<unshadow> True, my bad
<unshadow> the sec I get SSLSocket to act nicly in server mode, I can start writing my reverse proxy in crystal, I also want to try and re-write my ssl scanner in crystal, could be a cool project
ponga has joined #crystal-lang
<asterite> unshadow: you can always monkey-patch the standard library until we merge your pull request :-)
<unshadow> no worries, TBH becuase my lack of C style expireance I would really like to give as much people the time to review and edit the changes, so I dont mind if it would take some time.
kulelu88 has joined #crystal-lang
JBat has quit [Quit: Computer has gone to sleep.]
asterite has quit [Quit: Page closed]
ponga has quit [Remote host closed the connection]
<unshadow> btw, a little something I just finished, this is for Security Audits of WPA passwords: https://github.com/bararchy/phone-generator
<unshadow> as a request by a few people who wanted a binery who can do that
<jhass> typo, "languge" ;)
<unshadow> what typo ?? (fixed hahha)
ismaelga has quit [Remote host closed the connection]
<unshadow> btw, why dont we have String.chomp! ?
<jhass> because String is immutable
<unshadow> under what reason ?
<jhass> I guess so that literals don't have to be copied or so, dunno, gotta wait for asterite to answer that ;)
<jhass> it also makes literal to literal comparison as fast as symbol comparison I guess
<unshadow> dosn't String.chomp! is better performance wise then String = String.chomp ?
<jhass> it's always tradeoffs, some things get faster, some things get slower
<jhass> you decide which you deem more important
<unshadow> gsub will hurt :(
<unshadow> See you later guys, going back home (It's fun to have my company pay for additions in Crystal haha)
unshadow has quit [Quit: leaving]
unshadow has joined #crystal-lang
unshadow has quit [Client Quit]
ponga has joined #crystal-lang
datanoise has joined #crystal-lang
ismaelga has joined #crystal-lang
unshadow has joined #crystal-lang
sandelius has quit [Quit: Textual IRC Client: www.textualapp.com]
ponga has quit [Remote host closed the connection]
JBat has joined #crystal-lang
<crystal-gh> [crystal] Exilor opened pull request #670: Added String#succ (master...master) http://git.io/vTC8x
jtarchie has quit [Quit: Connection closed for inactivity]
bcardiff has joined #crystal-lang
<unshadow> I wish we had RubyMine support ...or ... CrystalMine haha
<jhass> I think there's a ctags plugin or two
<unshadow> I use Sublime with the Sublime-Crystal package
<jhass> same
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
shama has joined #crystal-lang
kulelu88 has quit [Ping timeout: 244 seconds]
willlll has joined #crystal-lang
kulelu88 has joined #crystal-lang
havenwood has joined #crystal-lang
willlll has quit [Quit: willlll]
<unshadow> do we have attr_accessor ?
<vikaton> unshadow: I think its just "getter"
<vikaton> if ur talking about Class variables u want to access
<unshadow> attr_getter ? or just getter :bal, :bla2 etc.. ?
<vikaton> correct me if im wrong tho
<vikaton> just getter
<unshadow> ok, thanks
<jhass> unshadow: getter, getter!, getter?, setter, property, property!, property?
<unshadow> property is like for both read and write ?
<bcardiff> unshadow: yes
<unshadow> thanks
leafybasil has quit [Ping timeout: 255 seconds]
<bcardiff> getter! and propety! call not_nil! before returning the value. Using plain getter/setter/property versions may be enough.
<vikaton> :O
<vikaton> bcardiff spoke !
sandelius has joined #crystal-lang
sandelius has quit [Client Quit]
<bcardiff> jeje. :-)
<vikaton> does Crystal have templates like Nim?
<vikaton> like, template `%`(x, y): expr = x mod y
<bcardiff> it has macros
<bcardiff> I need to run for a little while. but yes.
bcardiff has quit [Quit: Leaving.]
strcmp1 has quit [Quit: Leaving]
<BlaXpirit> i don't know any language that has templates/macros like nim
shama has quit [Ping timeout: 256 seconds]
strcmp1 has joined #crystal-lang
shama has joined #crystal-lang
bcardiff has joined #crystal-lang
leafybasil has joined #crystal-lang
tkrajcar has joined #crystal-lang
leafybasil has quit [Ping timeout: 246 seconds]
ismaelga has quit [Remote host closed the connection]
ismaelga has joined #crystal-lang
ismaelga has quit [Remote host closed the connection]
ismaelga has joined #crystal-lang
sandelius has joined #crystal-lang
willlll has joined #crystal-lang
questioner1337 has joined #crystal-lang
<questioner1337> hello
<questioner1337> anyone here ?
kulelu88 is now known as kulelu88_awaaaay
kulelu88_awaaaay has quit [Read error: Connection reset by peer]
<questioner1337> i have a question.. how come the compiler is written in crystal-lang .. where is the compiler that compiles the compiler ?
<jhass> questioner1337: where's the compiler that compiles gcc?
<questioner1337> the first c compiler could be written in assembly
<questioner1337> but i dont think crystal-lang is written in assembly :)
<jhass> the first crystal compiler was written in ruby
<questioner1337> ruby..
<questioner1337> damn
<questioner1337> i hoped it was c..
<strcmp1> i think it was ruby and ruby-llvm(https://github.com/ruby-llvm/ruby-llvm)
JBat has quit [Ping timeout: 240 seconds]
<crystal-gh> [crystal] tkrajcar opened pull request #671: Docs: minor typo fixes. (gh-pages...docs-typo-fixes) http://git.io/vTlgK
<tkrajcar> \o/
<jhass> questioner1337: why?
<questioner1337> jhass: wanted to find vulnerabilities :P
<jhass> oO
<jhass> well, the current compiler is written in crystal, so whether the old one contained any would be irrelevant
<jhass> because nobody uses it anymore
<jhass> questioner1337: what kind of vulnerabilities would you expect in a compiler? And why would they only appear in one written in C?
<questioner1337> jhass: memory corruption based vulnerabilities
<questioner1337> like buffer overflows, iat, fsa
<questioner1337> etc etc
<jhass> soo?
<jhass> I can perfectly fine corrupt memory in Crystal
<questioner1337> how can u find bof in a scripting language
<jhass> iirc I've actually seen some crazy JS stuff in that regard
<jhass> but Crystal isn't a scripting language (under the general definition of such)
<jhass> >> x = "foo"; x.to_unsafe
<DeBot> jhass: # => Pointer(UInt8)@0x8052FE4 - http://carc.in/#/r/8b
<jhass> >> x = "foo"; x.to_unsafe[1]
<DeBot> jhass: # => 111 - http://carc.in/#/r/8c
<jhass> >> x = "foo"; x.to_unsafe[20]
<DeBot> jhass: # => 1 - http://carc.in/#/r/8d
kulelu88_awaaaay has joined #crystal-lang
<jhass> >> x = "foo"; x.to_unsafe[20] = 532
<DeBot> jhass: Error in line 4: no overload matches 'Pointer(UInt8)#[]=' with types Int32, Int32 - http://carc.in/#/r/8e
<jhass> >> x = "foo"; x.to_unsafe[20] = 532u8
<DeBot> jhass: Syntax error in eval:4: 532 doesn't fit in an UInt8 - http://carc.in/#/r/8f
<jhass> >> x = "foo"; x.to_unsafe[20] = 8u8
<DeBot> jhass: Failed to run your code, sorry! - http://carc.in/#/r/8g
<jhass> and there we have a segfault
<jhass> easy as that
waterlink has joined #crystal-lang
kulelu88_awaaaay is now known as kulelu88
kulelu88 has quit [Quit: Leaving]
kulelu88 has joined #crystal-lang
DerisiveLogic has joined #crystal-lang
waterlink has quit [Ping timeout: 244 seconds]
boghison has joined #crystal-lang
<questioner1337> jhass: nice
<boghison> Hi! I just found out about Crystal and I'm very interested in being able to do C bindings. I have one question though: is it possible to link to static libraires with @[Link]?
<questioner1337> jhass: how do you use sizeof in crystal-lang ?
<jhass> boghison: yes, that's just passed to -l
<jhass> (of cc or ld, I don't remember, I think cc)
waterlink has joined #crystal-lang
<jhass> >> sizeof(LibC::TimeVal)
<DeBot> jhass: # => 8 - http://carc.in/#/r/8i
<questioner1337> jhass: whats the size of 'x' when initialized ?
<boghison> jhass: so, I just do the same thing for both static and dynamic then, right?
<jhass> boghison: I think so
<boghison> Thanks!!
<questioner1337> http://carc.in/#/r/8j
<jhass> questioner1337: looks like you can only sizeof constants
<questioner1337> yeah
<questioner1337> jhass: whats the size of 'x' when initialized ?
<jhass> >> "foo".bytesize
<DeBot> jhass: # => 3 - http://carc.in/#/r/8l
boghison has quit [Quit: Konversation terminated!]
<questioner1337> jhass: thats the size of the variable ?
<questioner1337> i mean
<questioner1337> thats a string lol
<questioner1337> well yeah
<questioner1337> http://carc.in/#/r/8n
havenwood has quit []
<jhass> a variable should be represented as a pointer I think
<questioner1337> http://carc.in/#/r/8o
<questioner1337> dynamic allocation
<vikaton> rust can fix that !
<vikaton> !
<jhass> no, rust does have unsafe parts too
<vikaton> it was a hoke
<vikaton> joke*
<vikaton> Rust's mem management is a PITA
jtarchie has joined #crystal-lang
BlaXpirit has quit [Remote host closed the connection]
BlaXpirit has joined #crystal-lang
<jhass> questioner1337: yes, you can call unsafe C functions
<questioner1337> jhass: yeah, but how come only '0' is printed out
<questioner1337> in crystal
<jhass> I'm not sure about what printf does there, but I assume it's whatever happens to be on the stack?
<questioner1337> jhass: yep
<questioner1337> jhass: cant belive that theres nothing
<jhass> questioner1337: http://carc.in/#/r/95
<questioner1337> well :P
<questioner1337> jhass: are you one of the project's contributors ?
bcardiff has quit [Quit: Leaving.]
<jhass> mh, I contributed an stdlib function or two, yet have to touch parser or codegen
willlll has quit [Quit: willlll]
sandelius has quit [Quit: Textual IRC Client: www.textualapp.com]
willlll has joined #crystal-lang
bcardiff has joined #crystal-lang
bcardiff1 has joined #crystal-lang
bcardiff has quit [Read error: Connection reset by peer]
ismaelga has quit [Remote host closed the connection]
questioner1337 has quit [Quit: Page closed]
<strcmp1> jhass, dont forget 2056.cr :p
<jhass> well, yeah
<vikaton> 2056 o.o?
<jhass> typo, they meant 2048.cr
bcardiff has joined #crystal-lang
bcardiff1 has quit [Read error: Connection reset by peer]
<vikaton> ah 0k
bcardiff has quit [Quit: Leaving.]
bcardiff has joined #crystal-lang
bcardiff1 has joined #crystal-lang
bcardiff has quit [Read error: Connection reset by peer]
leafybasil has joined #crystal-lang
BlaXpirit has quit [Quit: Quit Konversation]
datanoise has quit [Ping timeout: 255 seconds]
bcardiff1 has quit [Quit: Leaving.]
bcardiff has joined #crystal-lang
havenwood has joined #crystal-lang
ismaelga has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
bcardiff has joined #crystal-lang
datanoise has joined #crystal-lang
bcardiff has quit [Ping timeout: 255 seconds]