This file contains 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
#!/usr/bin/env ruby | |
class Splitter | |
SEPARATOR = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00DICM\x02\x00" | |
attr_reader :file_in_string | |
def initialize(file) | |
@file_in_string = File.binread(file) | |
end |
This file contains 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
#define a /* | |
#! \ | |
sub 'echo {print @_; print "\n"} | |
#' 2>/dev/null | |
# \ | |
echo "my polyglot"; exit; | |
# \ | |
sub puts{}; | |
puts "my polyglot"; | |
exit; |
This file contains 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
# Very simple Ruby diff for strings. | |
# It works only on strings with the same number of lines, but it was perfect | |
# for my usecase where I was modifying templates saved in the database and I | |
# wanted to be sure that I am changing only what needs to be changed. | |
def differ(str_a, str_b) | |
str_a.lines.zip(str_b.lines) do |line_a, line_b| | |
if line_a != line_b | |
puts "< #{line_a}" | |
puts "> #{line_b}" |
This file contains 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
<?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; |
This file contains 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
# 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 |
This file contains 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
<?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; |
This file contains 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
# 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 |
This file contains 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
# 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, |
This file contains 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
# 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 |
This file contains 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
# 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" |
OlderNewer