61 Matching Annotations
  1. Feb 2024
  2. Aug 2023
  3. Mar 2023
  4. Nov 2022
  5. Aug 2022
    1. 🚀A walkthrough of Obsidian x PPT workflow 🥳Obsidian 與 PPT 工作流整合 ☕中英對照影片 0:59 Install obsidian pandoc plugin 1:45 install homebrew 2:18 install pandoc 3:15 Pandoc path 3:56 introduce the example file
    2. Integrating Logseq and Zotero: A great combination for academic writing
    3. Using Logseq for PDF note-taking

      .

  6. Jun 2021
    1. 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.
  7. Apr 2021
    1. This gem uses a Rack middleware to clear the store object after every request, but that doesn't translate well to background processing with Sidekiq. A companion library, request_store-sidekiq creates a Sidekiq middleware that will ensure the store is cleared after each job is processed, for security and consistency with how this is done in Rack.
  8. Mar 2021
    1. data = {}.extend XKeys::Auto # Vs ::Hash, uses arrays for int keys data[:users, 0, :name] # nil data[:users, 0, :name, :raise => true] # KeyError data[:users, :[], :name] = 'Matz' # :[] is next index, 0 in this case # {:users=>[{:name=>"Matz"}]} pick = [:users, 0, :name] data[*pick] # Matz data[:users, 0, :accesses, :else => 0] += 1 # {:users=>[{:name=>"Matz", :accesses=>1}]}
  9. Feb 2021
  10. Oct 2020
  11. Sep 2020
  12. Jul 2020
    1. Unlike the webpack config, webpacker.yml settings are determined by the current RAILS_ENV.
    2. All this to say: your webpack test config, i.e. config/webpack/test.js, is essentially useless unless your application: a. uses a Node.js test runner for JavaScript unit test AND configure it to use your webpack config a. overrides the defaults so that the test config is loaded in your Rails tests (just be sure to change Babel behavior)
  13. May 2020
    1. # If you are using devise, you must extend engines's controller with devise helpers in order to get current_user PolicyManager::UserTermsController.send(:include, Devise::Controllers::Helpers)
  14. Apr 2020
    1. Remember to call super in any subclasses that override teardown.

      And yet the Rails core chose not to use RSpec, citing how it would be too easy to write subject == expected on accident?

    1. Github Pages is a sweet service that builds your Jekyll site for you when you commit changes to a Github repo. If you were using redcarpet and Pygments, you now should switch to Kramdown and Rouge to stay updated with the recommended Markdown filter and syntax highlighter supported by Github Pages.
    1. Rails also adds a test method that takes a test name and a block. It generates a normal Minitest::Unit test with method names prefixed with test_. So you don't have to worry about naming the methods, and you can write something like:

      Or you could use the "it" format mentioned on https://devhints.io/minitest.

      Or better yet, just use rspec...

  15. Mar 2020
  16. Dec 2019
  17. Oct 2019
    1. Rack middleware is more than "a way to filter a request and response" - it's an implementation of the pipeline design pattern for web servers using Rack. It very cleanly separates out the different stages of processing a request - separation of concerns being a key goal of all well designed software products.