Skip to content
View target_blank_external_links_filter.rb
View image_asset_path_filter.rb
module HTML
class Pipeline
class ImageAssetPathFilter < HTML::Pipeline::Filter
def call
doc.search("img").each do |img|
next if img['src'].nil?
src = img['src'].strip
View stripe_transfer_containing_charge.rb
# NOTE `auto_paging_each` requires a recent stripe ruby gem version
def stripe_transfer_containing_charge(stripe_charge, limit: 100)
txn = stripe_charge.balance_transaction
Stripe::Transfer.list({ limit: 100, created: { gt: stripe_charge.created }}).auto_paging_each do |transfer|
Stripe::BalanceTransaction.list({ limit: 100, transfer: transfer.id }).auto_paging_each do |bt|
if bt.id == stripe_charge.balance_transaction
return transfer
end
View configure_heroku_app_name.sh
#!/bin/bash
# For use in a `bin/setup` script to make onboarding new devs painless
# by configuring the current directory to link to a hard coded heroku app name
# test if heroku is configured for the app
if ! heroku config 2>&1 > /dev/null; then
echo $'\nHeroku is not configured. Configuring Heroku...'
# NOTE heroku app name hardcoded here
View all_stargazers_and_forkers.bash
GITHUB_ORGANIZATION_OR_USER=the_org
# to avoid rate limiting
GH_USERNAME=
GH_TOKEN=
curl -u $GH_USERNAME:$GH_TOKEN -s https://api.github.com/users/$GITHUB_ORGANIZATION_OR_USER/repos?per_page=200 | jq '.[] .full_name' | sed 's/\"//g' | while read line; do
# forks and stargazers
curl -u $GH_USERNAME:$GH_TOKEN -s https://api.github.com/repos/$line/stargazers | jq '.[] .login'
curl -u $GH_USERNAME:$GH_TOKEN -s https://api.github.com/repos/$line/forks | jq '.[] .owner .login'
View download_all_organization_repos.sh
GITHUB_USER=wombat
curl -s https://api.github.com/users/$GITHUB_USER/repos?per_page=200 | jq '.[] .clone_url' | sed 's/\"//g' | while read line; do g clone "$line"; done
View expost-published-post-permalink-list.php
<?php
require( dirname( __FILE__ ) . '/wp/wp-load.php' );
$posts = new WP_Query('post_type=post&posts_per_page=-1&post_status=publish');
$posts = $posts->posts;
header('Content-type:text/plain');
foreach($posts as $post) {
$permalink = get_permalink($post->ID);
View gui-scripting-mavericks.applescript
on enabledGUIScripting(flag)
get system attribute "sysv"
if result is less than 4240 then -- 4240 is OS X 10.9.0 Mavericks
-- In OS X 10.8 Mountain Lion and older, enable GUI Scripting globally by calling this handler and passing 'true' in the flag parameter before your script executes any GUI Scripting commands, or pass 'false' to disable GUI Scripting. Authentication is required only if the value of the 'UI elements enabled' property will be changed. Returns the final setting of 'UI elements enabled' even if unchanged.
tell application "System Events"
activate -- brings System Events authentication dialog to front
set UI elements enabled to flag
return UI elements enabled
View itunes_eleven_utilities.applescript
on ensure_playlist_sort_and_list_view()
-- http://stackoverflow.com/questions/4056812/how-to-change-the-order-of-a-song-within-an-itunes-playlist-by-applescript/13667549#13667549
tell application "System Events"
tell process "iTunes"
-- ensure list view
try
outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "iTunes"
on error
-- then we are not in list view
click menu button "View" of splitter group 1 of window "iTunes"
View tax_rate_decorator.rb
Spree::TaxRate.class_eval do
# UPGRADE_CHECK https://github.com/spree/spree/blob/1-3-stable/core/app/models/spree/tax_rate.rb#L33
def self.adjust(order)
order.clear_adjustments!
# TODO you'll have to customize this based on your situation
if order.taxable_flag?
return
end
Something went wrong with that request. Please try again.