Live data from Hacker News

Poor man's IFTTT in 3 lines of code

blog.lagentz.com

11–20 of 36 posts

Re: Poor man's IFTTT in 3 lines of code

#11
post #10

Regarding the watermark generation process, although the bash script works, I immediately reach for my old friend (GNU) make(1) for that kind of task. Here's the Makefile: all: watermark done:=$(wildcard *-BD.pdf) src:=$(filter-out $(done),$(wildcard *.pdf)) marked:=$(patsubst %.pdf,%-BD.pdf,$(src)) watermark: $(marked) %-BD.pdf: %.pdf ./watermark_script.sh $ The done + filter-out mumbo jumbo is there just because wi…

I'm sorry if I missed this, but why would you use make instead of bash?

Re: Poor man's IFTTT in 3 lines of code

#12
post #11
post #10

Regarding the watermark generation process, although the bash script works, I immediately reach for my old friend (GNU) make(1) for that kind of task. Here's the Makefile: all: watermark done:=$(wildcard *-BD.pdf) src:=$(filter-out $(done),$(wildcard *.pdf)) marked:=$(patsubst %.pdf,%-BD.pdf,$(src)) watermark: $(marked) %-BD.pdf: %.pdf ./watermark_script.sh $ The done + filter-out mumbo jumbo is there just because wi…

I'm sorry if I missed this, but why would you use make instead of bash?

    make figures out which files need updating
    make allows to write pattern rules (.c.o:, or %.o: %.c)
    you don't need to move files out of the 'inbox'
      to ignore them
    regenerating a file is a touch(1) away
    make is descriptive, not imperative (invaluable
      readability when you're coming back on it years later)
    should you ever need a second transformative step or
      a new dependency, it's trivial to insert, and make
      will figure stuff out
    make can trash intermediate results automatically
    make is crazy fast
    make variables are not environment variables
    make has multiple variable assignations, resulting in
      some early/late evaluation system (early with :=,
      late with =, $() is always late unless part of a :=)
    make outputs commands as they're executed (not with a global)
    make outputs nothing when commands are prefixed with @ (not with a global)
    make interrupts itself on a chain failure
    each make recipe line is executed in a distinct shell
You can set bash to do some of those things, or you can write bash code that do some of those, but most of the time you end up just coercing bash into behaving like make.

Of course I would not write everything in make. But knowing what make can do makes it the obvious choice for some tasks, and helps you coming up with a robust task/generator system in a snap, whereas coming up with a task/generator system in bash quickly is already not that easy, and making it robust even less.

Re: Poor man's IFTTT in 3 lines of code

#14
I wrote something similar the other day, but failed to realize that having a utility that locks until there are changes (vs one that calls a program when changes happen) is much easier to integrate with bash scripts.

Re: Poor man's IFTTT in 3 lines of code

#15
post #5
post #4

I found this a very intrusive site - I really dislike these animated slide in fade in distractions.

Not only the slide-in nonsense, but also the wiggling "Try Me!" arrow on the right. "You may also like" panels are becoming the Clippy of blogs and news sites.

Didn't see any of it with noscript on.

What's the "try me" pointing to? I tried clicking it and it did nothing, scrolling down it just points to blank right margin all the way ...?

I have no problem with "you may also like" and have found the links useful on occassion; anything animated without user interaction however is generally a turn off for me.

Re: Poor man's IFTTT in 3 lines of code

#17
post #5

Earlier quoted context omitted.

Not only the slide-in nonsense, but also the wiggling "Try Me!" arrow on the right. "You may also like" panels are becoming the Clippy of blogs and news sites.

Didn't see any of it with noscript on. What's the "try me" pointing to? I tried clicking it and it did nothing, scrolling down it just points to blank right margin all the way ...? I have no problem with "you may also like" and have found the links useful on occassion; anything animated without user interaction however is generally a turn off for me.

What's the "try me" pointing to?

Some kind of feedback tool about the site.

Re: Poor man's IFTTT in 3 lines of code

#19
The inotify script likely has a race condition; if the directory is modified while an update is running, it won't pick up the second modification, and will wait in a dirty state until it is modified again. If anyone wants a race-free solution, you should check out my NCD scripting language [1] which has an integrated command to receive directory change notifications (last example in Blockers section is a race-free solution to this problem).

[1] http://code.google.com/p/badvpn/wiki/NCD

Post reply on HN