- Oct 2023
-
www.alexandria.unisg.ch www.alexandria.unisg.ch
-
Toillustrate this principle, an HTML page typically provides the user with a num-ber of affordances, such as to navigate to a different page by clicking a hyperlinkor to submit an order by filling out and submitting an HTML form. Performingany such action transitions the application to a new state, which provides theuser with a new set of affordances. In each state, the user’s browser retrievesan HTML representation of the current state from a server, but also a selec-tion of next possible states and the information required to construct the HTTPrequests to transition to those states. Retrieving all this information throughhypermedia allows the application to evolve without impacting the browser, andallows the browser to transition seamlessly across servers. The use of hyperme-dia and HATEOAS is central to reducing coupling among Web components, andallowed the Web to evolve into an open, world-wide, and long-lived system.In contrast to the above example, when using a non-hypermedia Web service(e.g., an implementation of CRUD operations over HTTP), developers have tohard-code into clients all the knowledge required to interact with the service.This approach is simple and intuitive for developers, but the trade-off is thatclients are then tightly coupled to the services they use (hence the need for APIversioning).
-
- Jul 2023
-
www.codewithjason.com www.codewithjason.com
-
The way to do this with Capybara is documented on StackOverflow but, unfortunately, the answer there is buried in a little too much noise. I decided to create my own tiny noise-free blog post that contains the answer. Here it is:
-
- Apr 2023
-
www.schoolofmotion.com www.schoolofmotion.com
-
(6-10+ minutes) engaging videos that appear to do well on YouTube
This number(6-10minutes) is appealing to most viewers as it is concise and delivers a information in short bursts. It is ideal for quick tutorials, news and entertainment.
-
- Sep 2022
-
pyimagesearch.com pyimagesearch.com
-
Now, the progression of NLP, as discussed, tells a story. We begin with tokens and then build representations of these tokens. We use these representations to find similarities between tokens and embed them in a high-dimensional space. The same embeddings are also passed into sequential models that can process sequential data. Those models are used to build context and, through an ingenious way, attend to parts of the input sentence that are useful to the output sentence in translation.
-
- Jun 2022
-
github.com github.com
-
A custom component might be interesting for you if your views look something like this: <%= simple_form_for @blog do |f| %> <div class="row"> <div class="span1 number"> 1 </div> <div class="span8"> <%= f.input :title %> </div> </div> <div class="row"> <div class="span1 number"> 2 </div> <div class="span8"> <%= f.input :body, as: :text %> </div> </div> <% end %> A cleaner method to create your views would be: <%= simple_form_for @blog, wrapper: :with_numbers do |f| %> <%= f.input :title, number: 1 %> <%= f.input :body, as: :text, number: 2 %> <% end %>
Tags
Annotators
URL
-
- Jan 2022
-
-
<script> import { fibonacci } from './math.js'; $: result = fibonacci(n, 0); </script> <input type=number bind:value={n}> <p>The {n}th Fibonacci number is {$result.data}</p> {#if $result.loading} <p>Show a spinner, add class or whatever you need.</p> <p>You are not limited to the syntax of an #await block. You are free to do whatever you want.</p> {/if}
-
Once you've written the imperative library/util code once, your components are super slim and completely reactive/declarative. Wow.
-
-
github.com github.com
-
I value this pattern because it allows concise concurrency.
-
- Oct 2021
-
-
Collapsing directories Say some directories in a project exist for organizational purposes only, and you prefer not to have them as namespaces. For example, the actions subdirectory in the next example is not meant to represent a namespace, it is there only to group all actions related to bookings: booking.rb -> Booking booking/actions/create.rb -> Booking::Create
Tags
Annotators
URL
-
- Aug 2021
-
stackoverflow.com stackoverflow.com
-
the tuple() function you need can be succinctly written as: export type Lit = string | number | boolean | undefined | null | void | {}; export const tuple = <T extends Lit[]>(...args: T) => args;
-
- Jun 2021
-
hypothes.is hypothes.is
-
Giving peers permission to engage in dialogue about race and holding a lofty expectation that they will stay engaged in these conversations throughout the semester or year is the first of the four agreements for courageous conversation. While initially, some participants may be eager to enter into these conversations, our experience indicates that the more personal and thus risky these topics get, the more difficult it is for participants to stay committed and engaged." Singleton and Hays
-
-
stackoverflow.com stackoverflow.com
-
But what's the matter with "raw" instance variables? They are internal to your instance; the only code that will call them by name is code inside pancake.rb which is all yours. The fact that they start with @, which I assume made you say "blech", is what makes them private. Think of @ as shorthand for private if you like.
I agree / like that:
@
is just shorthand forprivate
.But OP clarified in a comment that the
@
itself is not what they disliked: it was the accessing data directly instead of going through an accessor method.The raw variable is the implementation, the accessor is the interface. Should I ignore the interface because I'm internal to the instance?
-
-
-
TypeScript includes a concise way to create and assign a class instance property from a constructor parameter.
-
-
disqus.com disqus.com
-
I like auto-property generation... who needs boilerplate code?
-
-
stackoverflow.com stackoverflow.com
-
instance_eval { reduce(:+) / size.to_f }
-
Or if you're looking for a core extension that adds this to the Array class, I'd recommend the facets gem (require 'facets/array/average'). Then you can just do array.average. And, from looking at the source, it turns out they do the exact same thing as the instance_eval approach above. The only difference is that it's implemented as a method—which of course already has self pointing to itself—instead of a block): def average; return nil if empty?; reduce(:+) / length.to_f; end Main advantage of this is that it's even more concise/readable and it handles the empty? case.
-
- May 2021
-
github.com github.com
-
Are you also tired and fed up with the bulkiness of jQuery, but also don't want to have to type document.querySelector("div").appendChild(document.createTextNode("hello")); just to add some text to an element?
happy middle/medium?
-
µ
-
-
stackoverflow.com stackoverflow.com
-
Shorter: git fetch /path/to/project-a master; git merge --allow-unrelated-histories FETCH_HEAD.
-
- Apr 2021
-
github.com github.com
-
There are several built in classes you can add as formatters. You can use a symbol to reference built in formatters. logger.formatter.add(Hash, :pretty_print) # use the Formatter::PrettyPrintFormatter for all Hashes logger.formatter.add(Hash, Lumberjack::Formatter::PrettyPrintFormatter.new) # alternative using a formatter instance
Tags
Annotators
URL
-
-
unix.stackexchange.com unix.stackexchange.com
-
exec &> >(tee -a "$log_file")
-
-
expect.sourceforge.net expect.sourceforge.net
-
Bugs The man page is longer than the program.
I assume "the program" is referring to this file:
https://core.tcl-lang.org/expect/file?name=example/unbuffer&ci=trunk
, which compared to the source for man page, is in fact much smaller (about 1/2 the length).
-
-
www.plixer.com www.plixer.com
-
The TCP/IP model is a more concise framework, with only 4 layers:
Tags
Annotators
URL
-
-
stackoverflow.com stackoverflow.com
-
0</dev/null script --quiet --flush --return --command "$(printf "%q " "$@")" /dev/null
-
- Mar 2021
-
bugs.ruby-lang.org bugs.ruby-lang.org
-
reduce(root){@1[@2]||={}}
first sighting: Ruby 3's new @1 shorthand
Tags
Annotators
URL
-
-
www.jackfranklin.co.uk www.jackfranklin.co.uk
-
I like that Svelte doesn't make me use the subscribe API every time I need to read the value.
-
-
medium.com medium.com
-
Because it requires less code to do the same thing as other programming languages projects can be developed faster
-
-
stackoverflow.com stackoverflow.com
-
[...document.querySelectorAll("*")].filter(e => e.childNodes && [...e.childNodes].find(n => n.nodeValue?.match("❤")))
-
-
reedbarger.com reedbarger.com
-
Replacing map / filter with a single reduce
-
-
trailblazer.to trailblazer.to
-
The absence of a method name here is per design: this object does only one thing, and hence what it does is reflected in the class name.
-
- Feb 2021
-
trailblazer.to trailblazer.to
-
To understand this helper, you should understand that every step invocation calls Output() for you behind the scenes. The following DSL use is identical to the one [above]. class Execute < Trailblazer::Activity::Railway step :find_provider, Output(Trailblazer::Activity::Left, :failure) => Track(:failure), Output(Trailblazer::Activity::Right, :success) => Track(:success)
-
For branching out a separate path in an activity, use the Path() macro. It’s a convenient, simple way to declare alternative routes
Seems like this would be a very common need: once you switch to a custom failure track, you want it to stay on that track until the end!!!
The problem is that in a Railway, everything automatically has 2 outputs. But we really only need one (which is exactly what Path gives us). And you end up fighting the defaults when there are the automatic 2 outputs, because you have to remember to explicitly/verbosely redirect all of those outputs or they may end up going somewhere you don't want them to go.
The default behavior of everything going to the next defined step is not helpful for doing that, and in fact is quite frustrating because you don't want unrelated steps to accidentally end up on one of the tasks in your custom failure track.
And you can't use
fail
for custom-track steps becase that breaksmagnetic_to
for some reason.I was finding myself very in need of something like this, and was about to write my own DSL, but then I discovered this. I still think it needs a better DSL than this, but at least they provided a way to do this. Much needed.
For this example, I might write something like this:
step :decide_type, Output(Activity::Left, :credit_card) => Track(:with_credit_card) # Create the track, which would automatically create an implicit End with the same id. Track(:with_credit_card) do step :authorize step :charge end
I guess that's not much different than theirs. Main improvement is it avoids ugly need to specify end_id/end_task.
But that wouldn't actually be enough either in this example, because you would actually want to have a failure track there and a path doesn't have one ... so it sounds like Subprocess and a new self-contained ProcessCreditCard Railway would be the best solution for this particular example... Subprocess is the ultimate in flexibility and gives us all the flexibility we need)
But what if you had a path that you needed to direct to from 2 different tasks' outputs?
Example: I came up with this, but it takes a lot of effort to keep my custom path/track hidden/"isolated" and prevent other tasks from automatically/implicitly going into those steps:
class Example::ValidationErrorTrack < Trailblazer::Activity::Railway step :validate_model, Output(:failure) => Track(:validation_error) step :save, Output(:failure) => Track(:validation_error) # Can't use fail here or the magnetic_to won't work and Track(:validation_error) won't work step :log_validation_error, magnetic_to: :validation_error, Output(:success) => End(:validation_error), Output(:failure) => End(:validation_error) end
puts Trailblazer::Developer.render o Reloading... #<Start/:default> {Trailblazer::Activity::Right} => #<Trailblazer::Activity::TaskBuilder::Task user_proc=validate_model> #<Trailblazer::Activity::TaskBuilder::Task user_proc=validate_model> {Trailblazer::Activity::Left} => #<Trailblazer::Activity::TaskBuilder::Task user_proc=log_validation_error> {Trailblazer::Activity::Right} => #<Trailblazer::Activity::TaskBuilder::Task user_proc=save> #<Trailblazer::Activity::TaskBuilder::Task user_proc=save> {Trailblazer::Activity::Left} => #<Trailblazer::Activity::TaskBuilder::Task user_proc=log_validation_error> {Trailblazer::Activity::Right} => #<End/:success> #<Trailblazer::Activity::TaskBuilder::Task user_proc=log_validation_error> {Trailblazer::Activity::Left} => #<End/:validation_error> {Trailblazer::Activity::Right} => #<End/:validation_error> #<End/:success> #<End/:validation_error> #<End/:failure>
Now attempt to do it with Path... Does the Path() have an ID we can reference? Or maybe we just keep a reference to the object and use it directly in 2 different places?
class Example::ValidationErrorTrack::VPathHelper1 < Trailblazer::Activity::Railway validation_error_path = Path(end_id: "End.validation_error", end_task: End(:validation_error)) do step :log_validation_error end step :validate_model, Output(:failure) => validation_error_path step :save, Output(:failure) => validation_error_path end
o=Example::ValidationErrorTrack::VPathHelper1; puts Trailblazer::Developer.render o Reloading... #<Start/:default> {Trailblazer::Activity::Right} => #<Trailblazer::Activity::TaskBuilder::Task user_proc=validate_model> #<Trailblazer::Activity::TaskBuilder::Task user_proc=validate_model> {Trailblazer::Activity::Left} => #<Trailblazer::Activity::TaskBuilder::Task user_proc=log_validation_error> {Trailblazer::Activity::Right} => #<Trailblazer::Activity::TaskBuilder::Task user_proc=save> #<Trailblazer::Activity::TaskBuilder::Task user_proc=log_validation_error> {Trailblazer::Activity::Right} => #<End/:validation_error> #<Trailblazer::Activity::TaskBuilder::Task user_proc=save> {Trailblazer::Activity::Left} => #<Trailblazer::Activity::TaskBuilder::Task user_proc=log_validation_error> {Trailblazer::Activity::Right} => #<End/:success> #<End/:success> #<End/:validation_error> #<End/:failure>
It's just too bad that:
- there's not a Railway helper in case you want multiple outputs, though we could probably create one pretty easily using Path as our template
- we can't "inline" a separate Railway acitivity (Subprocess "nests" it rather than "inlines")
-
step :direct_debit
I don't think we would/should really want to make this the "success" (Right) path and :credit_card be the "failure" (Left) track.
Maybe it's okay to repurpose Left and Right for something other than failure/success ... but only if we can actually change the default semantic of those signals/outputs. Is that possible? Maybe there's a way to override or delete the default outputs?
-
Patching has no implicit, magical side-effects and is strongly encouraged to customize flows for a specific case in a quick and consise way.
-
This connects the failure output to the previous task, which might create an infinity loop and waste your computing time - it is solely here for demonstrational purposes.
Tags
- trailblazer-activity
- no magic
- example: in order to keep example concise/focused, may not implement all best practices (illustrates one thing only)
- I have a question about this
- automatic
- semantics
- concise
- flexibility
- extension API: patching
- demystified
- powerful
- feels wrong
- useful
- example: not how you would actually do it (does something wrong/bad/nonideal illustrating but we should overlook it because that's not the one thing the example is trying to illustrate/show us)
- tip
- side effects
- official preferred convention / way to do something
- equivalent code
- monkey patching
- being explicit
- verbose / noisy / too much boilerplate
- helper functions
Annotators
URL
-
-
github.com github.com
-
(match = html.match(/<meta name="csp-nonce" content="([^"]*)"/)) && match[1] html[/<meta name="csp-nonce" content="([^"]*)"/, 1]
Tags
Annotators
URL
-
-
trailblazer.to trailblazer.to
-
Yes, we could and should use Reform or Dry-validation here.
-
-
en.wikipedia.org en.wikipedia.org
-
With >>= available, add can now be redefined as something much more compact:
-
-
akm111.wordpress.com akm111.wordpress.com
-
while : # This is the same as "while true".
-
-
github.com github.com
-
you can do pairs.each_with_object({}) do |(multiparameter_name, value), attributes|
-
values_with_empty_parameters.each_value.all?(&:nil?) This comment has been minimized. Show comment Hide comment Copy link Quote reply egilburg on Apr 9, 2015 Contributor you can do values_with_empty_parameters.values.none? [nil, nil].none? => true Pick your reaction egilburg on Apr 9, 2015 Contributor you can do values_with_empty_parameters.values.none? [nil, nil].none? => true
Tags
Annotators
URL
-
-
github.com github.com
-
Finally, you can use fields_for in order to create/edit associated fields and the suffix _list (like profile_list below) to choose an existing associated record.
-
-
blog.useproof.com blog.useproof.com
-
The goal of the header copy is to say just enough to get the user to convert without getting in their way. Appcues says all they need to in one concise and straightforward sentence.
Tags
Annotators
URL
-
- Jan 2021
-
developer.mozilla.org developer.mozilla.org
-
The behavior of this code is identical, but the implementation is much easier to write and read.
-
While custom iterators are a useful tool, their creation requires careful programming due to the need to explicitly maintain their internal state. Generator functions provide a powerful alternative: they allow you to define an iterative algorithm by writing a single function whose execution is not continuous. Generator functions are written using the function* syntax.
-
-
stackoverflow.com stackoverflow.com
-
Also, you'll get more concise code. More boilerplate left handling by the machine means more available human for the actual logic.
-
- Dec 2020
-
github.com github.com
-
json.(
I don't care what the Rubocop style guide says about this; this is nicer and cleaner than typing
json.call(...)
.
-
- Nov 2020
-
en.wikipedia.org en.wikipedia.org
-
if a R b and b R c, then a R c
-
-
github.com github.com
-
In Svelte, all reactive statements are memoized. Instead of const var = useMemo(() => expression, dependencies), you can use $: var = expression. Notice with Svelte, you don't need to declare the dependencies. The compiler infers them for you.
-
-
stackoverflow.com stackoverflow.com
-
yell() { echo "$0: $*" >&2; } die() { yell "$*"; exit 111; } try() { "$@" || die "cannot $*"; }
-
-
-
When people write COND && COMMAND, typically they mean "if COND succeeds (or is boolean true), then execute COMMAND. Regardless, proceed to the next line of the script." It's a very convenient shorthand for a full "if/then/fi" clause.
-
-
github.com github.com
-
3.25.0 Compiler Output
-
- Oct 2020
-
unix.stackexchange.com unix.stackexchange.com
-
Recursion can result in a quite concise solution
-
-
medium.com medium.com
-
import statements will become much smaller, as we will be importing stuff from less files. For example AbstractNode.js has only on import statement now, where it had two before.
-
-
github.com github.com
-
first sighting: use of superscripts like this
I like it. Nice and concise and understandable.
- s¹  critical
- s²  important
- s³  nice to have
- s⁴  low
- s⁵  inconvenient
But in other cases, the abbreviation is quite unclear and ambiguity:
Like, what does "pr" mean in these cases?
priority? Doubt it.
- pr¹  chore
- pr²  docs
- pr³  feature
- pr⁴  fix
- pr⁵  performance
- pr⁶  refactor
- pr⁷  style
Pull Request? Doubt it. But maybe?
For axes that are quantifiable, like severity, using a number makes sense. But what benefit is there in including a number in these (platform?) labels?:
- p¹ ⋅ browser
- p² ⋅ linux
- p³ ⋅ mac
- p⁴ ⋅ windows
I think this would have been better and clearer (in that fewer people would be like huh? and wonder what it means):
- platform: browser
- platform: linux
- platform: mac
- platform: windows
-
-
-
hyperscript is more concise because it's just a function call and doesn't require a closing tag. Using it will greatly simplify your tooling chain.
I suppose this is also an argument that Python tries to make? That other languages have this con:
- cons: closing tags make it more verbose / increase duplication
and that Python is simpler / more concise because it uses indentation instead of closing delimiters like
end
or}
?
- cons: closing tags make it more verbose / increase duplication
and that Python is simpler / more concise because it uses indentation instead of closing delimiters like
-
-
-
But this is starting to become rather verbose at what could be a much simpler and more elegant solution if only there were another template helper that could do variable assignment.
-
-
github.com github.com
-
Comparison to useReducer
-
- Sep 2020
-
svelte.dev svelte.dev
-
Reducing the amount of code you have to write is an explicit goal of Svelte.
-
-
medium.com medium.com
-
and making the code more beautiful and compact and human readable
-
-
-
We should also allow passing unrecognised props to the rendered component. eg: tabindex might be required on some instances of a component, and not all. Why should developers have to add tabindex support to their components just that it may potentially be used
Glad to hear this is solved now: $restProps
-
-
daveceddia.com daveceddia.com
-
With useEffect, you can handle lifecycle events directly inside function components. Namely, three of them: componentDidMount, componentDidUpdate, and componentWillUnmount. All with one function!
-
- Aug 2020
-
gohugo.io gohugo.io
-
<!-- The . represents an element in $array -->
-
-
unix.meta.stackexchange.com unix.meta.stackexchange.com
-
Then when giving answers I'm even less certain. For example I see occasional how-to questions which (IMO) are ridiculously complex in bash, awk, sed, etc. but trivial in python, (<10 lines, no non-standard libraries). On such questions I wait and see if other answers are forthcoming. But if they get no answers, I'm not sure if I should give my 10 lines of python or not.
-
- Jul 2020
-
www.w3.org www.w3.org
-
Terse RDF Triple Language
Tags
Annotators
URL
-
-
-
Context RAILS_ENV webpacker.yml NODE_ENV webpack config
-
-
svelte.dev svelte.dev
-
preventDefault — calls event.preventDefault() before running the handler. Useful for client-side form handling, for example. stopPropagation — calls event.stopPropagation(), preventing the event reaching the next element passive — improves scrolling performance on touch/wheel events (Svelte will add it automatically where it's safe to do so) capture — fires the handler during the capture phase instead of the bubbling phase (MDN docs) once — remove the handler after the first time it runs self — only trigger handler if event.target is the element itself
-
-
bugs.ruby-lang.org bugs.ruby-lang.org
-
Why don't you allow a range without end, like (1..)? There are two advantages. First, we can write ary[1..] instead of ary[1..-1]. The -1 is one of the most I dislike in Ruby. It is very magical, ugly, redundant, and disappointing. I envy Python's ary[1:]. I know that ary.drop(1) is slightly fast, but too long for such a common operation, IMO. Second, we can write (1..).each {|n| ... }.
-
- Jun 2020
-
www.reddit.com www.reddit.com
-
I was just expressing that, even thought I like React, I dread having to still manually handle everything, instead of just using a directive, a la Vue.JS. This is what I consider boilerplate. Hence my comment on how I could leave React for Svelte just because of that. Clearly a Svelte side-by-side code comparison shows a much cleaner code for Svelte.
-
<script> let a = 1; let b = 2; </script> <input type="number" bind:value={a}> <input type="number" bind:value={b}> <p>{a} + {b} = {a + b}</p>
-
I'm saying I'm ready to switch just because of the clarity of the code.
-
- Apr 2020
-
iapp.org iapp.org
-
Finally, from a practical point of view, we suggest the adoption of "privacy label," food-like notices, that provide the required information in an easily understandable manner, making the privacy policies easier to read.
-
- Nov 2019
-
stackoverflow.com stackoverflow.com
-
More elegant, just for fun: const parents = node => (node.parentElement ? parents(node.parentElement) : []).concat([node]);
-
- Sep 2019
-
cloudreports.net cloudreports.net
-
const forceUpdate = () => useState(0)[1];
-
- Dec 2017
-
crumplab.github.io crumplab.github.io
-
The IRB helps to make sure that the risks of the proposed research are minimized, the benefits outweigh the risks, the research is carried out in a fair manner, and the informed consent procedure is adequate.
Clear and concise explanation of exactly what IRBs do.
-