I'm finally getting around to trying out a few different libraries that claim to make testing Android apps easier. First up is Robolectric.
For this quick walkthrough, I'm going to show how to start from scratch. You'll need no prior knowledge except for how to make a regular Android app.
In my GitHub repo: How to get started with Robolectric
~ Danial Goodwin ~
Showing posts with label easy. Show all posts
Showing posts with label easy. Show all posts
2015-03-02
2015-02-12
Level Up - Web Dev: How to get started with Polymer
Polymer:
The purpose of this article is to provide the basic information needed for the easiest way to get started with Polymer, including downloading creating a custom Polymer element, and reusing other elements. This article probably could have been split into three separate smaller ones, but I'm opting for a single page that can be used as a "cheat sheet". Most of this information is from the official site, but the difference is that this is shorter guide with many deletions, a few additions, and different organization.
1. There are a few different ways to get Polymer, but the easiest is with Bower, which is a package and dependency manager for many web libraries. So, install Bower if you don't already have it.
2. Create a new directory for your web project, then run `bower init` in it using a console. There will be a few questions, in which you can just press Enter if you don't know what to do yet. This initialization just produces a `bower.json` file, which has settings that can easily be changed later.
3. Install Polymer for the project by running `bower install --save Polymer/polymer`. This will create and fill a new directory `bower_components` with Polymer and its dependencies. Using `--save` will update the `bower.json` file by listing Polymer as a dependency. (Sidenote: To update the components in bower_components, just run `bower update`.)
Now, you can use Polymer in your project. See the section on [How To Create A Polyment Element] for a quick walkthrough on getting a simple app working.
1. Create a new file called `my-element.html` and add the following code. Make sure the import is pointing to the valid location within the bower_components directory that was created in the previous walkthrough.
2. Use your element in `index.html`. Here's a minimal example. Note: The above `my-elements.html` was put in an `elements` directory for some organization.
3. Run the app from a web server so that the [HTML Imports](https://www.polymer-project.org/platform/html-imports.html) work correctly. For example, to run on localhost instead of remote, if you have Python 2, then you can run `python -m SimpleHTTPServer`. If you have Python 3, then you can run `python -m http.server`.
Notes about Polymer elements:
1. Install the element for your web project, for example: `bower install --save Polymer/core-ajax`. The `--save` flag is used to add that element as a dependency to the `bower.json` file. After the optional `save`, the pattern is `/`. The element will be installed to the `bower_components` directory.
2. Use that element in your layout or custom element. An import statement must also be included, for example, to edit the custom `my-element` created in the last section:
3. Run the project and enjoy how easy it is to create modular web apps and site now. If you don't see anything on the page, then make sure that all your imports are pointing to the correct place.
The best way I've found to learn about using new elements is to see the demos and look at the source code for the ones that you like.
There's plenty more details that I haven't included in this article because they weren't vital to the setup process. So, if you have any questions, the official Polymer website is a great resource or I'll be happy to try to answer any questions.
:)
~ Danial Goodwin ~
- A wrapper with syntactic sugar for the new HTML WebComponents W3C spec.
- Allows easy modularization and reuse of HTML/CSS/JS code.
- Creates more readable source files.
- Being actively developed by Google.
The purpose of this article is to provide the basic information needed for the easiest way to get started with Polymer, including downloading creating a custom Polymer element, and reusing other elements. This article probably could have been split into three separate smaller ones, but I'm opting for a single page that can be used as a "cheat sheet". Most of this information is from the official site, but the difference is that this is shorter guide with many deletions, a few additions, and different organization.
Getting Started For The First Time
This is a quick walkthrough for how to get started with Polymer from scratch.1. There are a few different ways to get Polymer, but the easiest is with Bower, which is a package and dependency manager for many web libraries. So, install Bower if you don't already have it.
2. Create a new directory for your web project, then run `bower init` in it using a console. There will be a few questions, in which you can just press Enter if you don't know what to do yet. This initialization just produces a `bower.json` file, which has settings that can easily be changed later.
3. Install Polymer for the project by running `bower install --save Polymer/polymer`. This will create and fill a new directory `bower_components` with Polymer and its dependencies. Using `--save` will update the `bower.json` file by listing Polymer as a dependency. (Sidenote: To update the components in bower_components, just run `bower update`.)
Now, you can use Polymer in your project. See the section on [How To Create A Polyment Element] for a quick walkthrough on getting a simple app working.
How To Create A Polymer Element
In this quick walkthrough, you'll create and implement a simple Polymer element called `my-element`.1. Create a new file called `my-element.html` and add the following code. Make sure the import is pointing to the valid location within the bower_components directory that was created in the previous walkthrough.
2. Use your element in `index.html`. Here's a minimal example. Note: The above `my-elements.html` was put in an `elements` directory for some organization.
3. Run the app from a web server so that the [HTML Imports](https://www.polymer-project.org/platform/html-imports.html) work correctly. For example, to run on localhost instead of remote, if you have Python 2, then you can run `python -m SimpleHTTPServer`. If you have Python 3, then you can run `python -m http.server`.
Notes about Polymer elements:
- The name of the element must have at least one dash `-` in it. (Reason: It's part of the web component spec as to not interfere with official HTML tags.)
- The `noscript` attribute used in the above sample code indicates that it's a simple element with no script, which allows it to be registered automatically.
How To Reuse Other Polymer Elements
First, find some elements with Bower by running `bower search Polymer`. This will show most of the elements that the Polymer team as created. For a curated list of custom elements, check out customelements.io/. For a scrape of GitHub of all the projects that mention "web component", see Component Kitchen. These instructions work for both Polymer elements and regular web components as long as they are registered with Bower, otherwise they'll have to be installed manually.1. Install the element for your web project, for example: `bower install --save Polymer/core-ajax`. The `--save` flag is used to add that element as a dependency to the `bower.json` file. After the optional `save`, the pattern is `
2. Use that element in your layout or custom element. An import statement must also be included, for example, to edit the custom `my-element` created in the last section:
3. Run the project and enjoy how easy it is to create modular web apps and site now. If you don't see anything on the page, then make sure that all your imports are pointing to the correct place.
The best way I've found to learn about using new elements is to see the demos and look at the source code for the ones that you like.
There's plenty more details that I haven't included in this article because they weren't vital to the setup process. So, if you have any questions, the official Polymer website is a great resource or I'll be happy to try to answer any questions.
:)
~ Danial Goodwin ~
2015-01-18
Level Up - Blogger: How to add formatted code to post (with highlighting)
In many of my posts, I like to add code snippets. Blogger doesn't have good native support for displaying code with syntax and line highlighting, so I found a way to add that feature using GitHub Gists and gist-embed project on GitHub.
The following steps can mostly be used with any blog.
Step 1: Include jQuery and gist-embed within your header tags.
Step 2: Add a code element to where you want your Gist code to appear.
Example:
Source:
Nice features also included, but not shown above:
This article was mainly written for myself in the future, but I hope others can benefit from it, as well.
Links:
~ Danial Goodwin ~
The following steps can mostly be used with any blog.
Step 1: Include jQuery and gist-embed within your header tags.
<head> ... <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/gist-embed/2.0/gist-embed.min.js"></script> </head>
Step 2: Add a code element to where you want your Gist code to appear.
<code data-gist-id="" ></code>
Example:
Source:
<code data-gist-file="PrimeNumbers.cpp" data-gist-hide-footer="true" data-gist-highlight-line="9,12,35-42" data-gist-id="5789439"></code>
Nice features also included, but not shown above:
- Ability to show GitHub footer
- Remove line numbers
- Load multiple files from a Gist
- Load a signal file from a Gist
- Show only certain lines from a file
This article was mainly written for myself in the future, but I hope others can benefit from it, as well.
Links:
~ Danial Goodwin ~
2015-01-17
Level Up - Android Dev: How to get started with AndroidAnnotations (easy) (and build Chuck Norris app)
AndroidAnnotations is an open source framework for Android. Basically, you provide Java annotations for things, and the framework will auto-generate the necessary boilerplate code so you don't have to write it yourself. Runs at compile-time! (Read: No reflection or startup time impact) And, there's a lot of code AndroidAnnotations saves you from writing manually.
For example, want to run something in a background thread? Annotate the method with `@Background`. Want to run something in the main/UI thread? (rub some bacon on it) Annotate the method with `@UiThread`.
In this article, I provide a quick walkthrough for creating a very simple Chuck Norris facts app. I'll assume that you already have basic Android knowledge (and using Android Studio + Gradle). Then, at the end, I'll explain in more details some issues/gotchas I ran into while using AndroidAnnotations for the first time, and mention other goodies.
Getting started..
For example, want to run something in a background thread? Annotate the method with `@Background`. Want to run something in the main/UI thread? (rub some bacon on it) Annotate the method with `@UiThread`.
In this article, I provide a quick walkthrough for creating a very simple Chuck Norris facts app. I'll assume that you already have basic Android knowledge (and using Android Studio + Gradle). Then, at the end, I'll explain in more details some issues/gotchas I ran into while using AndroidAnnotations for the first time, and mention other goodies.
Getting started..
2014-12-06
Level Up - Android Dev: The default emulator is horrendously slow, use Genymotion!
Many years back when I built and published my first Android apps, I only tested them on the default emulator provided by Google. And, even now, the default emulator is still too slow for my liking. It doesn't allow me to properly test apps. So, I purchased physical devices so that I would never have to touch the Android emulator again.
Genymotion provides a different take on the Android emulator. I've known about it for at least a year, but never got around to trying it because of my really bad experience with the default emulator. I've always heard that it was much faster than Google's implementation, but I didn't think an Android emulator could ever be fast enough for me compared to my physical devices.
I'm always learning something new, and today was finally time for me to learn more about Genymotion and test just how much better it is.
Results: Excellent! So much of a great experience that I had to write this blog post about it! I should have tried Genymotion when I first heard about it, and this is my message to all Android devs to also try it out now!
Sidenote: I was going to compare the default emulator with the Genymotion emulator side-by-side, but it was taking too long to load for me, whereas Genymotion startup was a breeze of fresh air. It runs without any lag. It runs faster than my old API 17 device.
Another great benefit is that Genymotion provides system images for many of the most popular devices, including Samsung Galaxy, Samsung Note, HTC One, Nexus, and more. And, they have a very convenient plugin for Android Studio to launch the emulator.
TLDR: It's fast. I have to make sure I stress that because I didn't believe how fast it would be. Genymotion's Android emulator is much faster and better experience than the default Android emulator.
Here, I even saved enough time to write a quick walkthrough for getting started. ;)
Genymotion provides a different take on the Android emulator. I've known about it for at least a year, but never got around to trying it because of my really bad experience with the default emulator. I've always heard that it was much faster than Google's implementation, but I didn't think an Android emulator could ever be fast enough for me compared to my physical devices.
I'm always learning something new, and today was finally time for me to learn more about Genymotion and test just how much better it is.
Results: Excellent! So much of a great experience that I had to write this blog post about it! I should have tried Genymotion when I first heard about it, and this is my message to all Android devs to also try it out now!
Sidenote: I was going to compare the default emulator with the Genymotion emulator side-by-side, but it was taking too long to load for me, whereas Genymotion startup was a breeze of fresh air. It runs without any lag. It runs faster than my old API 17 device.
Another great benefit is that Genymotion provides system images for many of the most popular devices, including Samsung Galaxy, Samsung Note, HTC One, Nexus, and more. And, they have a very convenient plugin for Android Studio to launch the emulator.
TLDR: It's fast. I have to make sure I stress that because I didn't believe how fast it would be. Genymotion's Android emulator is much faster and better experience than the default Android emulator.
Here, I even saved enough time to write a quick walkthrough for getting started. ;)
- Go to Genymotion.com, click "Get Genymotion".
- Download the free version, you'll have to sign up and confirm your email. (It's quick and it's worth it!)
- Install it along with VirtualBox. For Windows users, they can bundle the two together in the download. For other, you'll have to install VirtualBox separately.
- If you try to run it now, you might get an error that says "genymotion virtualization engine not found. Unable to load VirtualBox engine". So, just restart your computer and that fixed it for me. Some others had to enable the virtualization feature in the BIOS.
- Run! Fast!
- Now, you can click run in Android Studio and you will see an option to load the app in the Genymotion emulator that is running.
Bonus: How to Install the Genymotion Plugin for Android Studio (and, the first time you click on the installed plugin button, you'll have to add the path to where you installed it. Windows default is "C:\Program Files\Genymobile\Genymotion". Mac default is "/Applications/Genymotion.app")
~ Danial Goodwin ~
2014-11-17
Level Up - Android: How to Flash (Upgrade) Nexus 4 to Android Lollipop 5.0 (Easy)
If you have a Nexus 4, then you can have Android Lollipop now! Google recently released the factory image, and I'm now successfully running it (with root, which will be explained in a later post).
This will be a short walk-through because I assume you already have the tools needed, but just need the steps to get the flash done. If you have any questions, then please write a comment and I will update as necessary.
Congrats! When the script is done, it will reboot your device and Lollipop will be running. It may take a bit for it to boot the first time.
More info: There sure is a lot more information you could read about this entire process, but that's not what this post is for. These are the minimal instructions (with appropriate warning) for most people wanting to do this. If anybody has some good resources to share, then please add them to the comments.
Now, are you ready to root your Nexus 4?
:)
~ Danial Goodwin ~
![]() |
| Nexus 4 running Android Lollipop 5.0 |
- Download Android Lollipop 5.0 factory image: https://developers.google.com/android/nexus/images#occam
- Uncompress the file, possibly twice. I used 7-zip. You should see six files there, including a zip, which you do not have to unzip.
- Make sure `adb` is in your PATH environment variable, which can be found in %android-sdk%/platform-tools/. Also, you will need `fastboot.exe` from that same folder in your PATH. (I assume you already have the Android SDK and you know what I mean by "Advanced system settings"->Environment Variables->PATH.)
- Connect your Nexus 4 device to computer, then run `adb reboot-bootloader` in your computer's terminal. This will bring your device to the "fastboot" mode.
- At the very bottom-left, you should be able to see whether your bootloader is locked or unlocked. It must be unlocked to flash a new system image. If unlocked, you're good, go to the next step. If locked, then run `fastboot oem unlock`. WARNING: Unlocking will erase all data.
- Open your computer's terminal to where you downloaded and uncompressed the files, and run `flash-all`. That command will run the "flash-all.bat" script which will setup the new system image for you!
Congrats! When the script is done, it will reboot your device and Lollipop will be running. It may take a bit for it to boot the first time.
More info: There sure is a lot more information you could read about this entire process, but that's not what this post is for. These are the minimal instructions (with appropriate warning) for most people wanting to do this. If anybody has some good resources to share, then please add them to the comments.
Now, are you ready to root your Nexus 4?
:)
~ Danial Goodwin ~
2014-08-18
Level Up - Android: How to get started with Unit Testing in Android Studio
Recently, I finally got around to implementing the native unit testing that is provided within Android Studio (not third-party programs like Robolectric). So, after reading a few different sources, the following is the bare minimum that I would have needed in order to add the basic testing features.
2014-08-13
Level Up - Android: How to get started with Android Wear and the Wearables Emulator
Recently, I started working on Android Wear for the first time. It's been fun playing around with the new platform and form factor. And, of course, the official Android docs that I read could be condensed further for absolute newcomers. So, in the typical fashion, I've created myself a cheat sheet that I would use next time I would want to learn the easiest way for how to best create Wearable apps.
I've open sourced all my code so far on GitHub. It includes how to first set up the virtual Wear device, connect to the handheld device, and how to have the app send and open a notification on the wearable.
https://github.com/danialgoodwin/android-wear
~ Danial Goodwin ~
I've open sourced all my code so far on GitHub. It includes how to first set up the virtual Wear device, connect to the handheld device, and how to have the app send and open a notification on the wearable.
https://github.com/danialgoodwin/android-wear
~ Danial Goodwin ~
2014-03-10
Learned Experience
Many things learned are useful in other aspects of life.
Recently, I have learned a lot about business taxes and now personal taxes are so much easier to tackle. And, reading the IRS publications aren't that bad anymore. Prior to doing all of the business taxes research, I thought the IRS website and publications were overly complicated. Now, I consider each pub to be light reading even though they are small font, three columns per page, and typically around 5-40 pages.
I feel good.
~ Danial Goodwin ~
Recently, I have learned a lot about business taxes and now personal taxes are so much easier to tackle. And, reading the IRS publications aren't that bad anymore. Prior to doing all of the business taxes research, I thought the IRS website and publications were overly complicated. Now, I consider each pub to be light reading even though they are small font, three columns per page, and typically around 5-40 pages.
I feel good.
~ Danial Goodwin ~
2014-03-03
Level Up - Business: How To File the Annual Report (Florida)
When you run a business in Florida, you must submit an Annual Report every year between January 1st and May 1st. It will cost $138.75 to file. And, if not filed in time, then there is a $400 penalty fee and possibility that the company is "administratively dissolved". But, the good news is that the report is easy to fill out and submit, and it's all done online.
When you complete the form online, you'll be able to edit your business address and member(s) address(es). Then you don't need to file a separate form for changing the addresses with the state (an extra $25).
First thing is, you don't need to spend any extra money for a third-party to complete this state requirement for you. They may charge upwards of $35 to complete the form that is easily completed within five minutes.
To complete your Annual Report:
1. You will need, your business's document number, Federal Employer Identification (FEI/FEIN) or Employer Identification Number (EIN), an email address to keep on file, and about five minutes.
2. Go to https://services.sunbiz.org/Filings/AnnualReport/FilingStart
3. Start the form by imputing your document number, then read the directions on the page. It is all straight-forward.
4. Pay the filing fee and submit. Now, you are done.
Disclaimer: This is not legal advice. This post is mainly a pointer to help others who also need to Annual Report for Florida. I'm sure other states in the US also have a page similar to the one linked here.
~ Danial Goodwin ~
When you complete the form online, you'll be able to edit your business address and member(s) address(es). Then you don't need to file a separate form for changing the addresses with the state (an extra $25).
First thing is, you don't need to spend any extra money for a third-party to complete this state requirement for you. They may charge upwards of $35 to complete the form that is easily completed within five minutes.
To complete your Annual Report:
1. You will need, your business's document number, Federal Employer Identification (FEI/FEIN) or Employer Identification Number (EIN), an email address to keep on file, and about five minutes.
2. Go to https://services.sunbiz.org/Filings/AnnualReport/FilingStart
3. Start the form by imputing your document number, then read the directions on the page. It is all straight-forward.
4. Pay the filing fee and submit. Now, you are done.
Disclaimer: This is not legal advice. This post is mainly a pointer to help others who also need to Annual Report for Florida. I'm sure other states in the US also have a page similar to the one linked here.
~ Danial Goodwin ~
2014-02-27
Level Up - Android Dev: How To Automatically Extract Hardcoded Strings To res/values/strings.xml
This is just one of the many refactoring features of Eclipse. Using this extract feature, you won't even need to open res/values/strings.xml to add the String resources nor manually write out reference to the resource.
This saves a lot of time, and allows the best practice of putting String constants away from the UI/Java files so that localization can be performed easier. This method I'm about to show you is especially productive because it can change all instances of that particular String to point to the xml string resource so that you don't have to do it individually one-by-one. (I'm doing maintenance on code that has everything hardcoded, so this is a lifesaver.)
To automatically extract the String, it's easy enough:
Step 1: Highlight the entire String that you would like extracted and sent to res/values*/strings.xml
Step 2: From the menu bar, select Refactor->Android->"Extract Android String..."
Step 3: Preview options and confirm changes.
This works in the XML and Java files for your Android application. And, this is much quicker than manually changing all instances of hardcoded Strings to getString() and @string/.
~ Danial Goodwin ~
This saves a lot of time, and allows the best practice of putting String constants away from the UI/Java files so that localization can be performed easier. This method I'm about to show you is especially productive because it can change all instances of that particular String to point to the xml string resource so that you don't have to do it individually one-by-one. (I'm doing maintenance on code that has everything hardcoded, so this is a lifesaver.)
To automatically extract the String, it's easy enough:
Step 1: Highlight the entire String that you would like extracted and sent to res/values*/strings.xml
Step 2: From the menu bar, select Refactor->Android->"Extract Android String..."
Step 3: Preview options and confirm changes.
![]() |
| Step 2: Automatically extracting string menu option. |
![]() |
| Step 3: Many different great refactoring options to choose from. |
This works in the XML and Java files for your Android application. And, this is much quicker than manually changing all instances of hardcoded Strings to getString() and @string/.
~ Danial Goodwin ~
2014-02-25
Level Up - Webmaster: How To Get Started With MediaWiki
Want to create your own wiki pages like Wikipedia? You can organize all your thoughts, add notes for your new book you want to write, and more. The wiki can be either public, private, or half and half. You decide.
Going through this process will allow you to edit any and all features that are provided with MediaWiki, the wiki engine for Wikipedia and many other wiki sites.
Step 1. Download MediaWiki, it might be as a .tar.gz file, which in that use 7-Zip to unzip the compressed file, you may have to use 7-Zip twice to fully open it and see the source files.
Step 2. Copy all the files to a directly on your domain.com/mediawiki/w/ directory. One of the easiest ways is using FileZilla, navigating to the public directory using the GUI, then click+drag all the files into the directory. Note: The reason I said that particular directory is because it will allow you to do a lot more later on, like setup the domain.com/wiki site to serve the pages in your wiki. As you wait for all your files to upload to your server,
Step 3. Create a new database and user for that database. This is the method that the MediaWiki instance will be using to save and retrieve all the information for your wiki.
Step 4. Wait until all the files have finished uploading to your domain.com/mediawiki/w/ directory, then navigate to that page in a browser. It'll say LocalSettings.php file not found, so this is where you will use a wizard to setup all the properties of your site, like public/private and more. Each of these properties can always be changed later. I recommend reading through all of them to understand better what is available to you.
Step 5. After going through the entire wiki, the wizard will prompt you to download the LocalSettings.php file which you can then add to the same folder that you previously installed all the files in.
Step 6. In a browser, navigate to your domain.com/mediawiki/w/ and see that you have your main default page show. Congrats, you now have an instance of MediaWiki running on your own server.
If you run into any problems during this process, you can click on the little question marks in the wizard to pop up more information of a section or input area. Another great source of information is on the official install page.
~ Danial Goodwin ~
Going through this process will allow you to edit any and all features that are provided with MediaWiki, the wiki engine for Wikipedia and many other wiki sites.
Step 1. Download MediaWiki, it might be as a .tar.gz file, which in that use 7-Zip to unzip the compressed file, you may have to use 7-Zip twice to fully open it and see the source files.
Step 2. Copy all the files to a directly on your domain.com/mediawiki/w/ directory. One of the easiest ways is using FileZilla, navigating to the public directory using the GUI, then click+drag all the files into the directory. Note: The reason I said that particular directory is because it will allow you to do a lot more later on, like setup the domain.com/wiki site to serve the pages in your wiki. As you wait for all your files to upload to your server,
Step 3. Create a new database and user for that database. This is the method that the MediaWiki instance will be using to save and retrieve all the information for your wiki.
Step 4. Wait until all the files have finished uploading to your domain.com/mediawiki/w/ directory, then navigate to that page in a browser. It'll say LocalSettings.php file not found, so this is where you will use a wizard to setup all the properties of your site, like public/private and more. Each of these properties can always be changed later. I recommend reading through all of them to understand better what is available to you.
Step 5. After going through the entire wiki, the wizard will prompt you to download the LocalSettings.php file which you can then add to the same folder that you previously installed all the files in.
Step 6. In a browser, navigate to your domain.com/mediawiki/w/ and see that you have your main default page show. Congrats, you now have an instance of MediaWiki running on your own server.
If you run into any problems during this process, you can click on the little question marks in the wizard to pop up more information of a section or input area. Another great source of information is on the official install page.
~ Danial Goodwin ~
2014-02-19
Level Up - Webmaster: How To Randomly Redirect Visitors To Different Websites
There is a very simple method using PHP to have visitors automatically redirected to another site.
Why this is useful:
- User clicks "Take me to a random" page. You can finely-tune the random outcome.
- You are doing some A/B testing and want to sent users to different locations to test.
- Or, like me, you want to share your various websites/games, from a single button.
Try clicking
Ex: http://apps.simplyadvanced.net/windows8/redirect
Step 1: Here's all the PHP code that you need:
Step 2: Done
Or, if you want to redirect the visitor after they visit a certain URL on your domain, then simply create an "index.php" file in the public directory that you want users to be redirected from, then the above code is all that you need to put in it.
Try it: Random Windows 8 Games created by me.
Try it: Random Windows Phone Games created by me.
~ Danial Goodwin ~
Why this is useful:
- User clicks "Take me to a random" page. You can finely-tune the random outcome.
- You are doing some A/B testing and want to sent users to different locations to test.
- Or, like me, you want to share your various websites/games, from a single button.
Try clicking
Ex: http://apps.simplyadvanced.net/windows8/redirect
Step 1: Here's all the PHP code that you need:
$urls = array("siteA.com",
"siteB.com",
"www.example.com"); $url = $urls[array_rand($urls)]; header("Location: http://$url"); ?>
Step 2: Done
Or, if you want to redirect the visitor after they visit a certain URL on your domain, then simply create an "index.php" file in the public directory that you want users to be redirected from, then the above code is all that you need to put in it.
Try it: Random Windows 8 Games created by me.
Try it: Random Windows Phone Games created by me.
~ Danial Goodwin ~
2014-02-17
Level Up - Programmer: How To Quickly Setup And Use Git And GitHub
A long time ago, the first time I started trying to learn Git and GitHub, I thought it was an unnecessarily complex process. All I wanted was simple version control and easy collaboration. So, instead of learning Git, I just made everything really modular. For one of my teams, we even just worked in completely different files, and it worked out okay.
But, now, I want to explain the absolute basics on how to start, in order to drastically reduce the learning curve. You can always find more detailed information later. And, you can get started right now!
Assumptions:
- You already know what Git is.
- You are running Windows OS.
- You already have folder/file(s) in mind for added a version control system to or want to do easy collaboration on code projects.
- You want to get started with GitHub.
- You are okay with basic instructions meant for the easiest use of Git/GitHub.
Git
Step 1: Download Git.
- Make sure you have "Git Bash" to be installed also, and you can add it to your [right-click] contextual menu also during the install process. (And/or you can add Git to your Path.)
Step 2: Configure Git.
- Open Git Bash (either right-click in file explorer or find it through search)
- Type the following two lines into the console, and change the red parts to your own information:
Step 3: Setup project to work with Git.
- Navigate (using cd) the console to the directory where you want to enable Git.
- Run the following lines to setup the folder to work with Git and "save" all the files in the directory.
And, now you have version control. Just do those last two lines again whenever you want to save a new version. Change the red part to something descriptive of the change.
GitHub
Step 4: Create a GitHub account.
- If this is your first time using GitHub, you will need to create an SSH key. After entering the following, hit enter again to save to default location (your user folder/.ssh).
- Check for success by running:
Step 5: Create a new repository (sometimes called a "repo")
- Click the big green button somewhere on GitHub that says "New repository"
- Name the repo and create it.
- On the page you are navigated to, find/copy the "SSH clone URL". This will be used in the next step and looks something like, "git@github.com:danialgoodwin/MyFirstRepoNameHere.git"
Step 6: Pull From GitHub, then Push To GitHub.
- Setup the location that you will push to and pull from. The part in red should be substituted with your info from step 5. (The following should all be on one line.)
For more great information and details, please visit:
- Easy Version Control with Git
- Official GitHub site, there should be large buttons wanting to help you further.
~ Danial Goodwin ~
But, now, I want to explain the absolute basics on how to start, in order to drastically reduce the learning curve. You can always find more detailed information later. And, you can get started right now!
Assumptions:
- You already know what Git is.
- You are running Windows OS.
- You already have folder/file(s) in mind for added a version control system to or want to do easy collaboration on code projects.
- You want to get started with GitHub.
- You are okay with basic instructions meant for the easiest use of Git/GitHub.
Git
Step 1: Download Git.
- Make sure you have "Git Bash" to be installed also, and you can add it to your [right-click] contextual menu also during the install process. (And/or you can add Git to your Path.)
Step 2: Configure Git.
- Open Git Bash (either right-click in file explorer or find it through search)
- Type the following two lines into the console, and change the red parts to your own information:
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
Step 3: Setup project to work with Git.
- Navigate (using cd) the console to the directory where you want to enable Git.
- Run the following lines to setup the folder to work with Git and "save" all the files in the directory.
git initgit add .
git commit -m "Initial commit"
And, now you have version control. Just do those last two lines again whenever you want to save a new version. Change the red part to something descriptive of the change.
GitHub
Step 4: Create a GitHub account.
- If this is your first time using GitHub, you will need to create an SSH key. After entering the following, hit enter again to save to default location (your user folder/.ssh).
ssh-keygen -t rsa -C "your@email.com"- The console tells you where the public key has been saved. Open that file in Notepad++ and save the contents to GitHub.com->Profile->Edit Profile->SSH Keys->Add SSH Key. (Each arrow -> is basically another click.)
- Check for success by running:
ssh git@github.com
Step 5: Create a new repository (sometimes called a "repo")
- Click the big green button somewhere on GitHub that says "New repository"
- Name the repo and create it.
- On the page you are navigated to, find/copy the "SSH clone URL". This will be used in the next step and looks something like, "git@github.com:danialgoodwin/MyFirstRepoNameHere.git"
Step 6: Pull From GitHub, then Push To GitHub.
- Setup the location that you will push to and pull from. The part in red should be substituted with your info from step 5. (The following should all be on one line.)
git remote add origin git@github.com:andrew8088/Shazam.git- You always want to "pull" from GitHub before you begin your work because others may have updated the code:
git pull origin master- Now, you can finally update your code to GitHub!
git push origin master
For more great information and details, please visit:
- Easy Version Control with Git
- Official GitHub site, there should be large buttons wanting to help you further.
~ Danial Goodwin ~
2014-02-15
Level Up - Webmaster: How To Shorten Default MediaWiki URL to Short (Canonical) URL Form
This was my first time shortening the URL for MediaWiki to canonical form and it literally took me less than five minutes to fully complete and test. I bet you can do it in two minutes.
Quick and easy directions:
1. Go to MediaWiki ShortURL Builder (Your wiki will have to be temporarily public)
2. Type in your current URL, for me it was " http://danialgoodwin.com/mediawiki/w/"
3. When you click "Go", make sure the article path says "/wiki/$1" or wherever you would like your MediaWiki to appear to users.
4. You now have all the code at your fingertips to place on your server. I used a GUI FTP client (like FileZilla) to transfer the new data because that was the quickest for me.
The Code:
If your configuration is the exact same as mine, then you can use these following sections of code to enable the shortcodes.
At the root of your domain, in the .htaccess file (make it if you don't have it), include (I added the "REGION" comments just for readability and future maintenance):
In your MediaWiki's LocalSettings.php file, insert the following lines (preferably right under "$wgScriptPath" and "$wgScriptExtension" just to keep things organized):
Note: With this method, you don't even need a /wiki/ directory to make it appear that all the files are there. You should use this method so that when you make changes to the backend, the frontend will still be the same for users, search engines, and SEO. It also makes URLs easier to remember and more.
More detailed information: Manual:Short_URL
~ Danial Goodwin ~
Quick and easy directions:
1. Go to MediaWiki ShortURL Builder (Your wiki will have to be temporarily public)
2. Type in your current URL, for me it was " http://danialgoodwin.com/mediawiki/w/"
3. When you click "Go", make sure the article path says "/wiki/$1" or wherever you would like your MediaWiki to appear to users.
4. You now have all the code at your fingertips to place on your server. I used a GUI FTP client (like FileZilla) to transfer the new data because that was the quickest for me.
The Code:
If your configuration is the exact same as mine, then you can use these following sections of code to enable the shortcodes.
At the root of your domain, in the .htaccess file (make it if you don't have it), include (I added the "REGION" comments just for readability and future maintenance):
# REGION Redirects for MediaWiki Short Canonical URLs
RewriteEngine OnRewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/mediawiki/w/index.php [L]RewriteRule ^/?$ %{DOCUMENT_ROOT}/mediawiki/w/index.php [L]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-fRewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-dRewriteRule ^/?mediawiki/w/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/mediawiki/w/thumb.php?f=$1&width=$2 [L,QSA,B]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-fRewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-dRewriteRule ^/?mediawiki/w/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/mediawiki/w/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B]
# ENDREGION Redirects for MediaWiki Short Canonical URLs
In your MediaWiki's LocalSettings.php file, insert the following lines (preferably right under "$wgScriptPath" and "$wgScriptExtension" just to keep things organized):
## Added for short URLs.$wgArticlePath = "/wiki/$1";$wgUsePathInfo = true;
## Added for short URLs because .htaccess on root includes 404 thumbnail handler config.$wgGenerateThumbnailOnParse = false;
Note: With this method, you don't even need a /wiki/ directory to make it appear that all the files are there. You should use this method so that when you make changes to the backend, the frontend will still be the same for users, search engines, and SEO. It also makes URLs easier to remember and more.
More detailed information: Manual:Short_URL
~ Danial Goodwin ~
2014-02-09
Level Up - Webmaster: Setting Up Your First Laravel Website Or App
(For webmasters, a continuation on my last post Level Up - Webmaster: Installing Laravel and Composer on Bluehost.)
This walkthrough contains all the instructions I would have needed on one page, rather than looking through twenty different pages. This is a blunt how-to for connecting to a database with Laravel and displaying information. At the end are links for more specific and advanced info.
The following has explicit instructions and commands for a shared hosting provider like Bluehost, but the instructions should be the roughly the same for other providers and setups. I suggest to follow the steps explicitly the first time through, then run through it a second time with your specific project's names.
0. This simple "tutorial" assumes that you already know a little bit about Laravel and have possibly read my first install and setup walkthrough.
Setup the database:
1. Create a database on your server with a user and password.
2. From your root project folder, edit app/config/database.php to match your new database credentials.
3. In your root project directory, run php-cli artisan migrate:make create_users_table
8. Create two new views in app/views. Call the first one layout.blade.php and add this code:
@yield('content')
Create the second view, called users.blade.php:
@extends('layout')
@section('content')
@foreach($users as $user)
{{ $user->name }}
@endforeach
@stop
9. Go to your doman.com/users and you should have all the user names from the database displayed on the page.
This walkthrough contains all the instructions I would have needed on one page, rather than looking through twenty different pages. This is a blunt how-to for connecting to a database with Laravel and displaying information. At the end are links for more specific and advanced info.
The following has explicit instructions and commands for a shared hosting provider like Bluehost, but the instructions should be the roughly the same for other providers and setups. I suggest to follow the steps explicitly the first time through, then run through it a second time with your specific project's names.
0. This simple "tutorial" assumes that you already know a little bit about Laravel and have possibly read my first install and setup walkthrough.
Setup the database:
1. Create a database on your server with a user and password.
2. From your root project folder, edit app/config/database.php to match your new database credentials.
3. In your root project directory, run php-cli artisan migrate:make create_users_table
4. You should now have the file that looks something like: app/database/migrations/2014_02_09_195357_create_users_table.php. Edit the up() and down() function to look like:
public function up()
{
Schema::create('users', function($table)
{
$table->increments('id');
$table->string('email')->unique();
$table->string('name');
$table->timestamps();
});
}
public function down()
{
Schema::drop('users');
}
5. Now, back in the project root dir, run: php-cli artisan migrate
6. At this time, your tables in the database will be automatically created. Add some data manually so that we can test that retrieving data works.
Create a view:
7. Create a route (subdirectory pointer) in app/routes.php by adding the following code:
Route::get('users', function()
{
$users = User::all();
return View::make('users')->with('users', $users);
});
Laravel Quickstart
@yield('content')
Create the second view, called users.blade.php:
@extends('layout')
@section('content')
@foreach($users as $user)
{{ $user->name }}
@endforeach
@stop
9. Go to your doman.com/users and you should have all the user names from the database displayed on the page.
Note:
- If the php-cli command doesn't work for you, then try just php
More info:
More info:
2014-01-30
Knowledge Really Is Power
It's been happening quite a bit recently.
Ever get the feeling that everything you're doing seems really easy or smooth? That's knowledge at work. It allows the completion of many tasks to become easier. The more knowledge you have, the more tasks that are available.
Originally, when I first thought of this post idea, the above was pretty much all that I wanted to write about. But, now I'm seeing another side to this story...
Maybe, when one has reached the point of everything being easy, it means that the person isn't being challenged anymore, thus isn't growing or learning... So, it might be time for a change.
Because, after all knowledge really is power. ;)
~ Danial Goodwin ~
Ever get the feeling that everything you're doing seems really easy or smooth? That's knowledge at work. It allows the completion of many tasks to become easier. The more knowledge you have, the more tasks that are available.
Originally, when I first thought of this post idea, the above was pretty much all that I wanted to write about. But, now I'm seeing another side to this story...
Maybe, when one has reached the point of everything being easy, it means that the person isn't being challenged anymore, thus isn't growing or learning... So, it might be time for a change.
Because, after all knowledge really is power. ;)
![]() |
| Random image by Schoolhouse Rocks! |
~ Danial Goodwin ~
2013-08-27
Aerodynamic Cars
Is a car with smooth sides the most aerodynamic it could be?
A golf ball has dimples for a reason. They already tried smooth spheres, but the ones with dimples floated longer and went farther more easily. [http://www.livescience.com/32446-why-do-golf-balls-have-dimples.html]
The newest track suits (I read about this at least a year ago) also have small dimples on it rather than being perfectly smooth in order to shave a few hundredths of a second off. [http://www.gizmag.com/nike-pro-turbospeed-golf-ball-track-uniform/22520/]
Update: I just did a search for "cars with dimples" and found that MythBusters already did this. Mythbuster results showed a 11% increase in MPG (miles per gallon). =D
http://dsc.discovery.com/tv-shows/mythbusters/videos/dimpled-car-minimyth.htm
~ Simply Advanced ~
A golf ball has dimples for a reason. They already tried smooth spheres, but the ones with dimples floated longer and went farther more easily. [http://www.livescience.com/32446-why-do-golf-balls-have-dimples.html]
The newest track suits (I read about this at least a year ago) also have small dimples on it rather than being perfectly smooth in order to shave a few hundredths of a second off. [http://www.gizmag.com/nike-pro-turbospeed-golf-ball-track-uniform/22520/]
Update: I just did a search for "cars with dimples" and found that MythBusters already did this. Mythbuster results showed a 11% increase in MPG (miles per gallon). =D
http://dsc.discovery.com/tv-shows/mythbusters/videos/dimpled-car-minimyth.htm
~ Simply Advanced ~
2013-05-17
The Scientific 7-Minute Workout
Have you all heard about the scientific 7 minute workout yet?
On LifeHacker
In The New York Times
Here's a link to a timer to make things even easier for you: http://7-min.com/
~ Simply Advanced ~
2013-02-22
Procrastination Hack - Limit the Time Between Thinking and Doing
"Limit the time between thinking and doing." - Procrastination hack.
I'm sure I've read about this somewhere else, but I didn't find it with a quick "exact-phrase" search.
The goal is to stop putting so many items on a todo list and just do them as you think of them. One of the benefits is that you actually get stuff done rather than just thinking about it.
If you are actively participating in an activity or task, then you clear your mind of another task by writing it down. Current evolution of humans allows us to truly excel at just one task at a time. When we try to do more than one thing at a time, results are typically less than doing each of them individually.
Since I feel this needs an example.. Off the top of my head: I can juggle whilst riding a bike (multitask). But, if I were to do either of them individually, then it would be done much better.
~ Simply Advanced ~
I'm sure I've read about this somewhere else, but I didn't find it with a quick "exact-phrase" search.
The goal is to stop putting so many items on a todo list and just do them as you think of them. One of the benefits is that you actually get stuff done rather than just thinking about it.
If you are actively participating in an activity or task, then you clear your mind of another task by writing it down. Current evolution of humans allows us to truly excel at just one task at a time. When we try to do more than one thing at a time, results are typically less than doing each of them individually.
Since I feel this needs an example.. Off the top of my head: I can juggle whilst riding a bike (multitask). But, if I were to do either of them individually, then it would be done much better.
~ Simply Advanced ~
Subscribe to:
Posts (Atom)



