How to detect number of CPU cores in Crystal?
How do you detect the number of CPU cores in crystal? In Go you can do runtime.NumCPU() and in Node.js you can do os.cpus(). Is there something similar in Crystal?
The last time I checked (admittedly that was long ago) there was no direct way to do that, but you can get access to this information through the command line. I ended up combining multiple of these answers for redundancy. THREADS = `getconf _NPROCESSORS_ONLN || nproc --all || grep -c '^processor' /proc/cpuinfo`.to_i
Condition over object's type
Crystal C bindings: argument const unsigned char **
Crystal C bindings: return type char*
Make Class member attribute of type Array(T) accept 2D arrays of T
JSON.mapping if “root” attribute has inherit keys
Crystal C bindings: using fopen
Define Class object validations
Set attribute of type “Class” to define it as Int32, String, Float64
Set both default attribute and type of attribute
How can I test private methods?
Write binary data to stdout in Crystal
Unable to compile after upgrade from crystal 0.19.4 to 0.20
Application server for Crystal web app / Kemal
Crystal Fiber error - “Unhandled exception in spawn: SSL_shutdown: Operation now in progress (Errno)”
Convert hex string to int in Crystal
Crystal convert string to hash from response.body