tynation.com

Monday, January 30, 2012

Back to programming!

Alright. After a little hiatus, I've decided to once again delve into Python. Armed with a book titled Learning Python by Mark Lutz I am determined to create a program that will help you cheat at scrabble.


What I want this program to do is take the letters of all the tiles you have as well as the letters from any playable tile on the board and compare them against the scrabble dictionary. It will use all possible letters from the former category and only one letter from the latter, unless they are grouped together. I might even find fancy ways to make it so you can indicate spaces between letters so you can fill in those really complicated areas.


However we're starting small. Tonight I created a simple script that tells you how long a word and separates the letters of that word.



print "Insert a word"
wordInput = raw_input()
wordLength = len(wordInput)
wordChar = 1
print "Your word is", wordLength, "letters long."
while ( wordChar <= wordLength):
     print wordInput[wordChar-1]
     wordChar = wordChar + 1

Simple stuff right?

Friday, October 14, 2011

Interviewed

So the interview today went pretty well. The job that was described sounded like something I would really enjoy.


However if that doesn't happen the guys at By-Dzign seem to have full time work for me. Things are definitely looking up.


— Ty

Too long since an update

It has been a while since I updated this and my website. Unfortunately while I wasn't able to keep anything worthwhile for my portfolio from Off The Wall Signs, I did get plenty of excellent experience and a company to put on my resume. Speaking of my resume I updated that so it's current.


However I was able to update my commercial artwork section with a small web project that I did. It was a group project, and I didn't some parts from my project, but I think it has a really nice looking layout to it. Pretty clean and easy to read.


So we're back to the job searching grind. I'm hoping to land my next job before Jan 1, 2012. And as of yesterday those chances are looking pretty good. I actually have a job interview at 2pm today.


One more thing, I'm trying to go cold turkey from Reddit. It's great and all, but it disappoints too often. But most importantly it won't distract me when I should be working. If this was a writing blog I might muse on for a bit on how strange the phrase "cold turkey" is, but it's job/job search related blog so I'll keep my musings to myself, or maybe set up another blog sometime, but I digress, this is not the time!


That's all for now


— Ty

Thursday, June 2, 2011

Just a code for work.

So today (and yesterday) I found myself converting numbers for a 1" to 1' scale. Finding out how many feet there was was easy. For every 1" there was 1'. Then I was left with measurements like 5.2356" So I just wrote down that. I got tired of using the calculator to do these conversions so I wrote a little program for it.



num = 1
inches = 0
while (num != 0):
     print "enter number after decimal point or 0 to quit"
     num = input()
     if (num > 9999):
          print "use fewer numbers"
     elif (num > 999):
          num = num * .0001
     elif (num > 99):
          num = num * .001
     elif (num > 9):
          num = num * .01
     elif (num > 0):
          num = num * .1
     inches = num * 12
     print inches, "inches"

This worked decently. I didnt have to enter a decimal for anything and it converted the number with as few keystrokes as possible. But there was a problem. When I had .0901 inches the program crashed. Luckily I could actually enter ".0901" and it would convert that just fine. I call that an unintended feature


I dont know how good my builders are good at math but 3.276" is very difficult to translate into the widely used half, quarter, eighth, etc units for inch fractions. So I decided that when I had some time I would work a little bit harder and create something that made my life even easier still.



def startup():
     print " _____________________Inch To Foot Scale____________________"
     print "|This program will convert measurements in a 1\" to 1' scale|"
     print "| Just input value in inches (complete with decimal points) |"
     print "|_______________________Input 0 to quit_____________________|"
     print " "
     print "enter value to be converted"
     print " "


def fracFinder(frac):
     sixFourth = .015625
     fraction = "error"
     if (frac < 3 * sixFourth):
          fraction = '1/32"'
     elif (frac < 5 * sixFourth):
          fraction = '1/16"'
     elif (frac < 7 * sixFourth):
          fraction = '3/32"'
     elif (frac < 9 * sixFourth):
          fraction = '1/8"'
     elif (frac < 11 * sixFourth):
          fraction = '5/32"'
     elif (frac < 13 * sixFourth):
          fraction = '3/16"'
     elif (frac < 15 * sixFourth):
          fraction = '7/32"'
     elif (frac < 17 * sixFourth):
          fraction = '1/4"'
     elif (frac < 19 * sixFourth):
          fraction = '9/32"'
     elif (frac < 21 * sixFourth):
          fraction = '5/16"'
     elif (frac < 23 * sixFourth):
          fraction = '11/32"'
     elif (frac < 25 * sixFourth):
          fraction = '3/8"'
     elif (frac < 27 * sixFourth):
          fraction = '13/32"'
     elif (frac < 29 * sixFourth):
          fraction = '7/16"'
     elif (frac < 31 * sixFourth):
          fraction = '15/32"'
     elif (frac < 33 * sixFourth):
          fraction = '1/2"'
     elif (frac < 35 * sixFourth):
          fraction = '17/32"'
     elif (frac < 37 * sixFourth):
          fraction = '9/16"'
     elif (frac < 39 * sixFourth):
          fraction = '19/32"'
     elif (frac < 41 * sixFourth):
          fraction = '5/8"'
     elif (frac < 43 * sixFourth):
          fraction = '21/32"'
     elif (frac < 45 * sixFourth):
          fraction = '11/16"'
     elif (frac < 47 * sixFourth):
          fraction = '23/32"'
     elif (frac < 49 * sixFourth):
          fraction = '3/4"'
     elif (frac < 51 * sixFourth):
          fraction = '25/32"'
     elif (frac < 53 * sixFourth):
          fraction = '13/16"'
     elif (frac < 55 * sixFourth):
          fraction = '27/32"'
     elif (frac < 57 * sixFourth):
          fraction = '7/8"'
     elif (frac < 59 * sixFourth):
          fraction = '29/32"'
     elif (frac < 61 * sixFourth):
          fraction = '15/16"'
     else:
          fraction = '31/32"'
     return fraction
entry = 1
feet = 0
inches = 0
frac = 0
entryInt = 0
entryDecimal = 0
inchesInt = 0
inchesDecimal = 0
startup()
while (entry != 0):
     entry = input()
     entryInt = int(entry)
     entryDecimal = entry - entryInt
     inches = entryDecimal * 12
     inchesInt = int(inches)
     inchesDecimal = inches - inchesInt
     print entryInt, "'", inchesInt, fracFinder(inchesDecimal)
     print " "
     print "enter value to be converted"
     print " "

A little bit of design, a little bit of function, and a lot of usefulness. I actually had to look up the int() function, but boy was it useful in creating this program. now this will actually take an input of inches on my scale drawing, and kick out actual feet measurements down to the 32nd of an inch. ex: 2 ' 3 1/2"


Not even truly a programmer, yet I've already found myself writing a program of great use for me at work.


Now if I only knew how to create a tool in Illustrator that made a line segment, did this calculation, and displayed it near said line segment. Then I'd be making some cash! Perhaps I should continue learning programming...


-Ty

Tuesday, May 31, 2011

Psychology tricks

So in lieu of a post regarding classes or anything relevant I've saved up some of these nifty psychology tricks that anyone reading might be interested in using. Most of these were posted on Reddit, so the veracity of these may be indeterminate. Anyway here we go. (For some reason my blockquote tags don't work. So pretend everything is indented)


My boss has used this trick for years and until recently it got me every single time without me really paying attention. I'll come in to his office to talk about something and if it's too busy, he'll get up and walk out as he's talking with you. You feel compelled to follow him, of course. He walks to your desk and you feel compelled to sit back down. Then he walks away. You suddenly realize how you've been manipulated and feel stupid.


Placing an item in someones hand. If a customer isn't able to make up their minds, place an item in there hands, say one, maybe two good things about it, and they'll buy it. It is exceedingly rare for them to put it back down in this instance.


If you want to get information out of strangers:


  • get them off guard, and try to put them in a position of assumed superiority. Dressing a little shabbily, or just wearing one really stupid/ugly article of clothing helps.

  • appearing confused helps. Appearing tired helps. Think Colombo.

  • if you're trying to get information about a person, imply familiarity. Don't ask a stranger what they know about Robert, ask if they've heard from Bobby.

  • don't offer any explanation about why you want this information, unless they ask you. More often than not, they will offer their own explanation that you can just agree with.

  • don't be afraid to cold-call. Surprisingly, people will talk to you more often than not. Want to know something about someone? Knock on his neighbour's door. You will be surprised how much neighbors know about each other, and how willing they are to share that information.

To defuse situations of potential conflict:


  • increasing usual personal space by 50% not only keeps you out of punching range, it reduces perceived threat to the other party.

  • assume a non threatening stance. Lean against a wall, slouch a little, fold your arms, etc. (make sure you're at a safe distance, though). The idea is to appear calm and relaxed, not timid.

  • if you're dealing with someone who is a bully or rager, they are used to getting their way by implying threat- by being physically imposing, by yelling, etc. Those behaviors are designed to make you either be afraid or fight back. By doing neither you confuse the bully and short-circuit the behavior.

  • lower your voice to quieter than normal levels.

  • if an angry and agitated person suddenly becomes calm, they are probably about to take a swing.

always give someone a way out of a disagreement, letting them save face.


Co-worker obviously screwed up somehow and you want to bring it up to him:


"Hey Jim. These numbers don't really seem correct. Could you go over them really quick or maybe check to see that you sent me the right version of the excel file? The latest copy might've gotten lost in my inbox during the after-Christmas rush."


I learned to use that long ago when I was the designated trainer in a four-star kitchen. I'd see the trainee doing something retarded, and instead of shouting out, "What the hell are you doing?" like most chefs would I would say something like, "I've never seen someone do it like that before. It's kind of interesting, but have you ever tried it like this? I find that it's faster and simpler." Worked every time. Instead of resenting me they were thankful for the lesson.


You can get a lot of information out of someone by just being silent.
Creating an 'awkward' silence will make people want to say something to fill it up, even if it is something they'd rather not talk about. I believe Doctors sometimes use this to make people get into detail about their problems.


If you're having a conversation with someone and you're unsure whether they're into it, you can make a change in the way you're communicating (either with body language or a slight change in accent, etc.). If they start mirroring your change (cross their arms shortly after you do), you can assume that they're enjoying the conversation and listening to you. It's crazy how often it happens and you just don't notice it.
You can feign interest as well by intentionally mirroring their behavior to build rapport and encourage their interest in the conversation itself.


Any time you encounter a dinner moment that feels awkward, just ask a ton of questions about their life. They will think you're extremely charismatic when all you've done is make them talk about themselves. Never ask a yes/no question, because that just adds to the awkward.


"so, how did you get into this profession? "tell me about your family." "What's your favorite part living here? What's the hardest part of traveling?" or, the best "I'm sure you've got a lot of great stories because of that!"


I will ask the person I am talking to about themselves. That is the one topic everyone is each their own expert on. It is an instant conversation booster and the act of listening will make you more friends than talking in my experience


Even better trick, ask about their kids. The coldest people will turn to mush and open up about their kids like a fire hydrant. Works every time.


Saying someones name will 1) help you remember it and 2) make that person like you just a little bit more. People love hearing their own names.


People love hearing their own names. Pronounced correctly


I'm awful with names. "Sorry, how do you spell your name again?" works wonders.
When I can't remember someone's name at all:


Me: "I'm sorry what was your name again?"


Him: (looking a little hurt) "It's John."


Me: "No, sorry, I meant your last name."


Him: (friendly smile) "Oh! It's Smith."


People never seem upset if you can't remember their last name, so long as you know the first.


People also hear there names better than any other word in their native/non native language. The reason for this is because it is so high up in their lexicon, it take very little priming for them to experience the stimulus. This is also why People will sometimes think you said their name, when in reality you didn't. For more information on this, look up Top Down Processing, and Cognitive Psych as a whole.


  1. I try to smile whenever I make eye contact with someone, and especially if it's someone that I don't particularly like/doesn't particularly like me. 99% of the time they will smile back at me. If you do this enough, your smile will actually be genuine, but this might not work if you have a really creepy smile.

  2. If someone is attracted to you, their eyes naturally open up more when they first see you. I either look for this in someone I am interested in or use it myself to (again) make someone who doesn't like me subconsciously feel less hostile towards me.
    When you're in a group and everyone is laughing, take note of who is looking at you, that person is attracted to you. This works as long as you had nothing to do with what is making everyone laugh. If you're just a bystander to the joke and the girl/guy/whoever looks at you while you're all laughing, then you know that you have an admirer. Try it out next time you're in a group of people.

If you're unsure if someone is staring at you, look away from them and feign a big yawn. If they're paying attention to you they'll likely do the same.


If someone tells you something, but can't tell you details (in other words, it's a secret), wait a while and then bring it up again, but act like you can't remember what they told you before. They'll gladly help you fill in the gaps in your memory, which will include stuff they didn't tell you before.


While in the Air Force, a detective told me if I ever had to interview a witness, to wear a light blue or pastel colored shirt since the light colors are calming to the eye and you do not appear as though you are a threat or an authority figure. To this day, I always wear a light blue shirt to job interviews and performance reviews and have not had a bad review yet.


If you want someone to do some moderately big favor for you, ask them to do something even bigger that they'll almost always say no to. Then ask them to do the smaller favor, and since they feel guilty for saying no to the big one, they're more likely to say yes.


One of the tricks we learned is that, during an interview, if you want someone to keep talking, just smile and nod. Silence makes an interviewee feel awkward and so they'll just keep saying stuff, way longer than they normally would. It's great for when you want to get a lot of quotes for an article.


Another trick is, if you're doing a story involving numbers (like budgetary stuff), highballing a figure so that the other person will give you the maximum as a correction to your more dramatic guess, rather than giving you a range that affords them more wiggle room. You can also do the same thing in reverse if you want a minimum figure.


if you're at a table or something and you say "hey we should go do random thing etc" you need to be the first one to stand up otherwise nobody will get up.


There are certain kinds of people (e.g. police, "authority figures") who are really really inflexible and try to stop you bending stupid rules even slightly.


They don't really care about the rules, they just want you to be right and for you to obey them. So if you want to get your way, instead of arguing about how stupid the rule is, say something like "Of course you are right, I did not know that -- thanks for telling me, next time I will obey the rule."


When confronted by unknown persons on the street, initiating a screaming argument with a streetlight will usually difuse the situation.


However, I learned by working in retail that if I mimic the local accent when talking to a customer, they are generally kinder and more receptive to whatever I'm saying.


Here's a great one for cops that's worked surprisingly well for me in the past. If you are pulled over, when the cop walks up to you, initiate the conversation by asking "How are you today?" They have to answer something like "doing well" or "I'm ok, how are you?". Immediately you have broken their defensive wall. I've gotten out of many tickets by getting on the cop's good side before he has even engaged me!


That or if you're pulled over for something minor but you've done something incredibly exciting that day get enthusiastic about it. I had just left a Hurricanes game and had an out headlight and was speeding a bit and the cop asked where I was headed. "I'm headed home after the canes game" oh how was it... Door opened to me being super excited.


In my social psychology class, I learned that if someone doesn't like you, ask to borrow their pencil. Barely anyone will refuse a simple gesture like this, and from now on they'll like you more.


Whenever you're trying to round up co-workers to join you for lunch, you'll invariably be asked "So, who's going?" Whatever you say, the typical reply will be something along the lines of "if so-and-so is going, then I'll go".


Try this instead: to each co-worker you come across for lunch invitation, say "we're all leaving for lunch at ; wanna join us?".


If you need to get hold of somebody via telephone, but you get their voice mail instead, there's a trick you can use that will always get them to call you back. It's sleazy, but it works 100% of the time.


Call them, leave the voice mail. In the message tell them you've discovered something important, start describing the important thing, then hang up mid-sentence.


Touching someone lightly (don't get all touchy-feely on them) will make them like you more.


If you give someone an initially negative impression of yourself and you do something nice, they will like you more than they would have if their initial impression of you had been positive. It's very possible to change someone's opinion of you if you fucked up at the beginning.


It also works in reverse though: If you give someone an initially positive impression of yourself and you do something to piss them off, they will dislike you more than they would have if their initial impression of you had been negative.


I do a lot of presenting, and one of my favorite tricks deals with the awkward question-and-answer period after the talk, when people will periodically toss you a hand grenade of a question and expect a good answer. Sometimes I'll know the answer right off, but when I don't, I like to take a second to frame my answer. Thing is, if you do that while staring at the audience or saying, "Uhmmm..." then people tend to discount whatever answer comes next, regardless of how good it might be. So my secret is to time it so that as the person wraps up the question, I'm taking a big drink of water, or popping a breath mint, or taking a bite of food (lunch-and-learn talks). It's socially acceptable not to talk with your mouth full, so everyone gives you those seconds to think without noticing that's what you've done. As a bonus, people often find the timing funny and will chuckle, improving the mood in the room.


to get an answer closer to what you want ask a question with 2 options (e.g. shall we order Chinese or Italian? instead of what do you want to eat?).


If you are trying to hook up with someone compliment their body, face, etc but tell their wardrobe doesn't go with that outfit...


I hope everyone who finds themselves upon this information can find it useful.


-Ty

Tuesday, May 17, 2011

CS110

Today we're learning about using forms. Too bad I don't know any server side scripting, but it is good to actually understand this stuff


Lab


What is the purpose?


In this lab, you will practice building forms.


What are the steps?


• Task 1:


Procedure:


1. Write the XHTML to create a text box named username that will be used to accept the user name of Web page visitors. The text box should allow a maximum of 30 characters to be entered.


2. Demonstrate your code in a Web page.


• Task 2:


Procedure:


1. Write the XHTML to create a group of radio buttons that Web site visitors can check to vote for their favorite day of the week.


2. Demonstrate your code in a Web page.


• Task 3:


Procedure:


1. Write the XHTML to create a select list that asks Web site visitors to select their favorite social networking Web site.


2. Demonstrate your code in a Web page.


• Task 4:


Procedure:


1. Write the XHTML to create a fieldset and legend with the text “Shipping Address” around the following form controls: AddressLine1, AddressLine2, City, State, ZIP


2. Demonstrate your code in a Web page.


• Task 5:


Procedure:


1. Write the XHTML to configure an image called signup.gif as an image button on a form.


2. Demonstrate your code in a Web page.


• Task 6:


Procedure:


1. Write the XHTML to configure a hidden form control with the name of userid.


2. Demonstrate your code in a Web page.


Homework



  1. Use type="___________" to configure a button to automatically replace the default values in the fields on a form. Answer: reset

  2. What form element is appropriate for an area that your visitors can use to type in comments about your Web site?

  3. To treat radio buttons as a group, use the same value for the ________ attribute.

  4. What XHTML attribute specifies the name and location of the script invoked to process the form values?

  5. What is the default value for the XHTML method attribute?

  6. Use type="_________" to cause a form element to pass its value to the server without displaying in the browser.

  7. What form element is appropriate to use when conducting a survey such as asking visitors to vote for their favorite search engine?

  8. What XHTML attribute limits the number of characters a text box will accept?

  9. What XHTML element associates a text description with a form element

  10. What is the term for a protocol for a Web server to pass a Web page’s request to an application program or script?

  11. Use type="__________" to automatically send the form data to the location on the action attribute when a button is pressed.

  12. What XHTML attribute assigns a "hot" key to a form element?

  13. What form element is appropriate to use when conducting a survey and asking visitors to indicate their favorite browsers?

  14. What form element do you use when you want to conserve screen space but have a list of options to display to your visitors?

  15. What XHTML element describes the choices available in a select list?

Posting the lab and homework here so I can look over them later. Plan on enjoying my birthday tonight


-Ty

Monday, May 16, 2011

IT104

Notes


More on functions this week



def myfunction(var1, var2):
     total = var1 + var2
     print total
myfunction(10,10)

This is a bad way to quote because it's not as usable



def myfunction(var1, var2):
     total = var1 + var2
     return total
print "Your total is", myfunction(10,10)

The function call now holds the value here and can be reused for different values (potentially). Whatever is returned is the value of the function. You can also do math on the function call. print "Your total is", myfunction(10,10) + 50. You can also use a function as an argument for another function.



def myfunction(var1, var2):
     total = var1 + var2
     return total
def mul2(num)
     total = num * 2
     return total
print "Your total is", mul2(myfunction(10,10))

This can be quite powerful.


Lab Assignments


Purpose: Create a program that finds the distance an object will have fallen based on time


def fallingDistance(time):
     distance = 4.8 * time ** 2
     return distance
seconds = 1
while (seconds <= 10):
     if (seconds == 1):
          print "In",seconds,"second the distance fallen will be",fallingDistance(seconds),"meters"
     if (seconds != 1):
          print "In",seconds,"seconds the distance fallen will be",fallingDistance(seconds),"meters"
     seconds = seconds + 1

This program was a straight printing program. No inputs. No fun.


Purpose: Create a program to determine an objects kinetic energy based on user inputs for mass and velocity


def kineticEnergy (mass,velocity):
     kinE = .5 * mass * velocity ** 2
     return kinE
objMass = 0
objVel = 0
print "What is the mass of this object?"
objMass = input()
print "What is the velocity of this object?"
objVel = input()
print "Your object has",kineticEnergy(objMass,objVel),"kinetic energy"

I'm not sure what units kinetic energy is measured in. but kilogram meters squared per seconds to the fourth is a pretty nasty measurement. (I could be mistaken on this)


Homework


Purpose: Create a program that accepts scores for grades and displays their letter grade.


def calcAverage (grade,grades):
     avg = grade / grades
     return avg

def determineGrade(grade):
     if (grade < 60):
          return "F"
     elif (grade < 70):
          return "D"
     elif (grade < 80):
          return "C"
     elif (grade < 90):
          return "B"
     else:
          return "A"

numGrades = 0
cuGrade = 0
graded = 1
newGrade = 0
print "How many grades are there?"
numGrades = input()
while (graded <= numGrades):
     print "Enter grade for test",graded
     newGrade = input()
     cuGrade = cuGrade + newGrade
     print "Test",graded,"earned an",determineGrade(newGrade)
     graded = graded + 1
print "Average grade is",determineGrade(calcAverage(cuGrade,numGrades))

At first I was sticking to 5 inputs for grades. But Mr. Walker wanted me to do a cumulative total for the grade, so I thought about it for a bit and this came up with this.


Extra Credit


I shall post this on May 23


That's all for now


-Ty