-- Story.base.positive_ranked.joins(:taggings).where(taggings: { tag_id: tags.map(&:id) }) | |
EXPLAIN SELECT `stories`.* | |
FROM `stories` | |
INNER JOIN `taggings` | |
ON `taggings`.`story_id` = `stories`.`id` | |
WHERE `stories`.`merged_story_id` IS NULL | |
AND `stories`.`is_expired` = false | |
AND ( ( Cast(upvotes AS signed) - Cast(downvotes AS signed) ) >= 0 ) | |
AND `taggings`.`tag_id` = 159; |
import { FluentBundle } from 'fluent/compat'; | |
import { negotiateLanguages } from 'fluent-langneg/compat'; | |
const MESSAGES_ALL = { | |
'pl': ` | |
title = Witaj świecie! | |
today-is = Dziś jest { DATETIME($date, month: "long", day: "numeric") }. | |
`, | |
'en-US': ` | |
title = Hello, world! |
javacript:void((() => { | |
const topLevelComments = [...document.querySelectorAll('ol.comments > li > div')].slice(1), | |
hide = (node) => { node.closest('li').style.display = 'none' }, | |
show = (node) => { node.closest('li').style.display = null }, | |
reset = () => { topLevelComments.forEach(show) }; | |
window.query = (query) => { | |
// Convenient for using it as an event handler | |
if (query && query.target) { query = query.target.value } |
javascript:void( | |
(function() { | |
this.distanceFromTop = (a, b) => { | |
return Math.sign(a.getBoundingClientRect().top - b.getBoundingClientRect().top); | |
}; | |
this.setUnreadElements = () => { | |
document.unreadElements = [...document.querySelectorAll('[class*=unread]')].sort(this.distanceFromTop); | |
}; |
# $ gem install benchmark-ips | |
require 'benchmark/ips' | |
Benchmark.ips do |x| | |
x.report("long correct string: ") { "abfhbeufangi" == "abfhbeufangi" } | |
x.report("long mostly correct string: ") { "abfhbeufangx" == "abfhbeufangi" } | |
x.report("long incorrect string: ") { "bbfhbeufangi" == "abfhbeufangi" } | |
x.report("too short: ") { "bbfhbe" == "abfhbeufangi" } | |
x.report("too long: ") { "abfhbeufangibbfhbe" == "abfhbeufangi" } |
Lovingly harvested from the creative minds at these gems:
- https://raw.githubusercontent.com/tjackiw/obscenity/master/config/blacklist.yml
- https://raw.githubusercontent.com/chrisvfritz/language_filter/ea6677d35768f1729effe51bf159962617aed259/config/matchlists/mccormick.txt
- https://raw.githubusercontent.com/hairyhum/bad-words.ruby/5f135277c0a7c42467c24526da2501d1968a9ce6/lib/conf/library.yaml
/ be me
/ be working on new Rails API web app
/ ...I can't. I hate this format
...so I was looking up how to do simple, secure authentication in Rails for my super secret project which you definitely can't find by looking at recent activity on my [GitHub account] (Hail [Mammon][[0][zero]]) and realized that I hadn't implemented authentication in Rails in a long time. The closest I'd come to was throwing [Devise] into my app and grumpily remembering to configure the mailer after the fact.
This will seem unrelated, but bear with me: I learned how to calculate interest rates on loans in something like 6th grade. I have since forgotten how to do that without assistance. Much like how I would have been much better prepared to choose a mortgage back then, I would in some ways be much better prepared to figure out authentication a few years ago when I was just starting out in web dev - and had just implemented it from the [Hartl tutorial]. That said, just like how I now know more of what I'm looking for
Well! I'm officially pretty happy with the fruits of my labor. It's not the prettiest, aesthetically or in terms of code quality, but hey, it does exactly what I want it to. Now I can use GitHub Gists as the backend to my blog - at least until I hit [3000 gists]. I count that among problems I probably won't have to deal with, including:
- Getting slashdotted / hackernewsed
- GitHub changing their access model for public gists
- GitHub rate limiting me
- Having more blog posts than I know what to do with
- Having more viewers or subscribers than I know what to do with
I'll deal with those problems as they come. In the meantime, a quick rundown of what changed since the last post:
Well, I didn't know this was going to be as hard as it turned out to be, but sometime yesterday I decided that I didn't really want to manage a backend and GitHub Gists were where my technical thoughts ended up, anyway (and I didn't want to handle embeds, either) so why not just hit up Gists for my tech blog? That way, I'd get syntax highlighted embeds, comments, version management, and more.
As with a lot of technical things, it was much more difficult than I gave it credit for at first, mostly because of embeds and the CORS policy on GitHub Gists.
The first step was to get my GitHub Pages running locally, which I did with this convenient python3 one-liner: python -m http.server 8000
. Loading up http://localhost:8000/
gave me a look at my static files. I set up a barebones html file with some script tags for the majority of the logic.
I knew I could access the GitHub Gists through some sort of [API], but I wasn't sure what I got with it. Shouldn't be a problem, right? Sure enough, it was as easy as hi