The Code Damsel-Blog

What I’m Learning- PHP Constants and Operators

Are you looking to use Constants and Operators in your PHP code? Here is a  collection of some things you will need.

Constants

A constant is something that will not be changed, starts with a letter or _ (no $), and can be used throughout script.

Start here:

define(name, value, case-insensitive)

Name: The name of the constant you are creating

Value: The value of the constant you are creating

Case Insensitive: Default is false (meaning if you want to be case insensitive, don’t fill in this portion)

Unlike strings, constants can be inside or outside functions.


Operators

Perform operations on variables and values (words and numbers) in the following groups:

  • Arithmetic operators
    • Simple math problems
    • <?php
      $x = 10;  
      $y = 6;
      echo $x + $y;
      ?> 
  • Assignment operators
    • using = like “x=y+z”, the x is now equal to the equation
    • <?php
      $x = 20;  
      $x += 100;
      echo $x;
      ?>  
  • Comparison operators
    • are used to compare two values
    •  Got this from W3Schools.com, great site for all languages.
  • Increment/Decrement operators
    • The PHP increment operators are used to increment a variable’s value.

      The PHP decrement operators are used to decrement a variable’s value.

  • Logical operators
  • String operators
  • Array operators

Cheers,

The Code Damsel

 

What I’m Learning – PHP Special String Commands

Below I have string commands that are used in the PHP language that will allow you to find out information or change what is already written!

The following string command will return how many characters are within the string:

<?php
echo strlen(“Hello world!”); // outputs 12
?>

The following string command will return how many words are within the string:

<?php
echo str_word_count(“Hello world!”); // outputs 2
?>

The following string command will return the string written backwards:

<?php
echo strrev(“Hello world!”); // outputs !dlrow olleH
?>

The following string command looks for a specific word, and will return the location within the string. Unless it is not there, then will return “false”:

<?php
echo strpos(“Hello world!”, “world”); // outputs 6
?>

The following string command will replace the first word with the second word, in the third section:

<?php
echo str_replace(“world”, “Monkey”, “Hello world!”); // outputs Hello Monkey!
?>
Hope this was helpful,
The Code Damsel

Staying healthy and sane

I’m not sure about you, but I find it too easy to snack while I’m working on my computer. Every sugary or salty food starts to sound good, and it’s hand to mouth without paying much attention.

How to minimize snacking:

  1. Don’t eat in bed. Honestly keep food out of the bedroom if you can manage. It’s going to minimize cravings.
  2. If you’re hungry, have a glass of water first. This will make sure you’re actually hungry and not just bored.
  3. Eat and digest. You know when thanksgiving comes around, and it’s tradition to eat as fast as you can before your stomach catches up? Ya, don’t do that. If you take a minute to step back and let your body do it’s thing, you may find you’re not actually hungry anymore.

How to reduce stress:

I have notes and lists everywhere. This is both a good and bad thing, I will write the same events on a calendar, in my planner, and on a post-it note to keep track of everything. It’s kinda crazy. Here are some ideas I’m going to try to use to help myself destress:

  1. Realize that not everything in life is perfect. You can strive for perfection as hard as you can, but sometimes it’s unattainable. And what you can do, is good enough. You just may not see it.
  2. Focus on then good 
  3. Take time to do something for yourself. Right now I’m about 2 weeks from the end of my semester at school and finals week, and the projects are building up. Tomorrow, I’m going to take a break and go get my hair cut, because that is something I enjoy. Everything else can wait an hour.

And if we put these together, try not to stress eat. Go for a walk (or a run) and let it all out. You’re body and mind will thank you.

Thanks!

The Code Damsel

Google Maps in HTML

One awesome thing that you can add to your business web site is to show your location on Google Maps. The code that I’m going to show you is very easy to use, and you can find the coordinates for your location on Google.

/*HTML CODE STARTS HERE*/

<div id=”map” style=”width:300px; height:300px; float:left; margin:20; “></div>

<script>
function myMap() {
var mapOptions = {
center: new google.maps.LatLng(48.4799183, -122.6052809),
zoom: 10,
mapTypeId: google.maps.MapTypeId.HYBRID
}
var map = new google.maps.Map(document.getElementById(“map”), mapOptions);
}
</script>
<script src=”https://maps.googleapis.com/maps/api/js?callback=myMap”></script>
*/END HTML CODE*/

My first thought was that this looked like a java script code. And it is, you can see the js in the script src above. But it is already out there, and it searches the internet to load it. So don’t be scared off, it is totally handled on your end by HMTL.

To change the size of the box, just alter the height and width you see in the first line of the code.

The lat and long coordinates look like this: (48.4799183, -122.6052809), all you have to do is type your own coordinates in there.

Well there you go, that is how you add a Google map to your site!

Smiles!

The Code Damsel

Don’t give up coding 

Coding can be the most frustrating path to go down. I know I have started a project, had it close to completion, and had to start all over. There is good and bad news.

The good, you can Google everything. And don’t feel bad that you don’t remember how to code something, coding isn’t about memorization. It’s about solving a puzzle. Well, more like having a 1000 piece puzzle of all white pieces. But you slowly start coloring in the pieces and they make sense.

The bad news is it can take a while to find the right code. Every code out there will take some personalization to make it work for your needs. Sometimes, you won’t be able to find the answer right away. Instead of making you hate yourself by searching for hours, consider an alternative. I didn’t have the skills to make a slider work using java script, HTML, and CSS. And I spent hours trying to make it work. After s couple days, I finally decided I did not need it as much as I thought I did. I changed my direction, and inserted a gallery (see my other post about this) and you know what? It made me happy.

Coding is a special skill because it’s like carpentry or welding, you get to see your creation. Anything you make, is something to be proud of. It takes hard work, and dedication. Let’s say it loud for the people in the back “not just anyone can code”. Many people think making a website off a template is difficult, but they don’t know what goes into doing that. Never give up. You can do it!

Loves from

The Code Damsel

HTML and CSS Gradient

Hey Guys!

Today I am going to talk about backgrounds. These are a struggle for me, trying to figure out what looks good, what looks professional, and what I am actually capable of.

Here is one cool thing that I did figure out: how to do a gradient background.

Notice how along the sides it goes from white to light blue? One way of doing this is creating an image file that is really thin, and then having it repeat over and over and over again. But, I found a better way.


HTML CODE: put <div id= “grad”> in between the header and the body divs

CSS CODE: well, see the following. Each browser has a different way of reading the code written here, and if they don’t like any of them, the browser will resort to the individual color in the top line.

This was honestly a life saver. Not only does it look cool, but the code takes care of everything for you. If you want to change the colors, just switch them out. No need for the extra steps that an image would take.

OH! and do not forget that this will be the background for the whole website unless you say otherwise ( like how I told the body area to be white)

Have a lovely Monday,

The Code Damsel

HTML Gallery or Slideshow?

Lesson 1: Look for what’s not there, and don’t be afraid to move on.

There are many many many coding languages. While I am only working with CSS and HTML right now, I have tried to use Java, and I know there are many more out there. The thing about building a website, all of the code languages tie in together.

If you are looking to insert a slideshow, just know that you will most likely need a Java file for the interactions of the piece. I spent hours trying to edit a slide show, with code in each of my language files, and I was getting no where. I finally reached a point where I said this is not working any more, and I decided to delete the code that I had been working on for days. But that’s what we do: we build, we inspect, and we fix. It’s a cycle. I hope that for you, everything works out perfectly the first time around. But like I said above, do not be afraid to move on from something that isn’t working.

So after I deleted the code, I decided why not have a gallery of pictures instead!

<– This is what my gallery looked like, cool right?

Here’s the code:

/*HTML CODE*/

<div class=”gallery cf”>
<div><img src=”Images/Island Inn.jpg”><p class=”absolute-text”>Ann Marie’s</a> </p></div>
<div><img src=”Images/island.jpg”><p class=”absolute-text”>Island Life</a> </p></div>
<div><img src=”Images/Lake Erie Grocery Store.jpg”><p class=”absolute-text”>Around Town</a> </p></div>
<div><img src=”Images/night.jpg”><p class=”absolute-text”>Anacortes at Night</a> </p></div>
<div><img src=”Images/san juan island ferry.jpg”><p class=”absolute-text”>Ferry to the San Juan’s</a> </p>
</div>
<div><img src=”Images/Deception Pass Bridge.jpg”><p class=”absolute-text”>Deception Pass</a> </p></div>
<div><img src=”Images/park.jpg”><p class=”absolute-text”>Local Parks</a> </p></div>
<div><img src=”Images/rainbor.jpg”><p class=”absolute-text”>Rainbow</a> </p></div>
<div><img src=”Images/sunset.jpg”><p class=”absolute-text”>Sunset</a> </p></div>
<div><img src=”Images/boats.jpg”><p class=”absolute-text”>Cap Sante Marina</a> </p></div>
<div><img src=”Images/water.jpg”><p class=”absolute-text”>View From the Water</a> </p></div>
<div><img src=”Images/rocks.jpg”><p class=”absolute-text”>Rock Hunting</a> </p></div>
</div>

/*CSS CODE*/

/* Start Gallery*/
* {
box-sizing: border-box;
}

.gallery {
width: 600px;
margin: 0 auto;
padding: 5px;
background: #fff;
box-shadow: 0 1px 2px rgba(0,0,0,.3);
}

.gallery > div {
position: relative;
float: left;
padding: 5px;
}

.gallery > div > img {
display: block;
height:100px;
width: 150px;
transition: .1s transform;
transform: translateZ(0); /* hack */
}

.gallery > div:hover {
z-index: 1;
}

.gallery > div:hover > img {
transform: scale(3,3);
transition: .3s transform;
}

.cf:before, .cf:after {
display: table;
content: “”;
line-height: 0;
}

.cf:after {
clear: both;
}
/*text on images*/
.relative{position:relative; width:200px;}
.absolute-text{
position:absolute;
top:0;
font-size:12px;
font-family:”vedana”;
background:rgba(251,251,251,0.4);
padding:5px 5px;
width:100%;
text-align:center;
}
.absolute-text a{
font-size:12px;
color:#b92b27;
}

/*END CODE*/

Thankful to whoever created this, sorry I don’t remember where I picked it up from. I will try to be better about that from now on.

To get rid of the text over the images, delete “<p class=”absolute-text”>Ann Marie’s</a> </p>: this part of the code, and the CSS code below /*text on images*/

I used images with a width of 150px and a height of 100px.

Hope you like it, email me with any questions!

The Code Damsel

My Code Story

Hello World, as WordPress likes to say.

You can find my story about why I am about to graduate college at 20 below in another post. Today I am going to talk about how I became interested in coding. (But here’s another picture of me so you can visualize who I am)

About 2 years ago now, my mom started her own massage business after working as a Starbucks barista my whole life (go mom!) and she realized what every new business owner realizes – she needed a website. Being her tech savvy teen, I searched the internet for the cheapest and best option for making a personal website, something that was so easy even I could do it. We put her website on a platform called eHost, and it worked. It was easy like Microsoft Word, and we only had to drag and drop things where we wanted them.

-see my mom’s massage business here

A few months later my dad purchased an outfitting business in Colorado. The business came with a website, and the previous web designer emailed it to me in a zipped special file. I didn’t know what to do with it, and I learned my lesson. Do not ask professionals that you do not know for help. He charged my dad almost $200 because I asked how to unzip the file. After learning that lesson, I screen shot everything from the previous website (it was still live) and built my dad a site on eHost.

-see my dad’s outfitting business here

I was feeling pretty good about myself, I had created two websites. That was easy. When a family friend, Lisa, posted on Facebook that her web designer was having a baby and she needed to replace him, I jumped at the opportunity.

If you have never worked on a WordPress site before that has been created by a professional, let me tell you it is intimidating. The first night I opened the program, I immediately became overwhelmed. I saw CODE. I did not know how to code at the time. I called Lisa and told her that we needed to change platforms, go back to good ol’ eHost and build her website with templates and drag and drop. Well, instead of listening to me, she called her web designer. I will be forever thankful for her to do that, because he then called me and told me I could do it. All I needed to do was go into the site a little bit, and it wouldn’t be as bad as it seemed. And, he told me I could email him or call him at any time to ask questions. WITHOUT CHARGING ME! Having him behind me gave me the confidence to start working in WordPress and realizing- code is the most interesting thing in the world.

-see Lisa’s website here

Fall Semester 2016 at Montana State University, I took an online digital marketing class. This class went over user experience, SEO, WordPress, and so much more. The class allowed me to dip my toes into the world of code, but I was ready to jump in.

Spring Semester 2017 at Montana State University, I did an independent study for credit based on HTML and CSS coding. My teacher is a guy named Jerry, and the most important thing I have learned this semester is this: it is ok to Google. There is way to much to coding to memorize it all. I built a pretty cool website on Notepad ++ using HTML and CSS (I’ll post pictures here somewhere).

It was the middle of Spring Semester 2017, when Justin from a company called Wise Tail was a guest speaker in my Small Business class. He told us about a program called Montana Code School that would open many doors to companies like his.

I wasn’t going to apply. But I did.

I had my interview, and an hour after it was over I received an acceptance letter ( through email).
So February 2018, I will begin attending the Montana Code School to “jump in” to the code world.

As I learn about Code, I am going to use this blog as a reminder of snippets of code I like, things I want to do again, and lessons that I learn. For the next 30 days I am going to try to post once a day, with some lessons I have learned from my independent study.

Cheers!

The Code Damsel

Learning From an Early Age

Every nail equaled a penny. It may not seem like much, but I was sent 20150527_083957out with my nail bucket whenever my dad took me to his job site. I was a trendy four-year-old, with my miniature tool belt.

The nails that I was sent after were the rejects, or the ones that didn’t make it into the house. They were scattered in the dirt and in between rocks. My job was important, so no one would step on or drive over one of the rejected nails.

As the years went on, I was given jobs with greater responsibility. I was no longer in charge of picking up discarded nails, instead I was in charge of securing hurricane clips. All according to code, in case a hurricane ever hits western Washington.  No longer fitting my miniature tool belt, I was given safety glasses and ear plugs, a paper bag full of nails, and a palm nail-gun.

Starting on the job site as low on the totem pole as I could, and rising up taught me to respect hard work. Hard work requires a determined mindset to finish out a task. Knowing what it feels like to do the mindless task of picking up nails and putting them in a bucket for hours, makes me appreciate the people that complete the little tasks that will usually be unnoticed.

Why I’m a Senior in College at 19

In Washington State, they offer a program called Running Start to students that needed more of a challenge than they were getting. This program allowed me to basically be co-enrolled at Anacortes High School and at Skagit Valley College during my junior and senior years of high school.

June of 2015, I was able to graduate in purple and red, a week apart.

2015-06-08-10-48-05

Anacortes High School graduation- picture with cousin Mitchell

Skagit Graduation

Skagit Valley College Graduation- picture with parents and sister

Attending SVC offered me experiences that I would not have found elsewhere. The school is very diverse and focused on culture. I had people from all demographics in my classes and part of my groups. SVC is focused on offering learning communities to their students, and I took a class that was a mix between Intro to Film and Ethnicity. Having two separate teachers for two classes that had been combined together created a different atmosphere than a regular classroom.

The campus was about 45 minutes away from where I was living at the time, so the experience taught me about time management, responsibility, and perseverance. Some days it would have been much easier to stay home, but I have the type of personality that when I make a commitment I keep it no matter what.

The people that I met were more mature than those that I had attended high school with. It allowed me to be more focused on my school work. A negative that I see about high school, is that most of the assignments the teachers give students are “busy work” assignments  to kill time. Most of the information is not useful in the real world.

At SVC I took a creative writing class and a small group communications class  that really helped me open up to other people. Growing up I was very shy, and now I do not mind talking to other people. I actually enjoy public speaking.

There were many things that SVC offered to me that helped me grow as a person. Grades are important in the short run, but it is the information learned and retained that will be important for the rest of my life.