Skip to content

Instantly share code, notes, and snippets.

@Thepusherr
Thepusherr / unsubscribe-feature.patch
Created November 19, 2025 13:27
Add unsubscribe checkbox for marketing emails
commit b270768b09d16fe904ce5e4345c446eee2a943c0
Author: Pusher <spunkspunkik@gmail.com>
Date: Wed Nov 19 15:00:14 2025 +0200
Add unsubscribe checkbox for marketing emails
- Add marketing_emails_subscribed boolean field to users table (default: true)
- Add Email Preferences section in profile page with checkbox
- Add update action to ProfilesController to handle preference changes
- Update routes to include :update action for profile resource
@Thepusherr
Thepusherr / parser.rb
Last active May 21, 2022 18:29
New scrape test #1 case 1
require 'mechanize'
agent = Mechanize.new
page = agent.get("https://agriculture.house.gov/news/documentsingle.aspx?DocumentID=2106")
hash = Hash.new
title = page.search('.newsie-titler').text.strip
datelocation = page.search('.topnewstext').text.strip.split(",")
date = Time.parse((datelocation[1] + datelocation[2]).chomp.strip).strftime('%Y-%m-%d')
location = datelocation[0]
article = page.search('.bodycopy').text.strip.gsub(/\r\n?/, "")
@Thepusherr
Thepusherr / pdfreader.rb
Last active May 24, 2022 10:43
New scrape test #3 case 1 Ruby test #2
require 'mechanize'
#gem install pdf-reader-html
require 'pdf/reader/html'
#data-id - part of the link, "LPQUTd" - jscontroller, "WYuW0e" -class PDF
agent = Mechanize.new
page = agent.get("https://drive.google.com/drive/folders/1v8kAzirygnGsKm4X0eX_OhNgFPw865aQ")
page.search('.WYuW0e').each do |x|
array_data_id = x.attr("data-id")