229 Matching Annotations
  1. Sep 2021
    1. With the help of cutting-edge technologies, you can implement smart waste management that helps to reduce the costs, and increase operational efficiency. Bookmark this article to learn more about smart waste management.
  2. Aug 2021
    1. Question and Answer Website Development: Functionality and Best PracticesTimur YilmazTech JournalistMarketplaceProduct GuideHomeBlogEntrepreneurshipQuestion and Answer Website Development: Functionality and Best PracticesAug 25, 202117 min readSocial media is a jumping-off point for many people to get informed. Yet, on such platforms, users are more likely to voice opinions rather than share knowledge. That's when the websites to ask questions become a good help. For example, Quora's monthly active user base grew from 200 million to 300 million in 2018 alone. In 2021, the 6.6 million downloads of the Reddit app represented a 128% increase over the previous year. What is a selling point for this kind of platform and how to build one? How do they remain beneficial in a years-long run? How Q&A websites managed to survive social network dominance? Read on to find out.

      Social media is a jumping-off point for many people to get informed. Yet, on such platforms, users are more likely to voice opinions rather than share knowledge.

      That's when the websites to ask questions become a good help. For example, Quora's monthly active user base grew from 200 million to 300 million in 2018 alone. In 2021, the 6.6 million downloads of the Reddit app represented a 128% increase over the previous year.

      What is a selling point for this kind of platform and how to build one? How do they remain beneficial in a years-long run? How Q&A websites managed to survive social network dominance? Read on to find out.

    1. I know, I know—needing to use JavaScript when writing CSS does feel like defeat, but unless there’s a vwWithoutTheScrollbarPlease unit in CSS, you’re going to need use JavaScript.
    2. Maybe someday, we’ll get a viewport unit that doesn’t factor in the scrollbars, but until then, we can only work around the current one.
  3. Jul 2021
    1. SvelteKit offers a very elegant solution for this — the load function. The load function can run both on the client and on the server side and in both cases will be executed before the component renders.
    1. You can do this elegantly with throw/catch, like this:
    2. In most languages, there is no clean equivalent for breaking out of a recursive algorithm that uses a recursive function. In Ruby, though, there is!
    1. Bash is a wonderful and terrible language. It can provide extremely elegant solutions to common text processing and system management tasks, but it can also drag you into the depths of convoluted workarounds to accomplish menial jobs.
  4. Jun 2021
    1. I don't think it is too clever. I think it solves the problem idiomatically. I.e., it uses reduce, which is exactly correct. Programmers should be encouraged to understand what is correct, why it is correct, and then propagate. For a trivial operation like average, true, one doesn't need to be "clever". But by understanding what "reduce" is for a trivial case, one can then start applying it to much more complex problems. upvote.
  5. May 2021
    1. Every time filter-repo is run, files are created in the .git/filter-repo/ directory. These files overwritten unconditionally on every run.
    1. That image only contains 200 pixels horizontally, but the browser stretches it to 400px wide or even farther!Luckily, you’ll see there’s an easy “fix” there at the end: our old good friend the width attribute!<img src="example.gif", srcset="example.gif 200w" sizes="(min-width: 400px) 400px, 100vw" width="200" /* <=== TA-DA! */ class="logo">As long as you can specify the width attribute so it reflects the true maximum size of your largest image, you won’t run into this problem of having sizes make your image wider than it naturally should go.
  6. Apr 2021
    1. class AuthConstraint def initialize(&block) @block = block || ->(_) { true } end def matches?(req) user = current_user(req) user.present? && @block.call(user) end def current_user(req) User.find_by_id(session[:user_id]) end end This is a flexible approach to defining route access based on any desired variable (roles, auth, etc...)

      Good solution, and might be needed if you want to base routes on roles, etc. — but this one is even easier if all you need is for it to be conditional based on signed in or not (because devise provides authenticated helper):


  7. Mar 2021
    1. A proposal to specify the path for bury with classes as values of a hash arg: {}.bury(users: Array, 0 => Hash, name: Hash, something: 'Value') # {user: [{name: {something: 'Value'}]} So all absent nodes could be created via klass.new

      Didn't understand it at first, but now I think it's a pretty clever/decent solution.

      Just a bit more verbose than one might like...

      At first I had reservations about the fact that this requires you to pass a hash ... or rather, once you start using a hash as your "list", you can't just "switch back" to an array (a "problem" I've noticed in RSpec, where you have some tags that are symbols, and some that are hashes: you have to list the symbols first: describe 'thing', :happy_path, driver: :chrome):

      {}.bury(users: Array, 0, 'Value')

      But I think that's okay in practice. Just use a hash for all "elements" in your list:

      {}.bury(users: Array, 0 => 'Value')
    2. A one-liner alternative for hash-only cases can be implemented using Enumerable#reduce: root = {} [:a, :b, :c].reduce(root){@1[@2]||={}}[:d] = 'E' # root => {:a=>{:b=>{:c=>{:d=>"E"}}}}
    3. I think the issues/problems specified in the comments are not present with a Hash-only implementation. :) I would be supportive of re-considering this feature just for use with a Hash, where I believe 80% of the real-life use cases would (and do) exist. I have encountered this need before in the wild, but not with Arrays.
    1. Prof. Devi Sridhar. (2020, March 25). We will be stuck in an endless cycle of lockdown/release for next 18 months, if we do not start mass testing, tracing, & isolating those who are carriers of the virus while pursuing rapid research for antiviral treatment or vaccine. This is the message the public needs to hear. [Tweet]. @devisridhar. https://twitter.com/devisridhar/status/1242743618986745861

    1. xdg-open should do the same thing - actually, it will call gnome-open, or kde-open, or whatever, depending on your desktop environment. Thus it's more portable.
    2. The advantage is that you can use gnome-open for almost all file-types, URIs and directories. It's one command to learn, instead of trying to remember about obscure commands like sensible-browser
    1. Refactoring is a means of addressing the problem of software rot. It is described as the process of rewriting existing code to improve its structure without affecting its external behaviour.
  8. en.wikipedia.org en.wikipedia.org
    1. PyPy uses a technique known as meta-tracing, which transforms an interpreter into a tracing just-in-time compiler.
    1. We’re not really using placeholder in our demo, but a value of a single space works:
    2. :placeholder-shown is super useful for us here! It’s basically the secret selector for testing if an input currently has a value or not.
    1. var md = require('markdown-it')('commonmark');

      first sighting: require(...)(...)

      How would that work with import? Not as fluidly but...

      import markdownIt from 'markdown-it'
      let md = markdownIt('commonmark')
  9. Feb 2021
    1. Adding ends to an activity is a beautiful way to communicate more than two outcomes to the outer world without having to use a state field in the ctx. It also allows wiring those outcomes to different tracks in the container activity.
    1. Instead of having this confusing maze of lambdas, regexes, and strings, we could, in theory, introduce a single entry point of configuration for Sprockets to use, and in that file declare all assets we wanted to compile. Well, that’s exactly what the manifest.js file is.
    2. One way to alleviate this configuration fatigue is by making configuration consistent and composable. That’s what Sprocket’s new “manifest.js” seeks to do.
    1. Not all cases can be covered and easily restored. And sometimes when we will reuse this function for different use-cases we will find out that it requires different restore logic.
    2. But why do we return 0? Why not 1? Why not None? And while None in most cases is as bad (or even worse) than the exceptions, turns out we should heavily rely on business logic and use-cases of this function.
    3. So, the sad conclusion is: all problems must be resolved individually depending on a specific usage context. There’s no silver bullet to resolve all ZeroDivisionErrors once and for all. And again, I am not even covering complex IO flows with retry policies and expotential timeouts.
    1. Monads provide an elegant way of handling errors, exceptions and chaining functions so that the code is much more understandable and has all the error handling, without all the ifs and elses.
    1. I wanted to keep reviewing restaurants, but I didn’t want to go back into their dining rooms both because of the risk and because I was afraid readers would take it as an all-clear signal. When the governor halted indoor dining again in December, my selfish reaction was relief. Then I briefly got depressed. How would restaurants survive? And how would I keep writing about them?One answer had already started to appear on sidewalks and streets in the form of small greenhouses, huts, tents and yurts. Inside these personal dining rooms, you can (and should) sit just with people from your own household. If the restaurant thoroughly airs the space out between seatings, any germs you breathe in should be the same ones that are bouncing around your home. Many restaurants instruct their servers to stay outside the structures as much as possible, though some don’t.

      Syntax of question and answer reveals itself again. His doubts and negativity are addressed within the first highlighted paragraph with a question coming to Pete's mind. He realized his influence as a critic and decided to take the right step to prevent anything bad from occurring. Despite his sacrifice, the next paragraph he discusses the clever solutions restaurants had come up with which solved his problem for the most part. This description underlines yet more change that brought upon good things, which is the main idea he is relating to the food scene. He creates a comparison between an at home setting along with the solutions restaurants have come up with to further emphasize his point of safety amidst COVID.

    1. It requires an account to update, but the other inputs are optional. If they're missing, it'll ignore those attributes. If they're present, it'll update them.
    2. For this one we'll define a helper method to handle raising the correct errors. We have to do this because calling .run! would raise an ActiveInteraction::InvalidInteractionError instead of an ActiveRecord::RecordNotFound. That means Rails would render a 500 instead of a 404.

      True, but why couldn't it handle this for us?

    1. while ActiveForm currently fits 99% of my use cases, I do sometimes make modifications based on the product requirements
    2. I will continue to use form objects and push changes into the repo when I feel they are universally relevant and valuable.

      new tag?:

      • code that is universally relevant/valuable
      • non - _-specific logic
    3. I typically save everything I can first, and then call the side-effects afterwards. If the side-effects fail I can handle them elsewhere and retry when necessary.
    1. This can be useful in cases like multistep registration. Previously in # rails we used to stick all of the validations in the class and then we're # stuck validating them all everytime
    1. Most importantly, let us support all of those who are using sport as a force to advance equality and opportunity;

      A viable way to solve the gender inequality as a whole.

    2. Not only are successful sportswomen showing girls that they can excel on the field; many are using their status to start important conversations about gender equality and to advocate for women’s rights more widely.

      Being a role model that shows the world the problem of gender inequality would be a viable solution.

    3. We also need more male athletes to step up with us, and model a culture that reflects equality, respect for diversity and non-violence, within and beyond sport.

      Solution that may work.

    4. Even when laws and policies are in place, deep-seated attitudes about gender roles can hold back substantive change

      Some solution may not work even though it seems like it will. This means that we can't solve this on a government level, but on a individual's thought.

    5. In November 2018, Fenerbahçe Sports Club, one of the oldest and most popular multi-sports clubs in Turkey, joined forces with HeForShe in an ’Equal together’ initiative involving its male football players, and seen by its global fan base of 25 million. They aim to achieve gender equality transformation through sport, with women- and children-friendly stadium practices, and a zero-tolerance approach to all sorts of discrimination against women and girls

      A solution for combating gender inequality in sports. We can create a new program that allows equal rights and wages for all genders.

    1. Universal Links allow you to register a series of domains that are allowed to interact with an installed application. If the application is not installed, the universal link is opened with Safari, allowing you to inform the user of the existence of an application or whatever is necessary.
  10. Jan 2021
    1. If components gain the slot attribute, then it would be possible to implement the proposed behavior of <svelte:fragment /> by creating a component that has a default slot with out any wrappers. However, I think it's still a good idea to add <svelte:fragment /> so everyone who encounters this common use case doesn't have to come up with their own slightly different solutions.
    1. Moving DOM elements around made me anxious and I wanted to preserve natural tab order without resorting to setting tabindex, so I also made a flexbox version that never moves DOM elements around. I think it's the superior solution, at least for the layouts I was going for. https://github.com/wickning1/svelte-components/blob/master/src/FlexCardLayout.svelte
    1. A Svelte component that monitors an element enters or leaves the viewport/parent element. Performant and efficient thanks to using Intersection Observer under the hood. Can be used in multiple projects including lazy loading images, infinite scrolling, playing/pausing the video when in the viewport, tracking user behaviour firing link pre-fetching and animations and many many more.
    1. Popper for Svelte with actions, no wrapper components or component bindings required! Other Popper libraries for Svelte (including the official @popperjs/svelte library) use a wrapper component that takes the required DOM elements as props. Not only does this require multiple bind:this, you also have to pollute your script tag with multiple DOM references. We can do better with Svelte actions!
  11. Dec 2020
    1. This is an opportunity to fix a bug: if you're on a page that redirects to a login page if there's no user object, or otherwise preloads data specific to that user, then logging out won't automatically update the page — you could easily end up with a page like HOME ABOUT LOG IN ----------------------------------------------------------------------------------------- Secret, user-specific data that shouldn't be visible alongside a 'log in' button:
    1. Instead of waiting for a magic fairy to appear and eliminate your problem so that you can enjoy life again, you might want to start adding those little positive events back onto your agenda despite the problem still being present

      This solution based therapy focuses on trying to get people active and engaged with life even when depressed.

      It is important to help patients experience those little positive events. These events can help people get back on track.

    2. If you need to imagine in concrete detail how you would notice that a problem disappeared, you are challenged to leave vague descriptions like “I’ll be happy”, “I’ll be less annoyed” behind.Vagueness in the end is a cognitive avoidance mechanism. It is easy to ruminate on general emotions and thoughts but very hard to imagine concrete outcomes and changes. We would rather not face precise thoughts, emotions or memories because they can be painful. Better to stay at a safe but vague distance.

      This is all about solution based therapy. We need concrete ways of fixing our problems.

      Vagueness is a cognitive avoidance strategy. It is a way to avoid digging deep.

      It is safer for our feelings to stay vague, but that is not where we need to improve.

  12. Nov 2020
    1. So, how does an SPA work? JavaScript loads in the browser and loads data from an API. Most of the rendering is done on the client Side. But search engine bots have a hard time indexing the page because it doesn't have much without JS.
    1. This scenario demonstrates one drawback of CSS: With all the style rules that need to be applied to multiple elements on multiple pages, things can get pretty redundant. And redundancy can eat up your time and cause friction whenever you need to change a color, font, or any other style aspect across your site.
  13. Oct 2020
    1. We could broadcast a warning if we find the variable to be set in the environment, but that is more likely than not to annoy people who intentionally set it.

      New tag?: warnings that may annoy people who intentionally do something. (Need a way to selectively silence certain warnings?)

    1. for (var member in myObject) delete myObject[member]; ...would seem to be pretty effective in cleaning the object in one line of code

      But checking hasOwnProperty is probably better/safer idea:

      for (var prop in obj) { if (obj.hasOwnProperty(prop)) { delete obj[prop]; } }
    1. I don't want Svelte to go out of its way to try to catch all these edge cases. It would require lots of fragile heuristics in the compiler. I want a solid compiler I can trust, not something magic but often out of service. I want it the simplest possible.
    1. In the many projects I have maintained so far, sooner or later I always run into the same issue: circular module dependencies. Although there are many strategies and best practices on how to avoid circular dependencies. There is very little on how to fix them in a consistent and predictable way.
    2. This is how I solve circular dependency issues nowadays.
    3. Examples of this include: requiring base classes or reading from imported variables that have not been initialized yet.
    4. as soon as you have a (indirect) circular dependency, you might be interacting with a half loaded module in your code.
    1. Perhaps we should detect URLSearchParams objects differently (using duck typing detection instead of instanceof window.URLSearchParams, for example) but the solution isn't adding a specific polyfill to Axios (as it'd increase the bundle size and still won't work with other polyfills).
    1. You can see that behaviour in this example. Select a range of text and hit the tab key. Because the <textarea> value changes, the current selection is cleared and the cursor jumps, annoyingly, to the end.
    1. Just like elements can have children... <div> <p>I'm a child of the div</p> </div>...so can components. Before a component can accept children, though, it needs to know where to put them. We do this with the <slot> element.
    1. The primary motivation behind virtual-dom is to allow us to write code independent of previous state. So when our application state changes we will generate a new VTree. The diff function creates a set of DOM patches that, based on the difference between the previous VTree and the current VTree, will update the previous DOM tree to match the new VTree.

      annotation meta: may need new tag: for: "code independent of previous state."

      annotation meta: may need new tag: for: diffs other than source/text code diffs (in this case diffs between virtual DOM trees)

    2. Manual DOM manipulation is messy and keeping track of the previous DOM state is hard. A solution to this problem is to write your code as if you were recreating the entire DOM whenever state changes. Of course, if you actually recreated the entire DOM every time your application state changed, your app would be very slow and your input fields would lose focus.
    1. As we've briefly seen already, you can listen to any event on an element with the on: directive:
  14. mdxjs.com mdxjs.com
    1. Before MDX, some of the benefits of writing Markdown were lost when integrating with JSX. Implementations were often template string-based which required lots of escaping and cumbersome syntax.
    1. 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.