An Option for dealing with CORS

As we do more things with JSON, I run into CORS access issues. They can be solved in various ways but it’s often a hassle. It often irritates me as I build demos in COde

After wanting a simple solution this AM, I made this tiny, insignificant PHP file that I think might be useful to others.

Name this file cors.php.1

Put this file on a server.

You can now append some JSON URL to that URL like so … and it returns drama-free JSON for your use and enjoyment. Assuming you have HTTPs on your server it should also deal with HTTP/HTTPS conflicts as well which is very handy at times.

header("Access-Control-Allow-Origin: *");//let the people in
header("content-type: application/json");//make the return all JSON-Y
$url = htmlspecialchars($_GET["url"]);//get the URL parameter from the . . . URL
echo file_get_contents($url);//spit it back out

1 Or name it whatever you want. I’m going using bossiness as a shortcut to clarity.

Weekly Web Harvest for 2019-07-21

  • Please Consider My Application to Give You Labor So I Can Stay Alive – McSweeney’s Internet Tendency
    If you look at my résumé, I think you’ll find that I have extensive relevant experience that I could bring to the table after onboarding. In the formative years of my life, I attended primary school in exchange for not being detained per truancy laws in my home state; I then matriculated to college, where I cut my teeth going to classes in exchange for a framed sheet of cardstock that was a prerequisite for submitting this application.
  • The Pizza Effect – Futility Closet
    The pizza example continues to “echo” between the Italian and American cultures: American tourists sought out “authentic” (non-American) pizza in Italy, and the Italians met the demand by creating brick-oven pizzerias. The Americans then carried these back to their own country. Stephen Jenkins of Humboldt State University writes, “Hence, Americans met their own reflection in the other and were delighted.”
  • xkcd: Spreadsheets
    Pretty much my life . . .
  • I thought I was being ‘blacklisted’ by university colleagues, so I demanded to see their emails | The Independent
    Firstly, my eminent and influential PhD supervisor had let it be widely known that they thought I was an unpleasant person, impossible to work with, fundamentally stupid, and that I definitely shouldn’t be doing a doctorate.
  • pampers launches ‘lumi’ smart diapers that track baby pee
    the sensor then sends all information the the accompanying app where parents can chart feeding times and milestones to better understand how their child’s routines are changing over time. meanwhile, the logitech camera – which features a high-definition, wide-angle monitor – includes night vision and two-way audio so that parents can keep an eye on their little one. it also tracks room temperature and humidity.

Lunar Optimism

It’s a bit past the apogee (see what I did there?) of the 50th anniversary of the Apollo 11 lunar mission. Maybe a long time for us, but to the moon, that’s but 0.000000011 of its history.

The Eagle landed, and it was 2:56 UTC on July 21 when Neil Armstrong stepped out of the door. For a six year old kid in Baltimore, that was 10:56PM at night. Our family was perched in the living room, watching on maybe a 14″ Zenith black and white TV set.

Old 1960s TV set, white dingy case.
Not the exact model of TV we had, but some vintage like this.

It was not part of the living room decor, I can remember Dad placing it atop a folding step stool as a makeshift stand. I was sitting as close as possible to it.

The images were fuzzy, grainy. Live TV events like sports were not unusual, but the idea that something could be transmitted in real time (well there was a delay) from the Moon was rather fitting for the same TV we also watched Star Trek on.

That was the moment.

More memorable from the Apollo era was the special days when the astronauts returned to earth. At Bedford Elementary school they gathered all the students in the auditorium to watch the module splash down in the ocean. There were no giant projection screens, again we saw in what was then large TVs (24″ screens? big box tube TVs) perched on carts, maybe 6 of them for a few hundred kids to watch.

The vivid feeling in the 1970s I felt there was of unlimited optimism. If they could send astronauts strapped in a rocket to the moon, and then return them a few days later, why everything was possible. Certainly by 2000 we’d have flying cars and automated lifestyles.

Or that’s how I remember it.

In 2019, where every day the news is … well you know what it is, that kind of optimism seems as antiquated as the old TVs and plaid pants I wore.

But it need not be gone. So I look to the moon every now and then, and ponder it’s sliver of optimism, of a spark, of maybe large, not unlimited possibility, but still… possibility.

The moon is patient, so I can be too.

Thank you moon, for the reflected optimistic light you send our way.

Featured Image:

Weekly Web Harvest for 2019-07-14

  • teenage engineering – PO-32 tonic
    never before has a drum machine that sounds this good
    with literally endless sound capabilities been set at a price this low.
    meet PO-32 tonic, the new gold standard drum machine.
    and yes, it comes in a gold plated cardboard box.

  • Haruspex – Wikipedia
    In the religion of Ancient Rome, a haruspex (plural haruspices; also called aruspex) was a person trained to practice a form of divination called haruspicy (haruspicina), the inspection of the entrails (exta—hence also extispicy (extispicium)) of sacrificed animals, especially the livers of sacrificed sheep and poultry. The reading of omens specifically from the liver is also known by the Greek term hepatoscopy (also hepatomancy).
  • “Effectiveness of Animation in Trend Visualization,” ten years later
    Our results found that animation is a paradox.
    It certainly wasn’t very effective for solving our tasks. Whether they had interactivity or not, users in the animation condition were less accurate than small multiples. Users took a very long time to answer questions when given an interactive animation, scrolling back and forth. When we took that control away, they’d quickly make their best guess. Despite that, interactive animation wasn’t much more accurate then non-interactive!
    But we also found that users really liked the animation view: Study participants described it as “fun”, “exciting”, and even “emotionally touching.” At the same time, though, some participants found it confusing: “the dots flew everywhere.”

  • An (anti) audioblogging manifesto
    Consider also this – the average person speaks at one hundred, perhaps
    one hundred fifty words per minute. Meanwhile, an accomplished reader
    can read ten times faster – up to a thousand words a minute, and that’s
    straight-up reading, not even skimming. You’re forcing people to listen
    to you at a speed that’s barely faster than the speed at which they can
    type. Why are you wasting their time? Is your voice really that

  • FaceApp: Is The Russian Face-Aging App A Danger To Your Privacy?
    Feels like the intro paragraph is too pat but the full article shows the complexity of all this stuff and if facial recognition gets you into devices then thinking more about where your face is online will likely matter more and more.

    The weird decision in the article to focus on where a server is physically also makes no sense to me.

    What a mess.

  • [Folio] The Last Frontier, by Ted Conover | Harper’s Magazine
    In good weather, the large area between the mountain ranges has many appeals: incredible views, eagles and other wildlife, and land you can buy for a song. Five-acre lots on the prairie are typically priced at $3,000 to $5,000. (Land costs a lot more around the mountainous edges or in towns, where more people live.) But only the hardy can make it here year-round. The cheap land is almost all treeless and miles from anywhere, and the valley is famously windy.

    The McDonalds, the father still in jail awaiting trial for child abuse, were thinking hard about leaving the area before school started in the fall—possibly for Alabama, where they had come from years before. Another neighbor told me her cousin was visiting to withdraw from her addictions to meth and heroin. Paul was planting a garden and thinking of getting his last teeth pulled. Rick, also in the area, had sent out a group message on Facebook warning of the mountain lion he had seen on his property. Rhonda and Ke’Attrice, before long, would report that Rhonda’s house had been robbed while she was away; disillusioned, they said they might put it up for sale and move to Alaska.

Sliders as Inputs

Origin Story

There once was a worksheet that was meant to be used in a face-to-face scenario. The goal was indicate where you fell on a spectrum across a number cultural orientation of measures. The challenge was to transform that into something digital that could then be part of a larger conversations.

Watch the video above to get an idea of what the experience is like or this will make even less sense.

The Sliders

I like sliders as interface elements for things like these.1 You can see the HTML below that builds them or check out the Codepen for more CSS etc. That’s all pretty straight forward.

<div class="slider-container">
<div class="slide-label left">Direct Communication</div>
<div class="slide-label right">Indirect Communication</div>
<input id="directness" class="slider" max="100" min="0" type="range" value="50" />

I did have to add the input tag to the KSES allowed list to keep WordPress from stripping it out. To do that I added the following to our KSES modifier file.

$allowedposttags["input"] = array(
 "type" => array(),
 "range" => array(),
 "min" => array(),
 "max" => array(),
 "value" => array(),
 "id" => array(),
 "class" => array(),

Getting the Values

Now I needed some javascript to look at these sliders and record the values as the sliders were . . . slid in various directions. This little bit gets our values once we loop through the sliders that exist. Simple.

function sliderAmount(slider){
	 sliderValue = slider.value;
	return sliderValue;

Gravity Forms Integration

I did this via Gravity Forms because it’s fast and I’m overly comfortable with it. This is where things get a bit weird. We’re using a typical Gravity Forms to post scenario. Nothing odd there but I ended up building a shortcode to let me build the post content which is not as typical.

The javascript below is looking for our form and then writing various variables to the fields (which are hidden by CSS). The shortcode ends up looking like [dih-graph scores=”50,50,50,50,50″] with the 50s being replaced by whatever scores are recorded.

if (document.getElementById('gform_wrapper_6'))//change for prod
	let values = [50,50,50,50,50];
	let sliders = Array.from(document.getElementsByClassName('slider'));
	let field = document.getElementById('input_6_4');
	let title = document.getElementById('input_6_1');	
	sliders.forEach(function(slider, index) {
		slider.oninput = function (){				
				values[index] = sliderAmount(slider);
				field.value = '[dih-graph scores="'+values.join(',')+'"]';
				title.value = values.join('/');


The Shortcode

The shortcode is pretty ugly but it works. It loops through the data provided and generates the necessary HTML.

function dih_grapher_sc( $atts ) {
	$a = shortcode_atts( array(
		'scores' => '1,2,3,4,5',
	), $atts );
    $graphs = '';
    $lefts = ['Direct Communication','Monochronic','Low Power Distance','Individualism','Task Focus'];
    $rights = ['Indirect Communication','Polychronic','High Power Distance','Collectivism','Relationship Focus'];
    $scores = explode(",", $a['scores']);
    foreach ($scores as $key => $score) {
	   $graphs .= graph_builder($score, $lefts[$key], $rights[$key]);
	return $graphs;
add_shortcode( 'dih-graph', 'dih_grapher_sc' );

function graph_builder($score, $left, $right){
	return '<div class="slider-container">
<div class="slide-label left">'.$left.'</div>
<div class="slide-label right">'.$right.'</div>
<p><input type="range" min="0" max="100" value="'.$score.'" class="slider" id="directness">


Now because Gravity Forms kept insisting on running filters I didn’t want on the content, I just stuck the data in a custom post field and then appended it to the post via a filter. That seems weird now that I write it but whatever.

function filterPostForTBL($content){
    global $post;	
	if (get_post_meta( $post->ID, 'tbl_score', true )){
	  return $content . get_post_meta( $post->ID, 'tbl_score', true ) . get_post_meta($post->ID, 'discussion-prompt', true);
	} else {
		return $content;

add_filter( 'the_content', 'filterPostForTBL');

Scroll to Entries

With our entries showing up on the same page as the form, I wanted to make sure that the person was redirected back to where they’d see other people’s entries. I did this by adding an id to the confirmation message and adding a bit of javascript to scroll to that ID.

function scrollToThanks(){
	console.log('scroll ran')
		console.log('scroll found thanks')
	  let thanks = document.getElementById("thanks");
	  let topThanks = thanks.offsetTop;
		  top: topThanks,
		  left: 0,
		  behavior: 'smooth'

var callback = function(){
  // Handler when the DOM is fully loaded

if (
    document.readyState === "complete" ||
    (document.readyState !== "loading" && !document.documentElement.doScroll)
) {
} else {
  document.addEventListener("DOMContentLoaded", callback);

Filter WordPress Title but Only in Admin Area

I am playing around with unfurling1 open graph data in the WordPress TinyMCE editor. You can see what that looks like in the video above. It’s a lot like the oEmbed experience in WordPress but with the open graph information driving it.

I want the data to go into the post body but I don’t want a title that links to a post because these types of posts are more about getting people out to that original content. People could still manually enter a title and that’d work but if they choose not to I thought it’d be nice if it was just removed from the equation.

That’s pretty nice on the front end but on the backend you end up with a maze of posts with the title (no title). That seemed irritating so I cobbled together the following function which creates a mini excerpt from the post content but only applies the filter when you’re in the backend/dashboard. Nothing fancy but a nice little pattern that I expect I’ll use again.

add_filter('the_title', 'new_short_admin_title', 10, 2);
function new_short_admin_title($title, $id) {
	if ( is_admin() ) {
	    if ($title === null || $title == '' || $title == '(no title)'){
	    	$title = super_short_excerpt();
    return $title;

function super_short_excerpt() {
    return wp_trim_words(get_the_excerpt(), 5);


1 I like how furl and url have similar sounds but it is a ridiculous term.

Weekly Web Harvest for 2019-07-07

  • At VidCon, Influencers, Fans, And Brands Seemed Ready To Leave YouTube Behind
    At one point, the party converged around an Instagram-famous Pomeranian wearing a leather jacket and sunglasses. The dog’s owner was trying to yell out the dog’s Instagram handle over the sound of guests singing Kelly Clarkson’s “Since U Been Gone” on a karaoke machine on the other side of the room.
  • TheyDrawIt!: An Authoring Tool for Belief-Driven Visualization
    This is really solid.

    Need to look at the privacy stuff but an awesome thing to exist.

  • EarthRoamer – The Global Leader in Luxury Expedition Vehicles
    Since 1998, EarthRoamer has been redefining luxury camping and overland travel with our solar/diesel hybrid, four-wheel drive Xpedition Vehicles (XVs).
  • Old Weather
    Help scientists transcribe Arctic and worldwide weather observations recorded in ship’s logs since the mid-19th century.
  • You Can Apply to Hunt Pythons With Shotguns in Florida
    There are currently 40 paid snake hunters who hunt pythons in the Everglades. Remarkably, they earn anywhere from $8.25-$15 an hour, plus an additional $50 for each python. They also get $25 for every foot of length beyond four feet, as well as a $200 bonus for each nest. This new shotgun initiative will bump the number of hunters to 120.
  • The Navy’s USS Gabrielle Giffords and the Future of Work – The Atlantic
    Unbeknownst to the participants, the scoring rules changed partway through the game. When this happened, he noticed that players who scored high on conscientiousness did worse. Instead of adapting to the new rules, they kept doing what they were doing, only more intently, and this impeded their performance. They were the victims of their own dogged persistence.

    –not sure how much of this whole thing makes sense but interesting to see how people think about it

Weekly Web Harvest for 2019-06-30

Yet Another Wood Pen Gift Story

Can one every have enough hand made wood pens made by friends from wood you have given them? I bet most to all of you never pondered this question.

Cori and I are currently sitting on the deck of the house in Strawberry, our first visit back since a year ago April when I left to live/love in Saskatchewan.

We have enjoyed doing next to nothing but relaxing. When we arrived Wednesday night, on the front deck was a small wooden box with the pen you see in the image for this post. The return address told me where the box came from. I knew it because Howard Rheingold had emailed a few weeks ago that he had finished this pen from a chunk of spalted Arizona Oak I brought him when I visited in December, 2018.

He had explained the reason it took long (sorry for the extra critters that came with the log, Howard). But what a gift to have this in my hand. It’s not even the first one he sent, I still use one he sent me in 2014– if I recall, it was some of my previous pen stories that inspired him to start making them himself (I hope I remember that correctly, Howard!).

This wood mailing thing goes back to 2010, when I had posted to flickr a photo of some wood I had cut up form an oak tree that I had taken down here in Strawberry.

The story plays out in the comments… but an educator I had known mostly through flickr comments as “Windsor Di” was horrified I would burn the wood when she thought they would be great for doing wood projects. So the natural thing was to get in touch… and I mailed a log to Windsor, Ontario. Yes it’s possible to mail a piece of wood. Or it was then.

Anyhow, months later I got in the mail a collection of the wood pens she turned.


Pens flickr photo by cogdogblog shared under a Creative Commons (BY) license

There was more to it, as in 2011 when I made my round the US and Across Canada road trip, I made a stop to visit Windsor, and in the back of my truck was a box full of this wood for her (again, I am not sure how it passed the thorough inspection the border agents did in Victoria).

The story played out again in 2013- some messages back and forth with Andy McKiel who had posted photos of Arbutus trees he saw in Vancouver island and had reminded me of the Arizona manzanita. On learning Andy worked too with wood (you should check him out on instagram for his images of the wood bowls he turns)… it happened again. I mailed a chunk of manzanita to Andy in Winnipeg, and eventually got back pens and an ipad stylus.

My brother-in-law Skip picked up the habit too, and so I end up with a collection of Pens From Friends (and stories).

And I guess it keeps going with this newest one from Howard.

I guess I ought to be writing something pen-worthy. It’s on the “list”. But thanks again Howard, what a treat.

Featured Image: