Post ATWOLOQd1v2eYTYQjo by carlmjohnson@mastodon.social
(DIR) More posts by carlmjohnson@mastodon.social
(DIR) Post #ATW4HVt7M6sjRskiZ6 by simon@fedi.simonwillison.net
2023-03-11T19:50:16Z
0 likes, 0 repeats
A neat thing about having a copy of my blog's database in Datasette is I can use SQL queries to generate content - here's a query I used just now to build a Markdown list of all of my entries tagged gpt3, openai, generativeai or chatgpthttps://datasette.simonwillison.net/simonwillisonblog?sql=with+stuff+as+(%0D%0A++select%0D%0A++++title%2C%0D%0A++++%27https%3A%2F%2Fsimonwillison.net%2F%27+||+strftime(%27%25Y%2F%27%2C+created)+||+case%0D%0A++++++strftime(%27%25m%27%2C+created)%0D%0A++++++when+%2701%27+then+%27Jan%27%0D%0A++++++when+%2702%27+then+%27Feb%27%0D%0A++++++when+%2703%27+then+%27Mar%27%0D%0A++++++when+%2704%27+then+%27Apr%27%0D%0A++++++when+%2705%27+then+%27May%27%0D%0A++++++when+%2706%27+then+%27Jun%27%0D%0A++++++when+%2707%27+then+%27Jul%27%0D%0A++++++when+%2708%27+then+%27Aug%27%0D%0A++++++when+%2709%27+then+%27Sep%27%0D%0A++++++when+%2710%27+then+%27Oct%27%0D%0A++++++when+%2711%27+then+%27Nov%27%0D%0A++++++when+%2712%27+then+%27Dec%27%0D%0A++++end+||+%27%2F%27+||+cast(strftime(%27%25d%27%2C+created)+as+integer)+||+%27%2F%27+||+slug+||+%27%2F%27+AS+url%2C%0D%0A++++cast(strftime(%27%25d%27%2C+created)+as+integer)+||+%27+%27+||+case%0D%0A++++++strftime(%27%25m%27%2C+created)%0D%0A++++++when+%2701%27+then+%27Jan%27%0D%0A++++++when+%2702%27+then+%27Feb%27%0D%0A++++++when+%2703%27+then+%27Mar%27%0D%0A++++++when+%2704%27+then+%27Apr%27%0D%0A++++++when+%2705%27+then+%27May%27%0D%0A++++++when+%2706%27+then+%27Jun%27%0D%0A++++++when+%2707%27+then+%27Jul%27%0D%0A++++++when+%2708%27+then+%27Aug%27%0D%0A++++++when+%2709%27+then+%27Sep%27%0D%0A++++++when+%2710%27+then+%27Oct%27%0D%0A++++++when+%2711%27+then+%27Nov%27%0D%0A++++++when+%2712%27+then+%27Dec%27%0D%0A++++end+||+%27+%27+||+strftime(%27%25Y%27%2C+created)+as+date%0D%0A++from%0D%0A++++blog_entry%0D%0A++where%0D%0A++++id+in+(%0D%0A++++++select%0D%0A++++++++entry_id%0D%0A++++++from%0D%0A++++++++blog_entry_tags%0D%0A++++++where%0D%0A++++++++tag_id+in+(%0D%0A++++++++++select+id+from+blog_tag+where+tag+in+(%27gpt3%27%2C+%27openai%27%2C+%27generativeai%27%2C+%27chatgpt%27)%0D%0A++++++++)%0D%0A++++)%0D%0A++order+by%0D%0A++++created%0D%0A)%0D%0Aselect%0D%0A++%27-+[%27+||+title+||+%27](%27+||+url+||+%27)%27+||+%27+-+%27+||+date%0D%0Afrom%0D%0A++stuff
(DIR) Post #ATWDKZs9tfLaGLq8Zs by simon@fedi.simonwillison.net
2023-03-11T21:29:39Z
0 likes, 0 repeats
I used ChatGPT to generate that big case statement for returning the three letter month name based on two digits
(DIR) Post #ATWDgEB1F3pJLSz9I8 by fuzzychef@m6n.io
2023-03-11T21:35:42Z
0 likes, 0 repeats
@simon I knew it wouldn't be long until this power was used for evil.
(DIR) Post #ATWJIDY2WkjEAcgg2C by SamJSharpe@mastodon.social
2023-03-11T22:38:41Z
0 likes, 0 repeats
@simon funnily enough I needed to do something similar a month or so ago and I found this pretty nifty way of doing it. I dunno if that is faster or slower than a case statement, but it was fewer lines of SQL to read 🤣https://stackoverflow.com/a/33116186
(DIR) Post #ATWKH5bOgTrJBvHeEK by simon@fedi.simonwillison.net
2023-03-11T22:49:41Z
0 likes, 0 repeats
@SamJSharpe That's a really cool trick, thanks!
(DIR) Post #ATWLDf7Ao7km7x4nMu by SamJSharpe@mastodon.social
2023-03-11T23:00:12Z
0 likes, 0 repeats
@simon yeah I wouldn't normally bother code-golfing an LLM, but in this case you just happened on something I happened to also need to do recently 🤣 If I had written it from scratch, I would definitely have made the case statement but I was surprised that sqlite didn't have a format string for the shortened month name like MMM or similar like other languages have so I went searching for that. I mostly deal in Spark SQL and Hive SQL and they both can give the month abbreviation.
(DIR) Post #ATWN4WMIC21MGxuv4q by simon@fedi.simonwillison.net
2023-03-11T23:21:04Z
0 likes, 0 repeats
@SamJSharpe This is fun: I managed to get ChatGPT to produce the same result with a bit of careful prompting
(DIR) Post #ATWNdX7TM78WlggEt6 by SamJSharpe@mastodon.social
2023-03-11T23:27:36Z
0 likes, 0 repeats
@simon do you think it was trained on SO answers?
(DIR) Post #ATWOLOQd1v2eYTYQjo by carlmjohnson@mastodon.social
2023-03-11T23:33:29Z
0 likes, 0 repeats
@simon I needed to write a function to turn an N-dimensional array into a 1-D array. I tried Googling, but I couldn’t find a short description of the algorithm. ChatGPT got it, although I wish it had given the asterisk about row major vs column major. It’s a better fuzzy search for common knowledge than Google.
(DIR) Post #ATWOvF1JUGexnho6PQ by simon@fedi.simonwillison.net
2023-03-11T23:41:34Z
0 likes, 0 repeats
@SamJSharpe Yeah https://arxiv.org/pdf/2302.13971.pdf says it was:> Stack Exchange [2%]. We include a dump ofStack Exchange, a website of high quality ques-tions and answers that covers a diverse set of do-mains, ranging from computer science to chemistry.We kept the data from the 28 largest websites, re-moved the HTML tags from text and sorted theanswers by score (from highest to lowest)