Posts Tagged ‘crystal lang’
Practical coding questions answered by GPT3: is it ready for the prime time?
You can easily try GPT3 for yourself, simply register for an OpenAI account, and you will get (at the time of writing this) 18 USD of credit. Head on over to the following link: https://platform.openai.com/playground Here you can enter your question, and submit it. GPT3 will answer in the same text box. There are three…
WeiterlesenDealing with NIL in JSON::Any in Crystal Lang
One of the challenges when developing with Crystal is that it is not as forgiving about data types as, say, Python or Ruby. nil will keep you occupied. The following error message: cast from Nil to String failed, at /usr/share/crystal/src/json/any.cr:220:5:220 can be solved by: # cast to string, THEN check if it is nil if…
WeiterlesenHow to use catch all routes with Kemal
For a Vue.js single page application – at least on a SUB URL of our page – we want a catch all on our server, which will always render the same template / HTML output to the browser. Kemal is internally based on Radix for routing: https://github.com/luislavena/radix Radix has a Catch All / Glob character:…
Weiterlesenmongo_orm Exception: missing bson key: publish_acl (Exception)
When you extend your field definitions in the mongo_orm document classes, specifically with embedded documents, you might run into the following runtime (!) error: Exception: missing bson key: <name> (Exception) This is not an error in your code – your code is raising, because the database structure is not as it expects it to be!…
Weiterlesenmongo_orm custom name for collection
mongo_orm will automatically determine the name for your collection by using the Module and Class name, and appending an “s”. In cases where you want to name your collection, you can simply do this: class PapiTest < Mongo::ORM::Document collection_name “Buster” field test : String end get “/” do pt = PapiTest.new pt.test = “I want…
WeiterlesenThe scope of ecr within crystal: or how do I pass in variables and Objects into ECR templates?
As a beginner in the Crystal language I still struggle to get my head around some of the concepts in it, and develop a feel for coding in Crystal. When I come across difficult problems, which I solve or start to understand, I blog about them, so others can benefit – as lack of documentation…
WeiterlesenException: Unexpected quote at 1:2 (CSV::MalformedCSVError) Crystal
While trying to parse an Amazon pay file, I stumbled across this particular problem: Exception: Unexpected quote at 1:2 (CSV::MalformedCSVError) The reason: Amazon Pay encodes it’s files in UTF-8 with BOM. The BOM is an optional (in UTF-8 files) marker. You can see it with the tool xxd for instance xxd apolish_amazon_2018DecMonthlyTransaction.csv | less The…
Weiterlesen