Intercooler.js Bug: Body Overflow Hidden Toggled on New Page Load

Ran into a little bug here tonight playing around with Intercooler.js. At the moment I’m converting my traditional web-app, MoneyPhone, into a single page application using Intercooler.js. However, whenever I attempt to swap out one page with another using Intercooler.js, somehow all of the page overflow is becoming hidden. I’ve poured over my code and can’t find anything related to ‘body overflow hidden’, but did see in the developer console that the style property overflow is indeed being set to hidden whenever a new page is loaded in the background with Intercooler.js.

So I just wanted to post a quick little bug fix here on the blog in case anyone else out there on the ole interwebs runs into this problem in the future:

$(document).on('success.ic', function(event, ajaxSetup, elt){
  document.getElementById("body").style.overflow = 'visible';
});

 

How to Play Music in Python without Blocking the Main Thread

One of my students today at theCoderSchool was interested in writing a Python program that featured music. However, we quickly ran into a problem of blocking the main thread. But thanks to the threading library, we were easily able to play the music on it’s own thread and get back to coding her program:


from playsound import playsound
from threading import Thread

def play_music():
    playsound('wooboost.mp3')

# Play Music on Separate Thread (in background)
music_thread = Thread(target=play_music)
music_thread.start()

print("Does playsound block the main thread?")
user_input = input("What is your guess?: ")
print("You guessed: " + user_input)

 

How to Pitch Like Melanie Perkins

Read a really interesting article on Forbes today about Melanie Perkins, CEO of Canva, on how she went about pitching Canva to Venture Capitalists in the early days. Perkin’s says that when she first started pitching Canva, she always started with her solution to the problem she was trying to solve. However, when she switched up her pitch and started leading with the problem instead, she finally found success raising money for Canva.

I don’t think leading with the problem is necessarily intuitive, so I wanted to make a quick note of Perkins insight here on my blog so that I’ll remember to always lead with the problem when pitching MoneyPhone. I’m planning on re-shooting a video about MoneyPhone for my landing page explaining the product this month, and I think I now have a much better idea on how to go about presenting MoneyPhone to potential users. But this time, I’m going to make sure to lead with the problem before presenting my solution:

  • Habit– You eye-ball your bank account balance and have no idea how much exactly you are spending every month and where all of your money is going.
  • Problem– You end up living paycheck-to-paycheck. Make more money and you spend more money. Make less money and you spend less money.
  • Solution– You need MoneyPhone in your life!
 

The Startup Cooperative

Late night idea I don’t want to forget before I go to bed: The Startup Cooperative— a zero equity startup accelerator/incubator where all of the founders agree to use each other’s MVPs (minimum viable products).

 

Synapse: Programmable Banking Platform

Just wanted to write a quick post about a new startup I discovered today called Synapse. Synapse is a programmable banking platform that “enable[s] companies to build and launch best-in-class financial products. ” At the moment I happen to be working on a new personal finance app called, MoneyPhone, and I think it would be really interesting to see what sorts of features I might be able to add using Synapse. Specifically, I think it would be really awesome if I could create a checking account that gives users control to prevent companies from pulling money from your account at will. Here’s an example: I signed up for some sort of dental plan through my dentist last year under the assumption that I was making one payment for one year of this dental treatment plan. Well 12 months later the dental plan company just pull $300+ dollars from my account unannounced. Month-to-month payments aren’t that bad, but companies shouldn’t just be able to pull money from your account unexpectedly. So I’m going to have to check out Synapse and what all I can do with it. I am very excited about the new features I might be able to add to MoneyPhone in the future with the power of Synapse.

 

OregonTrailJS

Oregon Trail Tutorial for my Students…

 

Stripping Special Characters from Strings in JavaScript without Regex

Last night while working on my latest project, a personal finance application, I ran across the need to strip certain (special) characters from a string of user input in JavaScript. I assumed that there was an easy built in feature to do this in JavaScript, but most of the examples I found either used Regex which I don’t really want to use, or utilized some other confusing method that was not particularly straight forward. So, I decided to go ahead and post my ugly yet simple solution here on the blog in case anyone else might one day need it.

For my technique, I simply have one string variable that I want to strip special characters from, and another empty string which I will append characters from the original string excluding any special characters that I want to ‘strip’: SOURCE CODE ON GITHUB

 

Why Blogging is Better than Contributing to Wikipedia

Was talking to a friend recently about Wikipedia, and found myself wondering, “why don’t I ever (attempt) to contribute to Wikipedia anymore?” And then I realized… edit wars. Almost every time I tried to contribute to Wikipedia I would end up in some stupid edit war with another neckbeard somewhere out there in cyberspace.

However, I find that I’m blogging a lot more now post-Wikipedia. So maybe contributing to Wikipedia is somewhat of a gateway drug to blogging. I dunno, don’t really have anything else to say. Just, blogging is the way to go. No edit wars, no comments. Just thinking out-loud and contributing little snippets of information to the collective knowledge bank over time.

 

JS Trivia Game Starter Template

Source code available on Github: https://github.com/topherPedersen/Trivia-JS-Starter-Template/tree/master

The beginnings of a JS trivia game (starter template). Made by my students you know where…

Souce Code on Github

// Young man, and young woman, create a function called
// andHisNameIsJohnCena... GO!
var questionOneCorrect = null;
var questionTwoCorrect = null;
var questionThreeCorrect = null;
var questionFourCorrect = null;
var questionFiveCorrect = null;
var questionSixCorrect = null;
var questionSevenCorrect = null;
var questionEightCorrect = null;
var questionNineCorrect = null;
var questionTenCorrect = null;

function andHisNameIsJohnCena() {
    document.write("AND HIS NAME IS JOHN CENA!!!");
    document.write('<iframe width="560" height="315" src="https://www.youtube.com/embed/g6EnrLlofL0?autoplay=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>');
    var vid = document.getElementById("myVideo");
    vid.autoplay = true;
    vid.load(); 
}
function answer(questionNumber,ans) {
    if (questionNumber==1 &amp;&amp; ans=="Nihonium") {
        questionOneCorrect = true;
        alert("Correct! I didn't think you were smart enough to get it. Give yourself a pat on the back.");
    } else if (questionNumber==1 &amp;&amp; ans=="Johncenium") {
        andHisNameIsJohnCena();
    } else if (questionNumber==1) {
        questionOneCorrect = false;
        alert("Get rekt m8.")
    }
}

 

There are Some Games You Don’t Get to Play Unless You’re All In

“There are some games you don’t get to play unless you’re all in.”

Dr. Jordan Peterson