Archive for the ‘ Uncategorized ’ Category

Installing MySQL on MacOS with Homebrew

I was trying to install MySQL on MacOS and I followed the instructions to install it via Homebrew:

$ brew install mysql

Pretty easy, but then as I worked along I screwed something up where I could not load mysql in the command line. I would get the following error:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

So I do the logical step of uninstalling and reinstalling:

$ brew uninstall mysql
$ brew install mysql

I still get the same error. Two hours of browsing StackOverflow later, I figured it out. I failed to notice the following errors during reinstallation:

2019-02-21T01:02:48.455076Z 0 [System] [MY-013169] [Server] /usr/local/Cellar/mysql/8.0.15/bin/mysqld (mysqld 8.0.15) initializing of server in progress as process 18070
2019-02-21T01:02:48.457920Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2019-02-21T01:02:48.457929Z 0 [ERROR] [MY-013236] [Server] Newly created data directory /usr/local/var/mysql/ is unusable. You can safely remove it.
2019-02-21T01:02:48.457994Z 0 [ERROR] [MY-010119] [Server] Aborting
2019-02-21T01:02:48.458203Z 0 [System] [MY-010910] [Server] /usr/local/Cellar/mysql/8.0.15/bin/mysqld: Shutdown complete (mysqld 8.0.15) Homebrew.

This is the key line:
Newly created data directory /usr/local/var/mysql/ is unusable. You can safely remove it.

What do I do? Remove that directory!

$ sudo rm -rf /usr/local/var/mysql/

Then run the post install script:

$ brew postinstall mysql

And voilà, mysql loads!

$ mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.15 Homebrew

Learn from my fail.

Advertisements

Android: Dialog Box with an EditText

A simple code snippet I found over at http://www.androidsnippets.com/, shows how to create a dialog box with an EditText in it. I needed it to save a user’s login name into the preferences when first starting a program, but it pretty much has a limitless amount of uses

AlertDialog.Builder alert = new AlertDialog.Builder(this);

alert.setTitle("Title");
alert.setMessage("Message");

// Set an EditText view to get user input 
final EditText input = new EditText(this);
alert.setView(input);

alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
  String value = input.getText();
  // Do something with value!
  }
});

alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
  public void onClick(DialogInterface dialog, int whichButton) {
    // Canceled.
  }
});

alert.show();

-Kevin Grant

What is an immutable array? What does immutable mean in coding?

I got an email from rapleaf.com about some coding questions. Pretty much they are looking to hire some new people and are using these questions to generate interest / find candidates. The full list can be found here, but one question in particular I got lost in terminology slightly.

Imagine we have an immutable array of size N which we know to be filled with integers ranging from 0 to N-2, inclusive.

Did I learn about immutable in college? Maybe. Do I remember it? Certainly not. I googled for a few minutes, figured it out. As per usual, stackoverflow is a great place for answers.

A mutable object is simply an object that can be modified after it’s created/instantiated, vs an immutable object that cannot be modified.

source

So that’s what the keyword is, hope you learned something!

-Kevin Grant

Mobile AP 3.0 teaser…

-Kevin Grant

Services and notifications, just what you always wanted!

So have you ever wondered how to get a cool notification to show up in your app for something? Or have you ever wanted to know what a “service” in android was, or just something as simple as seeing some basic, example, skeleton code with some intuitive comments and variable names? Well, thats what I have produced for you! Some of this was copied from the Android site, some of this was created by some friends of mine, but all in all, its very basic stuff.

Download the code here. Just create a new project based off of this file and go nuts! The screenshots below show what it should generally look like when you run it!

Services are a great way to add some background processing to your applications. Services can almost be thought of as an Activity (which is what normal android programs are) but without a user interface. This means everything it does is in the background! Have a background service that sends a text message to your friend every 10 minutes, or have a service that creates a toast every 15 minutes to remind you how awesome you really are. This skeleton code gives you the framework to do just that!

If you found this example helpful, or would like to share how you utilized this in your own programs, post in the comments below, can’t wait to hear!

-Kevin Grant

I wanna be an engineer, so frickin’ bad

You said it brother.

New Stats!

We’ve been slacking here.  We apologize.  There is no excuse for this insubordinance.  This week look forward to our details of our experiences participating in the “Facebook Hackers Cup”, tutorials on Java Callback Functions, Services, Notifications, and Alarms!  There’s so much we want to share, bear with us while we try to document it all!

In the meantime, I would like to share our current app stats for Milestone 2 with you!

Category Total Change
Total app downloads (1/21/2011) 40,498 (+19,458)
Avg user rating 3.67 stars (205 / 379 5-star ratings) (-.06)
Avg downloads / day since last milestone 540.5 (+346.5)
Avg downloads / day since launch (144 days) 281.2 (+137.2)
Avg income / day $.79 USD (+.79)

If you want to see how we’ve been progressing, check out our stats from Milestone 1.

If you haven’t seen our new app portal, check out phamous-apps.com.

Thank you everyone who has purchased Golden AP, your donations are immensely appreciated and we look forward to keep delivering you awesome apps throughout the rest of 2011.

-Kevin Grant

Advertisements