Showing posts with label how-to. Show all posts
Showing posts with label how-to. Show all posts

2015-05-20

Level Up - Ruby on Rails: How to create a very minimal blog website (two different ways)

As I was refreshing myself with Ruby on Rails, I've decided to share these notes. To follow these steps, you don't actually need to know any Ruby or Rails, but you should have them installed already. I'm using Ruby 2.1.5p273, Rails 4.2.0, Windows 8.1, but these steps are simple enough to do on any version.

I show two different ways to create a very code minimal blog. It also demonstrates the power of of Rails scaffolding.

Using scaffold


1. Just run the following commands one after another:

    rails new quick-blog
    cd quick-blog
    rails generate scaffold post title:string body:text
    rails generate scaffold comment post_id:integer body:text
    rake db:migrate

2. To create a post or comment, make sure that the `rails server` is started. Then, in browser, navigate to `/posts/new` or `/comments`.
3. Done


Without using scaffold


1. Run `rails new very-minimal-blog`
2. Run `cd very-minimal-blog`, then `rake db:create`
3. Create the model for the posts: Run `rails generate model Post title:string body:text`
4. Run `rake db:migrate`
5. Create a controller for the posts: Run `rails generate controller Posts`
6. In that controller that was just created in `app/controllers/posts_controller.rb`, add some code so that it looks like the following:

    class PostsController < ApplicationController
      def index
        @posts = Post.all
      end

      def show
        @post = Post.find(params[:id])
      end
    end

7. In `app/views/posts/`, create a new file called `index.html.erb` and add the following code:

   

Very Minimal Blog


    <% @posts.each do |post| %>
     

<%= post.title %>


      <%= link_to "Read me", post_path(post) %>
    <% end %>

8. Create a way to get to the posts. In `config/routes.rb` add, `resources :posts`
9. In `app/views/posts/`, create a new file called `show.html.erb` and add the following code:

   

<%= @post.title %>


    <%= @post.body %>

10. Done. :)


## To create a blog post ##
1. Open Rails console by running `rails console`
2. Run `Post.create(title: "My Title", body: "This is my awesome blog post!")`


## To view the blog ##
1. Start the Rails server by running `rails server`
2. Navigate to `localhost:3000/posts`


~ Danial Goodwin ~



2015-03-02

Level Up - Android Dev: How to get started with Robolectric (Android testing)

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 ~



2015-02-12

Level Up - Web Dev: How to get started with Polymer

Polymer:

  • 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 `/`. 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 ~



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.

2013-05-18

Google Play Developer Console: How To Upload Required Graphics (Icons and Screenshots)

I've been asked many times, "what size logos do I need to upload to Google Play's Developer Console?" and "how many screenshots do I need to take?" So, here's a post that I point people to that explains everything you need to know about uploading graphics to the developer console in order to have an app published.

A very important point to remember: These images that are uploaded are one of the main factors potential users use to determine if they want to download it or not. They may not even read the description if you have an ugly app logo. Invest wisely in a great logo (either time or money). Google Play also allows each app to have one YouTube video associated with it and appear in the description. This is a highly effective way of showing that your potential users want to use your app.

The first part of this post will give a walkthrough on how to upload the required graphics to the developer console and the second part will have more resources for designers.

1. Walkthrough
  1. Go to https://play.google.com/apps/publish/ and select the app that you want to add the graphic assets to. You may either have to click "All Applications" in the top left or "Publish an Android App on Google Play" if this is the first app you are creating (create a title and click "prepare store listing").
  2. You should now be in the "Store Listing" section for your app of choice. Scroll down until you see "Graphic Assets." The screenshots section should be the first graphic assets to add.
  3. Now, you can either drag the screenshots onto the "Add Screenshot" box or click the box and browse to where the image is located. A minimum of two screenshots are required before the app can be uploaded to Google Play.
  4. Scroll down a little more until you see "High-res icon". This is the final required graphic asset that must be added before publishing. It should be 512x512px. See 4. Summary below to see more details.

2. Resources - Things change, so here's a link to the official Google Play Design Guide that all developers, designers, and Android app publishers should read.
  • Android Icon Design Guidelines. Here's some tips for designers to work more easily with developers. Designers, please follow these guidelines when creating assets for Android. It will just make things so much easier for developers. The biggest thing is to not have any spaces or capital letters in the file name.
  • All About Launcher Icons. Launcher icons are the icons that users see when they install the app; It is what they must click on to open the app. You don't want your icon to be so bland that the user can't easily distinguish it from the many other apps they have already downloaded.


3. Bonus: Google Play Protips
  • Google Play allows you to create localized versions of your graphics. Think about translating any descriptions and titles on your graphics to the other languages you support.
  • And always, do market research (or due diligence) to make sure that you aren't trying to upload the same style icon/logo as another app. Your app will seem like the spammy one. You want to have a distinguished style to set yourself apart from others (but not too different). Check out the Android Iconography

4. Summary: Graphic and Image Assets
  • Screenshots (Two Required)
    • Allowed up to 8 screenshots for each different device (phone, 7" tablet, 10" tablet)
  • High Resolution Icon (Required)
    • 512x512, 32-bit PNG w/alpha. This is the icon that is shown to users in Google Play
  • Feature Graphic (Optional, but recommended)
    • 1024x500, 24-bit PNG no alpha
  • Video (Optional link to a YouTube video, recommended)
  • For more information: https://support.google.com/googleplay/android-developer/answer/1078870?hl=en
Source: http://blog.simplyadvanced.net/google-play-developer-console-how-to-upload-required-graphics-logos-and-screenshots/

~ Simply Advanced ~



How To Get Started With Publishing Apps On Google Play

First of all, if you have never created a Google Play publisher account, then see: http://developer.android.com/distribute/googleplay/publish/register.html

That link above will walk you through the steps necessary to be able to upload apps on Google Play and start making money from them.

When creating a new account you will have to go through a few easy steps and pay $25 to setup the account. Then you should appear at a screen that looks like the following:
Google Play Developer Console Home Screen
The options are self-explanatory. But, the first thing that you would probably want to do is set up a merchant account in the bottom-right. This is how you will be able to accept in-app purchases and create paid apps. The second step for you probably (if you aren't a developer) is to invite co-workers to the developer console in the bottom-left. This will allow you to invite by email your developer to upload the Android APK (app packages that users download and install on their device). You can also invite your graphics designer so that they may upload all of the required logos and screenshots. And either yourself or a copywriter can fill in the app description and promo description.

I will eventually create more posts that explain exactly how to perform each of the roles for the developer, designer, and copywriter. I know how to do each of these because of the many Android apps that I've successfully published. If you are also doing each aspect of the app publishing, then I highly recommend reading http://developer.android.com/design. There is a lot of highly useful information there. But, don't limit yourself to just that one great resource. It takes a lot of knowledge to have a highly successful app.

Source: http://blog.simplyadvanced.net/how-to-get-started-with-publishing-apps-on-google-play/

~ Simply Advanced ~



2013-03-23

How To Publish a Windows 8 App Using GameMaker: Studio

This post is going to be one of my longer ones, but no worries. It still contains only the minimum amount of work needed to get done before you have the ability to publish. Here's the official YoYo Games' GameMaker Setup walkthroughhttp://help.yoyogames.com/entries/22361996-Setup-GameMaker-Studio-for-Windows-8

It has some good stuff, but not good enough. You'll be back here in order to successfully publish the Windows 8 app.


So, in this walkthrough, I will show you how to properly create the Windows 8 application for upload, using GameMaker: Studio.

I'll assume you already have:




1. First of all, make sure you have the proper GameMaker program. There are mainly two different ones to choose from. Choose one from http://www.yoyogames.com/gamemaker/studio and you must pay at least the $49.99 in order to publish to Windows 8. You must also have Microsoft Visual Studios 2012 installed.

2. The second biggest problem is not choosing the right target platform. Currently, you must choose "Windows 8 (Javascript)" option from the Target menu near the top (see pic below). Note: If you are using GameMaker in Windows 8, then choosing this method is the only way to save the project too. Having a target of regular Windows causes an error.
Platform target menu circled in red


3. Third, from the menu up top, choose File->Preferences->Windows 8. You should see something that looks like the following screen.

All this was setup for me automatically because I have created a Windows 8 app before. If these fields are not inputted, then please read http://help.yoyogames.com/entries/22361996-Setup-GameMaker-Studio-for-Windows-8. I can't describe the Preferences screen better than that (towards the bottom of the link).

4. Now that the GameMaker Preferences are set up, it is time to setup you project's Global Game Settings.
Double-click to open the Global Game Settings

This is where all other GameMaker to Windows 8 tutorials get messed up. What you need to do is open up Visual Studios 2012 and create a new basic Javascript project. It doesn't matter what you name it (for this tutorial let's call it GameMakerTest). Now, you need to reserve your app name (to ensure that it is available), associate the app with the store to get the package name, and create an app package to get the needed certificate. Where to find these options depends on if you have Visual Studios Express or Full.

4.1. To reserve your app name:

Express: In the menu bar up top: Store->Reserve App Name
Full: In the menu bar up top: Project->Store->Reserve App Name

(A new tab in your browser will open, titled "Submit an app")

Click on "App Name", which should be highlighted in blue in the middle of the screen. Then name your app. Your first choice may be taken already, so choose again. Remember this name because you will use it later back in GameMaker. Don't close this screen because you will use it again after inputting the details into GameMaker.

4.2. To associate app with the Windows Store and get the package name.

Express: In the menu bar up top: Store->Associate app with store
Full: In the menu bar up top: Project->Store->Associate app with store

Sign in with your Microsoft account. Navigate the screens and choose the one that app name that you just reserved for your GameMaker game. (Tip: The last screen shows some helpful information, like your publisher display name, if you don't remember it. You'll need to type that into GameMaker in step 5.)


4.3. To compile app and get a Windows 8 app certificate (to be used later in GameMaker):
Express: In the menu bar up top: Store->Create App Packages
Full: In the menu bar up top: Project->Store->Create App Packages

Sign in with your Microsoft account. You should see the app name that you just resevered, if not, then check the only checkbox that is there. You will need to know both the App Name and Package Identity in the Store. For this tutorial, I'm just going to say copy this information in your favorite text editor for now.
Your names and identities will be different than mine.
Highlight your app name that you want to submit. Click Next. Click Create. Click on the output location link so that the file explorer opens. Navigate one level up by clicking the up button. (You don't need to run the certification kit. It wouldn't work for you at this juncture anyways.)

The file you need here for GameMaker will be called _StoreKey.pfx (Ex: GameMakerTest_StoreKey.pfx). Keep this file explorer open so that you know where to find this file later in GameMaker.

5. Bring your project in GameMaker to the front again. You should still have Global Game Settings open on the Windows 8 tab. I will now walk you through what should go in each of the options.

Display Name - Put in the App Name that your reserved using Visual Studios
Package Name - Use the "Package Identity in the Store" value here. I told you to write this in your favorite text editor.
Package Display Name - Basically, the short name for your Display Name. It can be the same or a condensed version of it.
Publisher Display Name - What is your publisher display name when you created your Windows 8 Developer account? (It probably cost $49, or free if you are a student)
Version - Doesn't really matter. Just make sure it is higher than your last submission.

Each of the images that you see on this screen should be updated before publishing to Windows 8. So, go ahead and do that now. Don't close this screen yet. Come back here after you finish.

Currently, you should be in the General tab of the Windows8 tab in the Global Game Settings. On the left side, click the Installation tab. This is where you need to navigate to the PFX file (Ex: GameMakerTest_StoreKey.pfx). After you do that, click Install. Windows PowerShell will pop up and things will start to look very technical. Just read the options and continue moving forward. Close the Global Game Settings when you are done.

6. All the hard steps are finished. Now it's time to go to the menu bar, File->Create Application. Save it to your location of choice.

Navigate to the location you created the application. Click on the folder, then AppPackages. The *.appxupload is the file you will submit on the Windows website that you should still have open in your browser if you followed this walkthrough word for word.

UPDATE: After running through it again, I found out that you don't need to do step 4.3 if you do step 4.2. Associating the app with the store creates the certificate key. But, I'm leaving step 4.3 in just because it is easier to navigate to the file that way. Just know that next time you do this, you can remember where you save the project to and skip a step.


Please let me know if this walkthrough helped at all or if I should put in any more information. I spent about an hour creating this... after first learning how it do it myself which took much longer. =]

~ Simply Advanced ~



2012-12-10

Highlight Text in PowerPoint

There is no easy way to highlight text in PowerPoint. There is an easy method for Microsoft Word. But, PowerPoint wants you to first draw a rectangle around the text and use the "Shape Fill" feature...

Please, somebody prove me wrong. Show me an easier way to highlight text in PowerPoint 2010.

~ Simply Advanced ~



2012-11-06

How to Disable VLC Plugin in Google Chrome

VLC is the best media player in the market that plays just about any type of media file. But, one big flaw is its browser plugin. When it is running, there are no extra options to do anything with the media file.

Sometime I just rather download the file instead of watching it online. Then, that way I may speed up the video to 2x speed and watch it more efficiently. (It takes a bit of training in order to understand videos at 2x, I'd recommend starting off at 1.4x speed)

So, to disable VLC's plugin for Google Chrome

  1. type "chrome://plugins/" into the address bar (or omni bar) located at the top of Google Chrome.
  2. Search and find "VLC Web Plugin."
  3. Click on the "Disable" link.

You are done. There are no options in the desktop part of VLC to disable the web plugin. But now, you know how.

Google Chrome will now try to use another media plugin you have, or it will try to download the file.

Share the knowledge,
~ Simply Advanced ~



2012-07-24

Get Things Done - Priority List

Recently, a friend commended me for the ability to concentrate and stay productive throughout the day, day after day.

One thing about me is that I treat my [Internet] bookmarks and emails as a todo list. I also have a physical and virtual notepad on both my physical and virtual desktop where I keep track of things I want/need to do.

But, just having todo lists isn't enough for many people. So, for those who don't have the willpower to take a "just do it" attitude towards daily and/or important tasks, there is a solution.



Or

  • Think of your todo lists as priority lists instead. And, there can only be one #1 priority task to do at a time. Then, just do that task without thinking whether or not you should do that one or something else.



Get started now. You don't need to waste time reading more productivity guides and how-to's; Any thing besides what's on the priority list will just waste your valuable time.

~ Simply Advanced ~