Categories
coding

a question for you javascript/html5 guys/dolls

I found this code for “raw html” in wordpress to create a drop-down card with image and text when you hover over the button.

Trying to figure out how to change this code so that the card drops down when you click the button instead of hover?

here’s my suggested code:

<!DOCTYPE html>

<html>

<title>W3.CSS</title>

<meta name=”viewport” content=”width=device-width, initial-scale=1″>

<link rel=”stylesheet” href=”https://www.w3schools.com/w3css/4/w3.css”&gt;

<body>

<div class=”w3-container”>

 <h2>Card Dropdowns</h2>

 <p>Move the mouse over “London” or “Tokyo”:</p>

 <div class=”w3-dropdown-hover”>London

   <div class=”w3-dropdown-content w3-card-4″ style=”width:250px”>

     <img src=”img_london.jpg” alt=”London” style=”width:100%”>

     <div class=”w3-container”>

       <p>London is the capital city of England.</p>

       <p>It is the most populous city in the UK.</p>

     </div>

   </div>

 </div>

 <div class=”w3-dropdown-hover”>Tokyo

   <div class=”w3-dropdown-content w3-card-4″ style=”width:250px”>

     <img src=”img_tokyo.jpg” alt=”Tokyo” style=”width:100%”>

     <div class=”w3-container”>

       <p>Tokyo is the capital city of Japan.</p>

       <p>13 million inhabitants.</p>

     </div>

   </div>

 </div>

</div>

</body>

</html>

I tried the following code, but it’s still requiring a hover:

<!DOCTYPE html>

<html>

<title>W3.CSS</title>

<meta name=”viewport” content=”width=device-width, initial-scale=1″>

<link rel=”stylesheet” href=”https://www.w3schools.com/w3css/4/w3.css”&gt;

<body>

<div class=”w3-container”>

 <h2>Animated Dropdown</h2>

 <p>Use any of the w3-animate-classes to fade, zoom or slide in the dropdown content (w3-animate-zoom|opacity|top|bottom|left|right).</p>

 <div class=”w3-dropdown-click”>

   <button onclick=”myFunction()” class=”w3-button w3-black”>Click me</button>

   <div id=”Demo” class=”w3-dropdown-content w3-bar-block w3-card-4 w3-animate-zoom”>

     <div class=”w3-dropdown-hover”>London

 <div class=”w3-dropdown-content w3-card-4″ style=”width:250px”>

   <img src=”img_london.jpg” alt=”London” style=”width:100%”>

   <div class=”w3-container”>

     <p>London is the capital city of England.</p>

     <p>It is the most populous city in the UK.</p>

   </div>

 </div>

</div>

<script>

function myFunction() {

 var x = document.getElementById(“Demo”);

 if (x.className.indexOf(“w3-show”) == -1) {

   x.className += ” w3-show”;

 } else {

   x.className = x.className.replace(” w3-show”, “”);

 }

}

</script>

</body>

</html>

Categories
business

I learned a new word today

Incongruity


The relevant use of this term in business is something that just doesn’t make sense.

1. Economics

I feel we’re pretty lucky in New Zealand, that though the world economy is fraught with problems, many of our economical institutions and constructs seem to work. Which poses a dilemma for me, because without a problem to seek a solution to, how do you discover opportunity? The only thing I can think of that might be relevant is WINZ – RealMe login allows you to keep on top of most things going on with your benefit (I think there is a similar system for student living costs.) But what if your situation but not your finances change and as a user you need to talk to somebody? You have to either sit on hold listening to Tim Finn for 3.5hrs or make an appointment, wait in the waiting room and hopefully eventually talk to a (usually very friendly, accommodating and helpful) advisor/case worker. The part that seems like most people ‘just get over it’ is as a user the experience is terrible. Why is it allowed to stay like that? Because just like students at a horrible factory-for-beneficiaries (emulating the prison system) high school or most Ivy League colleges in North America – the institutions have forgotten that they are there to serve the user not the other way around. The government pays them to help us. They are not the ones giving us money (we are users, not inmates) – but that’s how they perceive the system and as the result of an indirect contamination (like a virus) – as do we.

2. Reality

Okay so my industry is writing and design. This is my reality. What problems come from my reality? 2.1 Access to research material, 2.2 Online distractions – while simultaneously requiring the consistent access to the internet – for research, for backing up documents, for writing this blog, answering crucial emails and messages. 2.3 Staying motivated to keep writing every day without a human being who understands my process reminding me and consistently inspiring me – like McKee’s book did or like my tutors in all years of the college where I earned my creative writing degree and all of my tutors at my first college in Television, Theatre and Radio. This is more interesting to me – I see alot of problems that could be opportunities for innovation. But a solution needs to be simple and invent-able using existing technology.

3. Values

I hear this alot. If you come up with an innovation and you haven’t talked to your target market, you are cutting yourself off at the knees, because you don’t know what your user wants. On the other hand as a writer, I am my user. As an artist I don’t pander to my audience – because that’s the first caveat in the creator’s code. This paradox could itself be a problem i.e. an opportunity.

4. Rhythm

Here, I’m reminded of my first section – economics. Daily/weekly/monthly life rhythms are interrupted by things that we tend to bear the attitude of ‘just get over it’. It’s part of life and we accept that there are things that we don’t like, but who are we to change them? Well, we are the innovators, so we are exactly the correct people who should be charged with changing them. So what rhythms in my life are interrupted? The business of other people walking in and out of my life – this is a distraction as much as it is a positive one. ‘Just get over it’. Okay, fine. But what if I don’t. What if I come up with a simple solution using existing technology that allows me to stay connected and close with my people, yet still have enough time devoted to focus on quality writing and design, without demanding that my others accept (which they would never do, and I would never ask) my routine? What if there was a solution that would solve this perfectly? My first thought is a man shed. My second thought is a tiny home in a foreign city or a town in the mountains (or a cabin in the woods – not a Drew Goddard one.) My third thought is something like the Saent (google it, a crowd-funded system for turning off distractions on the computer. Apparently it works, but I found the software-version far too simplistic.) 2020 now and someone has come up with the Freewrite Traveller – a perfect solution to my problem. So too late on this one. Doesn’t mean I can’t invent a different solution that’s works in a different way and has strengths/effects that apply to the overall problem in different ways.

I think that one thing will happen alot when attempting to innovate; the problem you are trying to solve has already been solved. But perhaps it isn’t as effective as you think you could make it, maybe you could create an improvement. Or just move on to the next problem.

Categories
business

early notes on intro to entrepreneurship

Capitalising on:

1. Unexpected Success

2. Unexpected Failure

3. Unexpected Outside Events

So my big idea is to find a solution to my design problem. I have a design idea but it has no form. The design is a 36-page document describing a narrative for an interactive house.

1. I have recently tested my knowledge-base against others in my field and I found I had proficiency in python, which I’ve only recently started learning. This could be called an unexpected success. This success has motivated me to continue learning python and to also learn Javascript and game engines.

2. I also found that I had novice-level knowledge in both Adobe Photoshop and Javascript, both of which I’ve spent some time with. In fact, I took a course in Photoshop and have been using it to create cartoon artworks for the past five years. From this I have decided to train up in Photoshop, technical drawing and Javascript. And to also study product design, game art, film production design and imagineering.

3. I don’t see many opportunities in outside events. Climate change and the boost in sustainable design? The wane in crowdfunding as people begin to realise how saturated the market is? The recent increase in awareness and positive messages about mental illness? The fact that one of the people I look up to as a person of authority in the literature field (a usually conservative organisation – the business suits side of writing) has come out as transgender?

And even if any of these things are significant – in what way could I capitalise on these opportunities and also how would that affect my entrepreneurial focus, or would it at all?

Categories
coding

pseudocode assignment

The assignment was to adapt the guessing game to reverse the process,

by allowing the player to choose the number and let the computer try to guess it,

then to write this game as pseudocode.

Let me know how well you think I did?

declare variables

import random

def start

Print “guess cannot be higher than 50”

if number >50 then print “you cheated”:break

input (low)”what is the lowest possible number your guess could be?”
input (high)”what is the highest possible number your guess could be?”
computer chooses a random number between low and high
check to see if it is the number
elif check to see if the number is too low
if so numscale=low
elif check to see if the number is too high
if so numscale=high

def new method
if the number is too low tell computer the guess is too low
if the number is too high tell the computer the guess is too high
is this the first time guessing?

if the guess is too low and this is the first time guess=guess+2
if the guess is too high and this is the first time guess=guess-2
if the guess is too low and this is not the first time guess=guess+1
if the guess is too low and this is not the first time guess=guess-1
print guess
guessCount=guessCount+1
goto start

Categories
coding python

first time coding in python on ios: Guess My Number (rated M: language)

So I used python 3 for ios on my ipad to do part one of this assignment.

Part One: create a guess my number game:

numSpecial = 0

time = 0

guesses = 0

g = 0

i = 0

import random

numSpecial= random.randint(1,9)

print (“guess my nmber, biatch! between 1 and 10”)

while g!= numSpecial:

    time = time + 1

    if time > 5:

        print (“you took too long, loser”)

    elif g > numSpecial:

        print (“too high, shithead”)

        guesses = guesses + 1

    elif g < numSpecial:

        print (“too low, asshole”)

        guesses = guesses + 1

    elif guesses > 10:

        print (“I have had enough of your shit”)

    else:

        print (“you found an error”)

    g = int(input(“what is your guess?”))

    if g == numSpecial:

        print (“you guessed right, you are not as stupid as I thought.”)

        i = input ()

Part Two: figure out where in the program the computer recognises time and place a time limit on the game.

And no it doesn’t have an ending because I haven’t covered ending a program in the text yet.

Categories
coding python

still tinkering with Python

Q: assignment that flips a coin 100 times and gives you the total amount of heads and tails.

A: I started by making it flip a coin 5 times so I could easily watch it working and fix bugs.

I don’t think it actually flips the coin exactly 100 times, can you spot the error?

It took me an hour to get it to work:

import random
def variables ():
    heads = 0
    tails = 0
    coinCount = 0
    againPlay = “y”
   
def game():
    heads = 0
    tails = 0
    againPlay = “y”
    coinCount = 1
    while coinCount > 0:
        if againPlay != “y”:
            print (“you had “, heads, “heads.”)
            print (” and “, tails, “tails.”)
            end = input (“You’re all done now!”)
        nmCoin = random.randrange(2)
        if coinCount > 100: againPlay = “n”
        if nmCoin == 1:
           heads = heads + 1
           coinCount = coinCount + 1
        elif nmCoin == 0:
           tails = tails + 1
           coinCount = coinCount + 1
        else:
            print (“you had “, heads, “heads.”)
            print (” and “, tails, “tails.”)
            end = input (“You’re all done now!”)
    
variables ()
game ()
 

Categories
coding python

my 1st program in Python

I wrote my first program (not including the false start last time I attempted programming) in Python… and it works! after a few bug fixes it’s actually quite small and some would think insignificant.

But I’m getting used to the syntax and form of the language.

print (“hello”)

print (“nwhat are your 2 favourite foods of all time?”)

food1 = input (“nt1.”)

food2 = input (“nt2.”)

print (“I have made “,food2+food1,” for you!”)

input (“press a key to exit and enjoy your meal :)”)

Categories
coding python

my 2nd program in Python

tip15 = 0
tip20 = 0
price = input (“how much did your meal cost?”)
tip15 = int (price) * .15
tip20 = int (price) * .2
print (“A 20% tip would be “,tip20,” and a 15% tip would be”,tip15)
input ()

I wrote a tipper program for an exercise.
It’s a simple program and it took 20mins to write including several bug fixes,
where I had to go back to looking through the textbook and a few glances at my first program,
before I got it running properly. I made the usual noob mistakes – since I’ve tackled many different languages, I had to figure out if I needed to declare variables.
I also got the variable on the wrong side of the equals sign, then I forgot to include commas in my print statement for the variables. I also forgot to state that the variable was an integer. Finally, I forgot to use brackets and then incorrectly included the calculation inside the brackets.
Eventually, I figured all of this out and came up with the above seemingly simple program.
And it works!

I’m still not using comments, but I’ll fix that when I start writing longer programs.

Categories
coding python

an early coding exercise #1

carPrice = input (“what is the base price of the car?”)

tax = int (carPrice) * .125
insurance = 250
totalcarPrice = int (carPrice) + int (insurance) + int (tax)

print (“total cost of your car including: insurance $”,insurance,”,”)
print (“and tax: $”,tax,” comes to $”,totalcarPrice)
input ()

This is a program that figures out all your extra costs, when buying a car.

The only mistake I still need to figure out, is what the escape clause is for avoiding having a space at the end of a statement inside a print function.

It works fine, the user enters the base cost for the car.

Program calculates the tax and adds a previously decided insurance cost.

Then the program provides the user with both the individual costs, and the total all-inclusive price of the car.

EDIT:
After some research not in-book, it turns out that you can avoid the white spaces in between statements by using the function sep = “”, which should be treated as a variable – so not inside the quotation marks of the print function, rather, naked inside the brackets.

So the final program now looks like this:

carPrice = input (“what is the base price of the car?”)

tax = int (carPrice) * .125
insurance = 250
totalcarPrice = int (carPrice) + int (insurance) + int (tax)

print (“total cost of your car including: insurance $”,insurance,”,”, sep = “”)
print (“and tax: $”,tax,” comes to $”,totalcarPrice, sep = “”)

input ()

Categories
coding python

a fortune cookie program

So it took one day to write and bug fix.

Then another day to go through guesswork and figuring it out – to get the program to work.

I haven’t got up to while loops in the book, so it took a while – a few errors before I got it working.

And I certainly haven’t got as far as def methods, so using them was difficult and problematic. But I wanted my program to be complete with an exit option.

import random
    
def end_game():
    end_message = (“game over”)
    print (end_message)
    
def game():
    againPlay = “y”
    while againPlay == “y”:
        nmCookie = random.randrange(5)   
        begin = input (“cookie time, open your fortune cookie”)
        if nmCookie < 1:
            print (“you are going to die someday”)
            againPlay = input (“Still hungry”)
        elif nmCookie == 1:
            print (“you just ate a cookie”)
            againPlay = input (“Still hungry”)
        elif nmCookie == 2:
            print (“you are going to eat another cookie”)
            againPlay = input (“Still hungry”)
        elif nmCookie == 3:
            print (“you like cookies”)
            againPlay = input (“Still hungry”)
        elif nmCookie == 4:
            print (“you will have a gargantuan legacy”)
            againPlay = input (“Still hungry”)
        else: end_game()


game ()
end_game ()