While this is a pretty cool showcase of what you can do with Elixir’s macro system… this is also an example of why we shouldn’t overuse macros!
I feel like a lot of people like trying to tack on features/paradigms from languages into other languages like this, and while that’s neat… it – by definition – isn’t idiomatic and won’t be something that can easily be grokked unless, in this case, you’re also an expert at “witchcraft”.
This is so interesting. It looks like something I’d like to build at some point, if only to recreate that rather relaxing devil-may-care attitude towards time and punctuality (generally speaking) that’s seen in some undeveloped countries. What’s that you say? I’m 10 minutes late? …so?
You are allowed to be relaxed about time and punctuality! It is not a sign of being undeveloped¹! It’s just a reflection of what you currently value (which is also formed by context and people around you)! Probably you are already relaxed about time in some situations, and stressed about it in others!
¹What does ‘undeveloped’ even mean? There are many things it can mean. It’s one of those words you should really only use as a shorthand in a long-running communcation, when you’ve already reached consensus on what it means here.
You are allowed to be relaxed about time and punctuality! It is not a sign of being undeveloped¹!
It’s probably just me, but I don’t look at being “underdeveloped” (my definition, anyway :/) as a bad thing!
It’s just a reflection of what you currently value (which is also formed by context and people around you)!
Possibly, but (again, generally speaking) it’s not easy to be very relaxed on time in the UK/US, in my experience (but looking at jtm’s comment, this is apparently not the case everywhere). The meetup is at 1440, sir. 1400 is 1400, not 1445!
What does ‘undeveloped’ even mean?
Yeah, I should have been more specific :/ By “undeveloped” I don’t mean “poor” or “third-world”, I mean more rural-type areas where the majority of the population is engaged in blue-collar work.
interesting. It looks like something I’d like to build at some point, if only to recreate that rather relaxing devil-may-care attitude towards time and punctuality (generally speaking) that’s seen in some undeveloped countries. What’s that you say? I’m 10
I’m not at all opposed to this, but at the same time I feel like parties who are often 10 minutes late come across as caring very little about wasting the time of other people.
I suppose the natural solution to this is to adjust one’s expectations for party’s who are oftentimes late… but I suppose my own concern for potentially wasting their time holds me back from doing so.
I feel like parties who are often 10 minutes late come across as caring very little about wasting the time of other people.
I think this feeling is largely cultural. In Brazil, punctuality feels much less important compared to the US or UK. In fact, there’s a phrase “horário britânico”, which means “British time”, used to describe something punctual.
I think one can be relaxed about timescales and timetables while still being punctual when an event is scheduled for a specific time, IMHO.
I’ll be finishing a blog post I’ve been writing forever about fully leveraging Ecto’s compositional query building DSL in Elixir projects as well as, hopefully, starting preliminary work outlining a blog post about using Nix to unify your CI environment with your development environment!
More likely: I’ll just procrastinate again this week :-)
I’m interested in your blog post. I’ll be looking for it on here. I really like Ecto. As a person who learned regular SQL before using an ORM, ecto is the first where I use it instead of just going back to regular SQL. But “fully leveraging” ecto is not something I do, but would like to.
Oh that’s awesome :-) I’m extremely new to blog writing so I’ve never actually posted anything here or on the orange site but maybe I will!
I’ll let you know when it’s out if you’d like, as well.
Ecto’s composability is what really sells it for me, I’ve seen a lot of very tradition ORM-esque use, but seldom do I see the more powerful features used (not even things like dynamic queries, using named bindings to make composability a little easier, subqueries etc)
What makes you stick to Ecto over other ORMs?
I think BeOS was probably the only system to get this right. The problem with UNIX is that the APIs pretend that a file is a thing with a name and higher-level abstractions reinforce this. The term ‘directory’ is far more accurate than ‘folder’ on these systems: it’s a mapping from names to identities, not a containment hierarchy. You see this in exciting ways in modern *NIX systems. For example, with Linux you can set up inotify to tell you if any file in a directory is modified, then you can modify a file in that directory via a different hard link and not receive a notification.
In BeOS, a folder was just the result of a saved search. The user abstraction was that you had a sea of files with metadata and you could construct views on this. For example, you could order your music in directories of {artist}/{album} or {genre}/{decade}, of anything else. This made it easy to track in the filesystem all of the possible ways in which a user could find a file.
That’s really interesting actually.
I wonder how feasible it’d be to build a utility which mimics this: i.e. perform some search using find
or rg
, and for each file automatically create links in $HOME/.views/$VIEW_NAME
.
In every day usage it’d work a little something like:
mkview my_scripts $HOME/git/custom_scripts/**/*.sh
cv my_scripts
ls # shows all .sh files returned by the pattern passed into mkview
I guess there isn’t so much you can do re: automatically keeping views up to date. I still wonder if a utility similar to this exists, I’d definitely use it.
The author of BFS went to work at Apple and the metadata stream that the XNU kernel emits is designed for this. It provides a fire-hose stream of events to userspace telling it what directories have had contents modified so that they can then go and inspect file modification times and re-parse things. Spotlight uses this and you can create saved searches with it. The event thing is designed so that userspace can’t block the kernel: it’s a ring buffer and if you don’t consume it fast enough then you miss events, but they have an event counter and so you can tell that you’ve missed them. You can then do a background scan and catch up by looking for every file with a modification time after you were behind. If there are a load of file updates, Spotlight will get behind for a bit but will eventually catch up when the system is more idle.
I don’t know of any open source *NIX system with an equivalent system (inotify on Linux is closest, but not quite the right shape). We’ve discussed using the hooks in FreeBSD that were added for the audit system to build such a thing, but never got around to writing it.
For archival purposes, git-annex can be used as a symlink farm, so that the different directories in a single git-annex repository constitute many multiple views onto a single data store. It is not at all as ergonomic as the BeOS demos that I’ve seen, though.
I think the solution in Elixir is pretty clean and readable. Being able to pattern match on binaries is really neat:
defmodule Solution do
@input "aaaabbbcca"
def run(input \\ @input, acc \\ [])
def run("", acc) do
Enum.reverse(acc)
end
def run(<<char::bytes-size(1)>> <> remainder, [{char, n} | rest] = _acc) do
run(remainder, [{char, n + 1} | rest])
end
def run(<<char::bytes-size(1)>> <> remainder, acc) do
run(remainder, [{char, 1} | acc])
end
end
iex(1)> Solution.run
[{"a", 4}, {"b", 3}, {"c", 2}, {"a", 1}]
I literally just threw this together, theres probably a much better way to do it
BTW I’ve added Ruby-like blocks to Oil, which I think can be used to replace YAML in many circumstances. Shell is a natural place to put configuration because shell starts processes.
I didn’t document it fully but there’s a snippet here:
https://www.oilshell.org/release/0.8.1/doc/oil-proc-func-block.html#configuration-files
It looks a lot like HCL. Just like you have a block like
cd / {
echo $PWD
ls
}
in Oil, you can also have
server foo {
port = 80
root = '/'
section bar {
...
}
}
It still needs a user-facing API and I’m looking for help/feedback on that!
Erlang gives you well-named functions in the
timer
module which return milliseconds, which I prefer over adding units to names unless absolute necessary.I usually do this in Elixir for managing Ecto timeouts, etc:
Because all these functions return the number of milliseconds as an integer, you can do basic math with these too unlike in Go:
Apple use seconds as a
Double
instead of milliseconds as anInt
, so you can easily specify milliseconds as necessary while having slightly more friendly seconds for larger values.And lose the linearity of the scale precision and buy into a whole class (pun intended) of billion dollar problems from using floating points.
A Double has more precision than a millisecond while also stretching to centuries. :)
An IEEE double cannot represent “1/1000”.
Can the timers in your system do that?
Yes. They use integers. Don’t yours?
I was thinking of the fact that the underlying quartz isn’t tuned to milliseconds, but rather to some unit which made sense to the hardware constructor, so there will be aliasing.
This is valid Go:
(3 * time.Hour) + (30 * time.Minute)