Showing posts with label website. Show all posts
Showing posts with label website. 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 ~



2014-03-01

Level Up - Business: How To Change Your Filed Information With The State Government (Florida)

If the information you have filed with the state has changed, then you are supposed to let the state government know about it. This blog post will simply point you to the page where you can find all the information that you need to change your filed emails, addresses, FEI/FEIN/EIN, your business name, and more.

For the state of Florida, you will need to go to the Sunbiz site at http://www.sunbiz.org/address_change.html.

Now that I have this information written down in my blog, next time I need to make a business change I will remember to just look at this post to find the link easily, rather than searching through the different government business websites.

~ 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:

$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-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
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);
    });
8. Create two new views in app/views. Call the first one layout.blade.php and add this code:
   
       
           

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:

2014-01-04

Cryptic Military Password Requirements

Just a few notes here for an unnamed (non-secret) military (ending with .mil) website. The sole idea of this post is to briefly articulate how "strong" of a security password is required, that is, until everything moves to requiring a physical, smart card + card reader.

(The following is not word for word, but just the general idea in my own words.)

Here's what is highly recommended (read: required) by the site:
- Up to 55 characters.
- Contain 2+ of each of the following
   - UPPERCASE letters
   - lowercase letters
   - symbols   - numbers
- NOT contain:
   - Any self-identifying information
   - Words that can be found in the dictionary (thus preventing dictionary attacks)
   - Common passwords, like "password", "654321", "abc", "qwerty", "asdfghjkl;'"

And, now the special considerations:
- Password lasts less than six months
- Can't reuse passwords
- Passwords must be significantly different from previously used ones

The above is all true.

Now, how does one remember this obfuscated password?

Well, one idea is to write it on a sticky note and put it on the computer. (Please don't do this). Another idea is to not remember the password and deal with possibly a weaker route of just knowing a few pieces of self-identifying information for a call or automatic password recovery system.
Two more bad ideas for remembering complicated passwords to a secure system:
- Using a third-party password solution
- Save in a plain text document
- Save in an encrypted document with the decryption key on the same machine

ps - Post purposely vague and without a final conclusion. It is my hopes that readers will find more reputable sources than a random blog on the Internet to read. Here's a good mostly-unbiased start: https://www.google.com/search?q=what's+a+safe+password

~ Danial Goodwin ~

pps - If you would like to know more about security for URLs, then check out my post from two years ago that still holds true today: http://blog.simplyadvanced.net/what-you-dont-know-about-urls-and-how-you-will-be-tricked/



2013-05-22

Simply Advanced Mobile App Development Website Updated

Hello,

Please check out my new design of Simply Advanced's home page. It's live now. Another surprising discovery is that my website shows first when searching for "Simply Advanced". You can access it by clicking the first result in: https://www.google.com/search?q=simply+advanced

Let me know what you think. =]
~ Simply Advanced ~



2012-06-28

New Simply Advanced Logo!

You should take a look at the Simply Advanced website that I just finished updating. Sometimes I even surprise myself lol. The layout is really neat, fits all screen sizes (try changing the width of your browser) and the about page has an innovative style that I haven't seen anywhere else.

http://simplyadvanced.net/

Inspired by modern art


~ Simply Advanced ~



2012-06-05

Personal Portfolio Site Redesign is Finished - djgoodwi.myweb.usf.edu

Not bad. The same site looks great on everything from large desktop monitor to tiny smartphone screen.

Definitely thanks to Twitter Bootstrap for the base framework. It has saved me many hours in design.

Please check out my site and let me know what you think. =]

Simply Advanced Home Page
Simply Advanced Homepage


There are still a few more projects I have to add, as soon as I find the pictures.
~ Simply Advanced ~