This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | {{/* | |
| figure with auto-resizing and srcset v2024-11-24 | |
| Drop-in replacement for Hugo's figure shortcode which uses img srcset | |
| to enable browsers to download only the resolution that they need. | |
| The resizing and srcset magic only works for images that are part of the page | |
| bundle. It will fall back to stock Hugo figure behaviour otherwise. | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| MAX=10 | |
| if [[ ! -z "$1" ]]; then | |
| MAX=$1 | |
| fi | |
| for i in $( seq $MAX ); do | |
| FILE=image${i}.jpg | |
| curl 'https://thispersondoesnotexist.com/image' -H 'authority: thispersondoesnotexist.com' -H 'pragma: no-cache' -H 'cache-control: no-cache' -H 'upgrade-insecure-requests: 1' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36' -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3' -H 'referer: https://thispersondoesnotexist.com/' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: en-US,en;q=0.9' --compressed -o $FILE | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | RSpec.configure do |config| | |
| config.before(:suite) do | |
| FactoryBot.find_definitions if FactoryBot.factories.count == 0 | |
| DatabaseCleaner[:active_record].clean_with(:transaction) | |
| end | |
| config.around(:each) do |example| | |
| unless User.count.zero? | |
| # we will output to current terminal but also into a file in tmp | |
| open('tmp/leaky.txt', 'a') { |f| | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // MIT Licensed | |
| // Author: jwilson8767 | |
| /** | |
| * Waits for an element satisfying selector to exist, then resolves promise with the element. | |
| * Useful for resolving race conditions. | |
| * | |
| * @param selector | |
| * @returns {Promise} | |
| */ | 
Short link to this page: http://caseywatts.com/ptt
Other gists & tricks: http://caseywatts.com/gists-and-tricks
Unrelated update: my book is out! Debugging Your Brain is an applied psychology / self-help book
- Save this bookmarklet. Right-click on boomarks toolbar 
Add Page... 
- Name: 
PTT(push to talk) or whatever you'd like (maybe short so it stays on your bookmarks toolbar) 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # this is the code I used to determine the csv_path to use when using Paperclip with Amazon S3 AWS | |
| # necessary because my development environment doesn't upload to S3 | |
| # get an object that has_attachment with Paperclip | |
| object = ModelWithPaperclip.last | |
| # use url if no file exists at path | |
| csv_path = File.exists?(object.csv.path) ? object.csv.path : object.csv.url | |
| # this should probably be implemented as a model method | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #app/inputs/collection_check_boxes_input.rb | |
| class CollectionCheckBoxesInput < SimpleForm::Inputs::CollectionCheckBoxesInput | |
| def item_wrapper_class | |
| "checkbox-inline" | |
| end | |
| end | 
NewerOlder