Skip to content

Instantly share code, notes, and snippets.

View alexschreyer's full-sized avatar

Alexander C. Schreyer alexschreyer

View GitHub Profile
@alexschreyer
alexschreyer / Ban domains from Buddypress signup.php
Last active December 14, 2015 06:18
Ban domains from Buddypress signup
// ====================================
// Limit signup by banning domains
function bp_as_restrict_signup_domains( $result ) {
$banned = array(
'spam1.com',
'spam2.com'
);
$error = 'Your email domain has been the source of spam. Please use another email address.';
@alexschreyer
alexschreyer / Calculate Volumes in SketchUp.rb
Created June 11, 2014 16:14
A snippet that sums up volumes of groups in SketchUp. It also adds face areas.
mod = Sketchup.active_model # Open model
ent = mod.entities # All entities in model
sel = mod.selection # Current selection
# Zero all totals
t_volume = 0.0
t_faces = 0.0
# Calculate the conversion factors
cu_yd = 12**3 * 27
@alexschreyer
alexschreyer / Display Flickr photos in SketchUp.rb
Last active August 23, 2022 00:41
This script loads Flickr's RSS feed and exatrcts images from it into the SketchUp model.
# This script loads Flickr's RSS feed and exatrcts images from it into the SU model
mod = Sketchup.active_model # Open model
ent = mod.entities # All entities in model
sel = mod.selection # Current selection
tag = 'architecture' # Flickr search tag
rad = 1000 # circle radius
n = 20 # number of images
@alexschreyer
alexschreyer / drop to z0
Last active August 29, 2015 14:16
Drop selection to ground (z=0) in SketchUp
mod = Sketchup.active_model # Open model
ent = mod.entities # All entities in model
sel = mod.selection # Current selection
sel.each { |i|
vec = Geom::Vector3d.new 0,0,-(i.bounds.min.z)
t = Geom::Transformation.new vec
ent.transform_entities(t, i)
}
@alexschreyer
alexschreyer / extractComments.js
Last active March 12, 2021 15:57
Extract comments from Acrobat PDF
// Get all annotations in current document
var annots = this.getAnnots();
// Assemble them into a Tab-delimited string (remove linebreaks in comments, too)
var cMyC = "Comment\tPage";
for ( var i=0; i<annots.length; i++ )
cMyC += ("\n"+annots[i].contents.replace(/(\r\n|\n|\r)/gm,"")+ "\t" + annots[i].page);
// Export them to MS Excel (opens the data there)
this.createDataObject({cName: "myCommentList.xls", cValue: cMyC});
@alexschreyer
alexschreyer / hrc-bumpersticker.htm
Created November 3, 2016 10:29
Hillary Clinton Website Bumpersticker
<div id="bumpersticker" style="margin:0;padding:0;position:fixed;top:0;right:0;background:none;z-index:1000;opacity:0.75;"
onMouseOver="this.style.opacity='1.0'" onMouseOut="this.style.opacity='0.75'" >
<a href="https://www.hillaryclinton.com/" title="I support Hillary Clinton. You should, too!" style="margin:0;padding:0;background:none;" target="_blank">
<img src="https://dl.dropboxusercontent.com/u/1129994/hillary-clinton.png" width="200" height="200" alt="Hillary Clinton Bumpersticker" style="margin:0;padding:0;border:0;background:none;" />
</a>
</div>
@alexschreyer
alexschreyer / pin-bumpersticker.htm
Last active November 16, 2016 09:30
Pin bumpersticker
<div id="bumpersticker" style="margin:0;padding:0;position:fixed;top:0;right:0;background:none;z-index:1000;opacity:0.75;"
onMouseOver="this.style.opacity='1.0'" onMouseOut="this.style.opacity='0.75'" >
<a href="https://www.youtube.com/watch?v=-rSDUsMwakI" title="Say no to hate!" style="margin:0;padding:0;background:none;" target="_blank">
<img src="https://dl.dropboxusercontent.com/u/1129994/safety-kilt-pin.png" width="200" height="200" alt="Safety (Kilt) Pin Bumpersticker" style="margin:0;padding:0;border:0;background:none;" />
</a>
</div>
@alexschreyer
alexschreyer / liquid-page-loader.js
Last active November 24, 2016 11:01
Liquid Page Bookmarklet
javascript: (function() {
if (!window.lqpage) {
lqpage = {};
lqpage.s = document.createElement('script');
lqpage.s.src = 'http://media.alexschreyer.net/lqpage/lqpage.js';
document.getElementsByTagName('head')[0].appendChild(lqpage.s)
}
})();
@alexschreyer
alexschreyer / liquid-page.js
Created November 24, 2016 11:02
Liquid Page JS
// "Liquid Page" -- Make all DIVs on a page draggable
// By A. Schreyer, (c) 2009-2016
// Downloaded from: www.alexschreyer.net
// Based on the Jquery UI themeroller
window.lqpage || (lqpage = {});
lqpage.trString = "";
lqpage.s1 = document.createElement("script");
lqpage.s2 = document.createElement("script");
lqpage.s1.setAttribute("src", "https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js");
@alexschreyer
alexschreyer / brick_wall_bumpout.rb
Created October 5, 2018 19:55
Apply transformations to a brick wall (headers only) in SketchUp
# Apply transformations to a brick wall (headers only)
mod = Sketchup.active_model # Open model
ent = mod.entities # All entities in model
sel = mod.selection # Current selection
# Max pullout of headers in inches
max_ext = 2
ent.each { |e|