Categories
Uncategorized

MySQL Alter Locking Tables

I happen to get to work with some decent size data. I don’t know that I would say Big Data because that is a buzz word and I know there are people dealing with MUCH more data than I get to.

However, on the main application I work on, we do have over 2TB of data. With this much data comes a price to pay when you want to make a schema change. Locking tables being the biggest price, as sometimes this will render an application unusable.

There are ways around this sometimes. Percona has some great tools to make altering tables work without locking. It involves a lot of really cool magic, including creating a new table, creating triggers on the old table to populate the new table, and then copying all of the data. Once done, remove the old table and rename the new table. It’s fascinating when you think about the simplicity of it.

However, I still often go old school with a simple ALTER TABLE command. In the past, when I wanted to see the progress that has been made, I simply looked at the files on disk and compared the table being updated’s file size and the temporary table. As the temporary table grew close to the same size, I knew it was done.

Today I learned there was a SQL query you can run. I then modified what was given to me to also include the number left (I don’t know what the number means), and the percentage completed. That final number is the one I am finding most fascinating right now.

I am documenting this here for my future self as I will one day ask what that query was and go digging trying to find it.

SELECT 
    EVENT_NAME, 
    WORK_COMPLETED, 
    WORK_ESTIMATED, 
    WORK_ESTIMATED-WORK_COMPLETED AS REMAINING, 
    WORK_COMPLETED/WORK_ESTIMATED*100 as PercentDone    
FROM 
    performance_schema.events_stages_current
Categories
Personal Opinion

The Day I Learned I Was Racist

Nobody is born racist. It is a learned behavior through family, friends, and media.

Today I am constantly frustrated that people don’t understand what “White Privilege” really is. I am a white male living in the United States who is a beneficiary of white privilege.

So let me start there. Having White Privilege itself doesn’t make you racist. It simply means that you most likely have been able to obtain more, do more, and be hassled less because of the color of your skin. People aren’t mad at you personally. So, if you are white, own the fact that you may have gotten something a little extra out of life that someone else hadn’t. This is the starting point, acknowledge that other people are less privileged. And now let’s figure out what we need to do to fix it.

Now back to my story. I’ve said and done some very stupid things because I didn’t know better. Now I do, and I regret them dearly. I had “friends” that would tell very racist jokes and I’d laugh. I said untrue things like “some of my best friends are black”. Sure, I had black acquaintances, but to say some of my best friends were was just to make me feel better when talking to other people.

The day I learned I was racist is still so ingrained in my brain. I can’t apologize to this woman enough. I worked with a white female friend at a grocery store. She was in an interracial relationship. I had the gall to tell her that “I don’t believe in interracial relationships”. WTF?!?!?!

Why did I say this to her? Goes back to my childhood where my mom would tell me how disappointed she’d be if I brought home a black woman. We are taught biases and beliefs that may not be true. Granted in the 90’s it could have just been my mom trying to protect me from society, but that doesn’t make it right.

Fast forward to my college years where I said those words to my friend and the devastation I saw in her face. How dare I?!?!?! I definitely learned something during that time. I was lucky to also meet my now wife who has the utmost respect for all people and has taught me so much about white privilege, it’s meaning, and is helping us raise two sons that know what racism is and what they should be doing to stop it. To hear my 3 and 5 years olds talking about George Floyd, Breonna Taylor, Ahmaud Aubrey, and others makes me both happy and sad. The fact that they know what is going on and how wrong it is makes me happy. The fact that they know them for what happened to them makes me sad.

While I am not close with the friend I said those words to, I am happy to be friends on Facebook and see that she went on to marry that man, raise a great family and see that she is now a grandmother to a little baby with the same name as my son.

To my “friends/family” that are sharing posts like “All Lives Matter”, “Police Lives Matter”, etc… you are showing your ignorance about what is happening in this world. You are on the wrong side of history.

To my “friends/family” that believe monuments to confederate soldiers is history, why in the hell would you want to idolize the losers of the war. Those are statues of people that were fighting against the United States. You too are on the wrong side of history.

People can change. You can unlearn your biases. But you have to start with admitting that you have White Privilege. You have to start by realizing where our biases are. I am still not perfect, but I’d like to think I am WAY better off today then I was 30 years ago.

Categories
Programmer's Mindset

Jenkin’s Build Pipeline

I watched a great video of a presentation by @adamculp about Jenkins. I have been setting up a Jenkin’s build server for a while, but this thing can be both easy and complicated at times. The video, while great, left me wanting more of the specifics of the setup, not just “look at what this can do”. I wanted, “This is how you do this”.

I reached out to Adam on the twittersphere and he told me which plugins I needed. The one I really wanted was the Build Pipeline Plugin, and when I finally took a second to scroll down on the plugins page, things started to click. Specifically “views”. I hadn’t used them before.

Even with the instructions, I missed the key point. It says to add a new build pipeline view, so I kept clicking on New Item and not finding it. I read a little closer and looked at the picture, and it was clear… Click the “+” to create a new view.

Categories
Blogging

YNAB: You Need A Budget

I have been getting on a soap box a lot lately, and thought I would take a moment to put my words into a blog post. This will be a long post, but I have so much passion for this right now that I have to write it down.

I am terrible with money. I live well, but like most people, at the end of the month, the money is gone and I don’t know where it went.

My wife and I have been saying to each other that we need a budget. She or I would take the first step to start an excel document, load up a bunch of numbers, and then pretend we never saw it. Because we would get so overwhelmed, it just never got completed or looked at.

That is… until I found YNAB. Something in this program made the whole idea of managing money click for me. I don’t know why, or how, it just did. They have fantastic videos on their approach, and do it in a very personable manner.

Of course, you will still not have any money at the end of the month (at first), but I think if you stick with it… that will change.

So my challenge to you. If you are someone that knows me well enough (mostly family), and you want to try You Need A Budget, start your free trial now. You have 35 days to use it. If at the end of 35 days, you are convinced that this is for you, but you truly can not afford the $60, I will buy it for you. (Disclaimer: I have the right to turn down any request for any reason) 😀

Keep your categories simple. Track your major expenses, and if you have a bad habit you want to quit, create a category just for that. Track what you are spending and then make an honest assessment. You will be amazed that when you start budgeting and realize that to pay for that habit, you have to knowingly remove money from savings, that you may just want to stop that habit anyway.

And I like the idea of paying yourself first. Start with a small percentage, say 5%. When you get your check, let’s say it’s $100, first things first, put $5 into your savings category. Yes, you may need to use that, but do it anyway. Then when you are budgeting the rest of your money, you will have to knowingly take the money from that savings line, and put it somewhere else. Again, it’s that act of doing this that makes you aware of your money.

Categories
Programmer's Mindset

Laravel Repository Pattern Experience

I am always trying to learn, and lately I’ve been working on the repository pattern via Laravel.  I found myself WAY overcomplicating this, and it turned into a mess.

With that said, I think I got myself to a very happy point.  All of the examples on the Internet that I have found ultimately return Eloquent models.  Which, if your controller is ONLY accessing the data, is fine.  But I found myself then relying on Eloquent, which defeated the purpose of the repository.

Introducing domain objects.  I was trying so hard to use active record objects, that it ended up causing me issues.  In the end, I want controllers to be very small and ask a domain object for the data it needs to pass back to the requestor (Web visitor, or API consumer).

The domain object is responsible for all logic (not data).  The domain object should interact with the repositories, and ask for data, or send data.

The repositories are only responsible for retrieving data or saving data.  They should return either arrays or plain old php objects (popo), not Eloquent, Mongo, Redis, etc… models.

Controllers ask the domain to DO something.  The domain asks the repositories for data it may need to do said something.  The domain asks the repositories to store some data.

Once I started following these rules, things started making sense to me.

/** @todo: show examples */

Categories
Programmer's Mindset

Asterisk astobj2.c: bad magic number for object 0x7ff6ac021888. Object is likely destroyed.

Recently we had 2 asterisk servers that were segfaulting, and of course when that happened, all current calls were lost.  This was very frustrating for our customers, our customer service reps, and of course for the us developers.  It was very hard to explain, there was not silver bullet saying “X” is responsible.

So, my boss Kevin and I spent time going through log files, analyzing time lines, researching on the Internet, etc…

Our conclusion is still dumbfounding.

We recently added a new outbound sip provider.  We started only giving them a small percentage of our overall traffic.  During this time we saw 0-1 segfaults each day.  But we didn’t even know about some of them because asterisk started right back up, and unless there was a complaint, we wouldn’t know.

Of course we got the occasional complaint, but we didn’t have an answer.  All of a sudden the last couple of days was showing 4-5 segfaults per day.  Some happening within 20 minutes of each other.  This was very unacceptable and we spent a lot of time trying to narrow down the issue.  It so happened that 2 days ago, we ramped up the amount of traffic this new provider was receiving, subsequently increasing the odds of segfaulting.

At this point, we still don’t know what actually caused the segfault.  We just know that removing that carrier has so far stopped them from happening.

Ugggg… what a PITA.

Categories
Bitcoin

Should My Website Accept Bitcoins?

If you own a website that accepts money, you should be asking yourself this question.

To me, this is like asking if you should accept Yen, Euros, or Pesos.  The fact is, you probably already accept these other forms of currency and don’t even realize it.  Payment processors like PayPal or other gateways handle those exchanges for you.  You tell the processor you want $100 for some goods, the customer pays (currently 10172.00) Yen, and you do not know the difference.

Same thing happens with bitcoin.  Through a payment processor like Coinbase, you can easily accept bitcoin payments and immediately turn them into US Dollars.  The processing fees are so much lower as well, roughly 1%.  Compare that to the 3% that credit card processors charge.

Not to mention, the chance of chargebacks are absolutely zero.  Because bitcoin is a push payment, the customer has to choose to send you bitcoin.  You can’t take what you want, like you do with credit cards.

So the answer to “Should my website accept bitcoins?” is absolutely yes.

Categories
Bitcoin

BitCoins: My Opinion

So, I first heard of bitcoins a few years ago and didn’t wrap my head around them at that time.  (STUPID ME)

I decided to learn more about them late last year.  I had lots of questions myself, and hear them from others, so I want to try and answer some of them from my viewpoint.

Questions that confused me:

  • What are they?
    • First, realize that they are not physical coins.  They are digital tokens (for lack of a better word)
    • These “coins” are generated through mathematical algorithms at a predetermined pace, currently 25 about every 10 minutes.
    • Over time, the amount created will be reduced.  Actually, they are cut in half every 4 years.  At the beginning, they were generated at 50 coins every 10 minutes.
  • How are they generated?
    • They are generated through “mining”.  It’s analogous to gold mining.
    • I recently heard a great analogy.  If you play Sudoku, you know that the puzzles can be hard to solve, but very easy to verify.  This is the key, hard to solve, easy to verify.
    • So every 10 minutes (or so), a kind of computer puzzle is generated.  Thousands of computers around the world try to solve it.  The first computer to solve it correctly, receives the prize (currently 25 bitcoins).  As computers get faster, the puzzles are made more difficult, to try and keep the rate at 1 puzzle every 10 minutes.
  • Should I get into mining?
    • As it turns out, the answer is really no.  Most miners are using very high end computer equipment, running specialized hardware for this.
    • If you do, you should participate in a mining pool, so even if you don’t solve the puzzle, you receive a portion of the prize.
  • If I don’t mine, how do I get them?
    • Turns out easily.  Buy them with USD.  Just like you get Japanese Yen, Mexican Pesos, Euros, etc…
    • There is an exchange rate, so you can exchange money for bitcoins
    • Barter or Sell stuff.  Just like other currency, it’s only worth what someone else will give you for it.

If you are a merchant selling good and services, why would you not accept this currency?  The most usual reason is that merchants don’t know what bitcoin is and they are concerned about the exchange rate screwing them up.  The fact is that as a merchant, you may already be dealing with this very issue.  Your payment gateway may accept Japanese Yen from your customer and turn it into US Dollars for you, without you even knowing.  You can do the same with BitCoin.  Coinbase is currently the largest exchange for bitcoin.  You can think of them just like PayPal, but for this new digital currency.

Furthermore, there are more and more businesses accepting bitcoin as a form of payment.  You can find local businesses through coinmap.org if you are interested.  I’ve seen articles from other people that have tried to live solely on bitcoin, and mostly successfully.  There are some obvious restrictions right now, as not everyone will accept them.

Categories
Mobile Programmer's Mindset

AngularJS + Phonegap Works In Browser Not On Device

I was going crazy for the past 2 days trying to get an Angular app running on my phone.  I had it working in Chrome the way I wanted for testing purposes, and just couldn’t get it onto the device.

Basically I would see the index page, but the app would never bootstrap and get going.  I tried with test apps, and it worked fine.  I tried a very basic app with just 2 way binding and that worked.

Solution ended up being not to use absolute urls.  For example <script src=”/js/index.js”></script> does not work.  You must us <script src=”js/index.js”></script>

The reason is that on the device, everything is accessed as a file, so file:///js/index.js does not exist.

Hope this helps someone not spend so damn long looking for an answer like I did.

Categories
Personal Opinion

My Drama Filled Day: How A Bad Remark About My SDPHP Usergroup Set Me Off

I had a bad day on Thursday, here’s why…

Just clearing the air here.  Ranting on my personal website, with views from the way I see them.

So I had some personal business to handle this morning and was gone for half the day.  I get back home and have to get to work done, so I get down to it and work with my boss to launch some new code and do other tasks.

I then find out that this morning there was a ton of drama due to the presentation on Laravel 4 at SDPHP last night.  The presenter Chris A Moore (@CAMDesigns) did an amazing job.  I told him right afterwards that fact, and he did what most presenters do and doubted himself.  There were a lot of questions asked, that for the most part he could handle.  There were a few that he didn’t know, and this bothered him.  I can appreciate wanting to be able to answer them, but it doesn’t always happen that way.

He then followed up with the creator of Laravel (@taylorotwell) to get the other questions answered.  Which is the right thing to do.  However, he made the mistake of saying he was heckled (which he definitely was not), and Taylor proceeded to call our group a “shit user group”.   This group means everything to me and for someone to put it down really offended me (and a bunch of my members).  I took this personally and proceeded to tell my friends… via twitter.

Did I over react?  Maybe…

Chris and I discussed this whole ordeal via IRC and he admitted to having been wrong, and he apologized to the group in IRC.  I appreciated it very much.

However, because I aired this in public on Twitter, I don’t think the drama is over.  And I am sure this post won’t help much….