Seeking Happiness

Quick aside first: if this was shared with you, please know I wrote this for myself and nobody else. Ideally, this is just a thoughtful article to get folks thinking about things in their lives and is worth sharing. That’s what I’m hoping for at least!

Is it just me, or is happiness one of those elusive things… something that comes and goes, or maybe leaves you feeling like you’re coming up short? A roller coaster of highs and lows, or maybe even just something that you never can quite grasp?

I would like to make a slightly bold statement: we all have an imperative to greedily seek out the things that make us happy.

Not to the detriment of ourselves or others – in some cases, service to others is what makes us happy. Simply put, I want us to begin (or continue) the avid pursuit of achieving our own happiness. Let’s face it: nobody is going to find it for you and nobody is going to lay it in your hands.

I mean that with all kindness =]

Plotting a Course

What do we do about this? How do we approach this? The one bit of wisdom I can eke out of this concept (seeking happiness), is that if you’re not where you want to be, if you don’t have the things in life that you want, chances are high you’re going to have to do something you’ve never done before to get there. A fresh approach, taking with you all the learnings of before to achieve something closer than you’ve ever been. The great climb to a genuine smile!

I’m writing this right now because I currently find myself in a situation where I have an infinite of options in front of me, and I’m not sure what the next step is. I’m not quite terrified by this prospect though. I look at it like this: if you find yourself in the middle of the ocean and aren’t sure which way will get you to land, the best course of action is to pick a best guess direction and go.

Is that the best we can do though? Does it all boil down to a good guess, a bit of luck, and maybe even a little good ol’ fashioned gumption? A little bit every day or haymakers until we have to stop to catch our proverbial breath? This is starting to sound like the ultimate showdown of the Turtle Vs. the Hare. Perhaps there’s wisdom there (#UnawarePoet).

Necessity for Adapting

Life at times can feel like it’s nothing but curve balls and monkey wrenches… so expect that! Trials will be had, hurdles appear… the obstacles that we anticipate seem to never happen, and yet what we least expect generally occurs (speaking as a developer – hah! Damn that left field!). So let’s expect that in the course of our lives we have to roll with the punches and adapt.

So that’s it? We plot a course, make a plan, execute it, and adapt as the situation changes? I suppose so… then when we come up short (which is bound to happen – monkey wrench incoming!), we adapt. We rinse and repeat, starting back at step one – plot a new course with all of our learnings from our previous attempts, and press on.

I think the point here is: don’t let a little thing like failure slow you down. When beating your head against the wall doesn’t get you through it, try to find a way around it – or at least find a method that isn’t quite as head-trauma inducing!

What can I say? I’m a caring guy like that =]

Simple Concept, Not Simple

Ugh! You know what though?! That sounds like a lot of work. A lot of heartache. A lot of struggle and pain. A lot of bullshit. But then again, you tell me – are you where you want to be in life? Maybe there is something to be said for finding happiness without finding land — in the middle of that ocean, so to speak. Maybe…

Yet I find myself wanting… friends, family (especially one of my own), connection, a loving relationship, success, happiness, trust, and purpose! I do know where I’m wealthy – my friends and family. I’ve had success and found software development to be my craft of choice – something I’m pretty good at!

Real Talk

Hold the phone! Did I really just confess that what I’m seeking right now is the lady of my dreams? Whoops. Eh… I’m ok with being vulnerable to the entire internet. Pshhh! It’s just the internet! Joking aside – I think we could all be a little more honest with ourselves and each other.

So let’s do this! What is it that you want in life? What steps can you take to get yourself closer to realizing that dream? What’s in your way to getting there now? How can we get there?

I’d like to apply one last parting concept from software development to life. Be forewarned, this one is taken from agile (hey! don’t hate!): whenever you start any endeavor, you’re starting from nothing. Effectively, you’re at your dumbest point! Give yourself the space and a little kindness to muck things up a bit – because you will – and if it’s worth it, you might muck it up a few times before you get there.

Learn from those moments, adjust course, and press on. Rinse and repeat my friends, rinse and repeat!

Lastly…

At the end of the day, I mainly wrote this for myself. Don’t let that stop you if you’re feeling compelled – please throw some comments below! Tell me (and everyone else for that matter) if something here resonated with you! Proclaim the things you seek! Share your plan or your wisdom! Alternatively, you could just enumerate the ways I sound like a looney person or lack solid conclusions in all of this whimsy! All is welcome.

And yes, lastly, I hope you find what you’re looking for – even if it’s just the contentment of being right there in the middle of the sea =]

Helpful Hacky Skyrim Tools

Dragons fly in Skyrim's sky!

Enter the Skyrim Alchemy Sage

Skyrim Alchemists know that potent poisons come in small doses!

Welcome fellow Skyrim alchemists – interested in brewing the most potent of poisons?! The most proverbial of potions?!! The most electrifying of elixers?!!! …perhaps with a touch of alliteration? Hrmph! I have a scroll called the Skyrim Alchemy Helper that will help you craft the finest concoctions – far beyond the skills of mere mortals… In a land where everything’s for sale, this one is free…

Back to Reality

Whew! Ok, now that the RP’er in me has had a chance, the developer in me has a question for you: have you ever been doing something where you just wished you could tie a few things together quickly? Make sense of large amounts of data in no time? Then call me Mr. Rinse & Repeat, ’cause I can’t stop! heh ok… I’ll calm down.

Anyway, as a developer, I have the advantage of being able to put data together and display it in a fashion that makes sense to me. This is a story about one such helper that I made to assist in all my alchemy endeavors in Skyrim – one that I thought I would use as an example (and advertisement) of code that’s good enough for now and why that too can be ok.

The Pain Point of Inspiration

Recently (well, recent to me), Bethesda Game Studios came out with a freshly revamped Skyrim – Special Edition – full of high res textures, bug fixes, and many improvements. Cool! I’ve sunk a few hours in that game, but it’s been a minute and I wouldn’t mind returning to Skyrim to slay some dragons once more!

I get started and it dawns on me: “Geez, I wish I could get back to crafting my alchemy stuff.” I used to have those recipes memorized! What parts for my paralysis poisons? What’s good for restoring health? What’s the other thing I used to craft for those times when I need that thing?!! Blah! It’s too much to get started all over again!

So what’s the solution you might be asking? The new hotness in web frameworks, CI/CD pipelines, and the latest, most feature rich, spanky IDE?! Huh huh huh?!! =D

Hell no! I ain’t got time for that! I made a few hacky scripts to make sure my alchemy prowess was better than ever so I could get back to the game! Pshhh.. what, is this your first rodeo with Skyrim?

Enter the Lazy Dev Sage

So why is this article under filed under “Code”? I realize the quality of the code in these is more or less not ideal… Not a great start for the Code category. Yet, if there’s one thing I know, it’s the tendency of developers (especially jr. devs) to be paralyzed by the quality of their code to the point where progress is painfully slow. This is my effort to say “Heck with it! I need this now!” and to show that even when you write mediocre, unreadable, and/or unmaintainable code… there’s a place for that too.

Going back to one of my favorite rules of the dev process: “Make it work; Make it right; Make it fast”. Right now, we’re at stage 1… I might not ever need to come back to this code, so while it works, it’s fine as it is – and now I can focus on the next task at hand way sooner than perfection would allow for.

Can improvements be made? Hell yes.
Can features be added? Sure – might have to start thinking about the overall architecture if we’re working on this a lot.
Is it fast? Probably not as fast as it could be yet not unbearably slow. Does the trick, I guess *scratches head*.

Resultant Results and a Few Caveats

For now – it IS… which is way better than “it is not”. I think that counts for something too. Sure: take feedback from code reviews with respect and perspective. Sure: this isn’t how you should be writing code for mission critical applications (sidenote: if your mission critical software doesn’t already have a CI/CD pipeline to prevent this – HOW ARE YOU LIVING YOUR LIFE RN?!! IS IT BROKE? ARE YOU SURE? ASK GARY AND MAKE SURE! I DON’T CARE – ASK HIM AGAIN! WELL WAKE HIM UP!!!)

heh. I’m a dork.

…and sure: is this the standard I want all my code to sink to? Nahh… but for what it is – it’s just right and that’s ok.

If Source Code Wore Underpants

As it turns out, I even went as far as to make a script that allows you to look at the files and their source code! Yeesh! What was I thinking?! Eh… I was having fun banging out something I wanted to make and not thinking twice about it.

So, without further adieu, if you’d like to see London and you’d like to see France – here’s the Skyrim Helper Scripts underpants. They’re hacky and look like hell, but it’s way better than having to relearn all the different alchemy recipes from scratch again!

I hope it helps and I hope you enjoy!

Cheers!
Ryan

How I Write Professional Code

Subtitle: and talk about it UNprofessionally

I’ve been writing code for about the last decade and a half. It really wasn’t till I started working on a team of developers that I was pushed to write better, more readable code — a very important lesson. Then, it wasn’t till I started breaking old habits and started writing in a test driven development (or TDD) fashion that I started to write professional code. Continue reading “How I Write Professional Code”

Enabling Hot Corners on a Mac

So you got gotten D=

Here’s how you ensure you can quickly lock your mac to prevent folks from giving your computer a cronjob. Just enable hot corners and ensure that it requires a password to unlock. Here’s how:

Step 1: Enable hotcorners

  1. Go into your system preferences (the apple icon in the top left corner of the screen)
  2. Search for “Hot corners” (or just hot will probably do) which should light up “Desktop & Screensaver” stuff like this:
    Screen Shot 2016-04-12 at 3.33.23 PM
  3. Bonk the “Hot Corners” button in the bottom right corner
    Screen Shot 2016-04-12 at 3.33.45 PM
  4. Select your desired corner (I’m using the bottom left corner) and set it to “Start screensaver”
    Screen Shot 2016-04-12 at 3.34.25 PM
  5. Press OK and we’ll return to the System Settings for the next part

Step 2: Ensure the Screensaver requires a Password

  1. Back in your System Settings, search for “Security & Privacy”
    Screen Shot 2016-04-12 at 3.34.55 PM
  2. Then under the “General” tab, make sure the box is checked and set up to either “Immediately” or within “5 seconds” lock your computer
    Screen Shot 2016-05-16 at 1.21.25 PM
  3. If you encounter trouble modifying any of the options, you may need to unlock your settings. Look in the bottom left corner of the settings window and click the lock. You should be prompted to enter your password. Authoritate yer computer and rock on!
    Screen Shot 2016-05-16 at 1.26.26 PM

How it works

Now that you have hot corners enabled, let’s kick the tires, shall we? Move your mouse to the corner that you selected and it should enable your screensaver. Ensure that when it turns on, that it requires a password to unlock. This is a great way to protect yourself against shenanigans, and a good step to help make sure you aren’t the victim of a USBDriveby D=

…fin!

Unmasking the User in PHP CLI Scripts

Who are you. Whoo whoo. Whoo whoo.

…The Who? Anyone? …Bueller?

So let’s say you need to know what user is running a script in PHP. If you’re like me, you may have tried get_current_user only to find that’s just for the current owner of the file. Well THAT’S deceivingly unhelpful! =\

Wait! Sec. One more moment of gripe: If what get_current_user in php does makes sense to you, I’d like to be the first to ask you: …How?!

Not only did that not help, but I also couldn’t find any solutions or hints in the right direction from the comments in the documentation (generally, I find them to be a good place for a next step). There was one suggesting to using posix functions like this: print_r(posix_getpwuid(posix_geteuid())); — however, no luck! If the user is invoking the script with sudo, we lose all trace of who done it. Also, this is technique can limit who can use it as it’s not uncommon for environments to disable posix_* functions for security.

So, Who Really Done It?!

Ranting aside… the answer to this eluded me! Low and behold, the it was inside of $_SERVER all along. Le sigh. I put together a quick function with a few fallbacks to figure it out. Let me know if this doesn’t work for you, but for me, does the trick in spades =]

I like this solution the best. Not only is this data already in the scope of our script already, but we don’t have to use posix or try crap like echo exec("who am i"); and parsing through that. #winning

Hope that helps someone out there in the ether!

Cheers!
Ryan

Adding Crontabs to your Coworkers Unlocked Computers

What’s a cron?

Alright, what we’re doing here is scheduling a mac to do something for us using cron. Cron is a program that checks to see if there is anything it needs to do every minute. Once something qualifies, it will execute the code it’s given. But what if the code we give it is…… shenaniganalous in nature? Mwah ha ha ha!!! The possibilities are limited only by your imagination =P

In this example, we’re going to make a job that will repeatedly say “nacho nacho nacho” every ten minutes until the end of time. Seem fair? Alright, the schedule when we’re done will look something like this:

Ready. Set. Cron.

Here’s how it works on a mac:

  1. Open up a terminal on the victim’s computer. You can press the F4 key, type in “terminal” and press enter.
  2. Type in “crontab -e” (without quotes) to edit the current cron schedule for the user.
  3. To add the schedule above in Vim, press “i” – the bottom left corner should say -- INSERT --
  4. Paste in the schedule from above. You can change the text to say something else, but whatever you do, do not use exclamation points. It’s syntax in bash and will not work!
  5. Once you have your schedule pasted in and it’s perfectly crafted, press escape, then type “:x” (which you’ll see in the bottom left) and press enter — this will save your new schedule and exit Vim

It will tell you if it fails, otherwise, consider your plan in progress! Quit the terminal and wait.

Cleanup

Alright, so the joke is done, and if anyone hears your victim’s computer say “pee pee” one more time, …no wait it’s still hilarious. Ok, let’s say you want to remove it anyway, right? If they don’t have any crons they need to save, there’s a simple way to do it.

Open up the terminal again and type the following (WARNING: it will clear ALL CRONS on the machine!):

Now, if you’ve come across the rare person who has something in their crontab, you can simply edit their crontab again and remove the magnificent job you added like this:

  1. Open up the terminal and type crontab -e
  2. Using ‘j’ and ‘k’, you can navigate to the line that needs to be removed
  3. Once on the offending line, you can type ‘dd’ (yep, two of em) to delete the entire line
  4. Once the schedule is gone, type “:x” to save and quit vim and you’re set!
  5. Hit cmd+q and close the terminal as if nothing ever happened.
  6. Flex.

What else, Ryan?

…yes! A quick reference for you!

Great question! I’m so glad you asked! There is SO MUCH MORE we can do.

View current cron tasks
crontab -l (that’s an “L” to “List”)
Remove all current scheduled tasks
crontab -r
Schedule to open a google search for nachos every 10 minutes
*/10 * * * * ( /usr/bin/open "https://www.google.com/webhp?#q=nachos" )
…hey I get it. Sometimes, you just need some nachos.

More fun with Say

Say comes with a lot of different options… have a look using man say in your terminal to see the manual. Now when you look at this, if you have any questions on how to use some of these options, you can ask!

For instance, let’s say I’d like to use a different voice… but I don’t know which ones I can use. Ask yer mac like this: say -v ?

This will give us a massive list of voices to choose from. Now you can switch up your command to do things like:

The above schedule, on exactly the 14th minute of the hour, will creepily whisper “I can see you”.

Conclusion

Here we’ve explored three tools (crontab, say, and open) that in coordination can help you mess with unlocked computers. I give you this knowledge knowing full well it could be used against me……… but then again, I lock my computer =P

One or many

So, I get that there are probably better ways to handle this circumstance, but when working with legacy code, sometimes, it’s not up to you. I had a method that would be called with either one thing, or an array of these things. Approaching a context like this, the solution we came up with was (what I think is an) amazingly simple way to ensure if you’re sometimes receiving one thing or an array of things, you can handle both.

Check it out:

There it is. And now hopefully I’ll remember this better next time I need something quick.

Cheers!
Ryan

Blog Spammer Shootin’ Match

The Stage

For some reason….. this blog — THIS blog! …..gets a crap ton of spam. So I went looking. I figured I’d share the bulk of what I found.


Yep. If you’re getting crazy spam, watch out for China, obama, and nofollow. They. Will. Destroy. Your. Sanity.

The Apology

If you legitimately are trying to comment and noted something about any of the three mentioned above, I owe you an apology. I’m sorry I shot your comment in the spam box with glee and a special kind of whimsy.

Looking at the Data, Again!

I kinda enjoy using this as a psuedo “comment honeypot” because it’s just so darn entertaining. Here are some other fun ways to look at your comment spam:

By number of comments posted per IP:

Original IP’s censored b/c I don’t wanna be a jerk to anyone but the guy at 123.45.67.89!

By my patented, foolproof, never wrong Offender Rating System®:

Again, original IP’s censored b/c I don’t wanna be a jerk to anyone but the guy at 123.45.67.89!

…fin!

Wasn’t that fun?! =D

Don’t spam me, bro!