Skip to content

Instantly share code, notes, and snippets.

View mrhead's full-sized avatar
👋
nil

Patrik Bóna mrhead

👋
nil
View GitHub Profile
# Convert iPhone .mov videos to .mp4 videos which can be embedded in Basecamp.
IFS="
"
for video in *.mov; do
ffmpeg -i $video -c:v libx264 -crf 23 -c:a aac -strict -2 `echo $video | sed "s/mov/mp4/"`
done
# The ffmpeg options were generated by ChatGPT. Here is the description
class Clients::Convertkit
def tags
request(:get, "/tags")["tags"]
end
def get_subscriber_by_email(email:)
request(:get, "/subscribers", params: { email_address: email })
end
end
@mrhead
mrhead / wordle.json
Last active September 7, 2024 04:54
All Wordle words. Line number = wordle number.
[
"cigar", "rebut", "sissy",
"humph",
"awake",
"blush",
"focal",
"evade",
"naval",
"serve",
"heath",
# Add "status: :see_other" to redirects without explicit redirect status
#
# This is useful for migration to Turbo: https://turbo.hotwired.dev/handbook/drive#redirecting-after-a-form-submission
#
# Usage:
#
# ack redirect_to app/controllers | cut -f 1 -d : | sort -u | while read FILE; do ruby set_redirect_status.rb $FILE; done
unless filename = ARGV[0]
puts "Filename is required"
@mrhead
mrhead / convert_stimulus_targets.rb
Last active January 20, 2021 09:15
Convert Stimulus 1.x target syntax to Stimulus 2.0 target syntax
# Convert Stimulus 1.x target syntax to Stimulus 2.0 target syntax
#
# ack data-target app/views | cut -f 1 -d : | sort -u | while read FILE; do ruby convert_targets.rb $FILE; done
# ack data app/views | grep target: | cut -f 1 -d : | sort -u | while read FILE; do ruby convert_targets.rb $FILE; done
unless filename = ARGV[0]
puts "Filename is required"
exit(-1)
end
# https://3.basecamp.com/3293071/buckets/5610905/todos/3353537510
site = Site.find(23219) # futureofgood
csv = CSV.generate force_quotes: true do |csv|
csv << ["Name", "Email", "Signup Date", "Initial Article", "Signup Article"]
site.members.where("created_at >= ?", "2020-11-01").find_each do |member|
csv << [
member.full_name,
# Count number of words in a locale file.
def word_count(hash)
hash.values.sum do |value|
if value.is_a?(Hash)
word_count(value)
else
value.split.size
end
end
@mrhead
mrhead / memberful-wp-plus-wp-ultimate-recipe.php
Last active June 21, 2018 11:55
Memberful WP + WP Ultimate Recipe
<?php
$wp_ultimate_recipe_activated = in_array( 'wp-ultimate-recipe/wp-ultimate-recipe.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) );
$memberful_wp_activated = in_array( 'memberful-wp/memberful-wp.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) );
if ( $wp_ultimate_recipe_activated && $memberful_wp_activated ) {
add_action( 'wp', 'disable_wp_ultimate_recipe_content_filter' );
function disable_wp_ultimate_recipe_content_filter() {
global $post;
# lib/raven/processor/remove_ip_address.rb
class Raven::Processor::RemoveIpAddress < Raven::Processor
def process(data)
data = data.with_indifferent_access
if data.dig(:user, :ip_address)
data[:user][:ip_address] = nil
end
<?php
function is_protected_post( $post_id = NULL ) {
global $post;
if ( $post_id === NULL )
$post_id = $post->ID;
if ( in_array( $post_id, memberful_wp_posts_that_are_protected() ) )
return true;