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

<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.cppdata-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 ~



2013-09-22

Microsoft's App Studio

Today, I wrote two blog posts regarding a new product from Microsoft that allows anybody to easily and quickly create and publish Windows Phone apps.

Learn about it: What Is Microsoft’s App Studio?

Learn more about it: How To Edit App Studio Code

~ Simply Advanced ~



2013-07-14

Cleanliness: Grass versus Concrete

Is laying on grass more sanitary than laying on concrete?

Concrete may be easier to wash off the surface (via rain) and grass/ground may more easily absorb things on it.

Regardless, people [mostly] rather lay on random grass than lay on random concrete.

~ Simply Advanced ~

ps - I had another sentence that stated my conclusion, but my posts are [typically] different from other blogs. For other blogs, you can just read them and say "okay", then move on. For many of my posts, they just state a few things or a new perspective and I leave the ability to further expand the readers mind up to the reader. I know many people want quick wins, but in the long run people (IMHO) need to be able think for themselves and always be doing so.



2013-05-16

The Future of Android and Chrome

I wrote a new post in my developers blog (Danial Goodwin), but it may also be useful for readers here because it doesn't really have to deal with code or IDEs.

The first part of the post talks about Google IO's keynote and has the prediction: "By this time next year, Google will announce that Android OS will be fully integrated into Chrome. Just like Google Glass extends Android experience on the phone. Chrome on computers will be able to extend the Android experience."

In the second part, I drone on in one large paragraph about "content creation as just a phase in our human social lives". Also, I mention content absorption, being a data-centric world, and eventually having nothing else to learn.

Read the full article: http://blog.simplyadvanced.net/the-future-of-chrome-and-android/

~ Simply Advanced ~



2013-01-28

Obol - The Never-Soggy Cereal Bowl and Its Future

I saw the Obol in Brookstone over a month ago and really liked the idea of having the cereal and milk separate in order for the cereal to stay crispy the entire time you are eating.

Recently, I saw a post about it a food blog and started thinking about the idea of Obol again.

Imagine yourself eating out of a regular bowl of cereal with milk. The best bites are the first few because the cereal is the most crispy at that point. But, there is at least two more reasons why the first few bites are typically the best of the bunch. Point number three below I believe affects people on a more psychological level.

At the beginning of eating:

  1. Cereal is still crispy
  2. Milk is the coldest
  3. It is easiest to get a huge scoop of cereal on the spoon!

After determining that these are the reasons why I truly like cereal (besides the overall great taste), it is easy to determine that the Obol is does not significantly help me eat and enjoy my daily cereal. Obol performs task one very well. Task two is iffy. It may take longer for me to eat the bowlful of cereal, thus the milk will be warmer by the end (I am a cereal milk drinker). Obol fails at number three. By only putting a little bit of cereal in the milk compartment, the cereal spreads throughout the entire surface area of the milk, causing me trouble when I try to get a large scoop of cereal on my spoon. If I put any more than a little bit of cereal in the milk compartment, then I might as well be using a regular cereal bowl instead.

An idea for a bowl is to throw it in the refrigerator or freezer overnight and in the morning you can enjoy colder milk for a longer period of time! I haven't actually tried this out yet, but I will! Number two improved.

Another idea for a bowl to add a little vertical strainer on the coming out from the side. Milk will be able to go through the strainer, but the cereal will not. This could be a clip-on that would fit most bowls. Maybe it just have a little lip on it that allow it to sit on an edge. The idea is that you can gather up all the cereal to one side of the strainer, then a big scoop of cereal will be easy again. You could potentially just swirl your milk with the spoon and like magic, the cereal will all be gathered in one place. Number three vastly improved!!

http://www.obol.co/images/


~ Simply Advanced ~



2013-01-08

New Years Resolution of 2013

This is the first year that I'm going to create a blog post about my New Years Resolution.

  • My main goal for this year is to create at least one truly innovative mobile application.
  • Also for this year would be to develop at least two half-innovative apps.
  • This year will be the one where I do more hand stands and possibly a vertical push-up!

LTE Discovery was my main innovative app of 2012. If you search Google for "LTE Discovery", then it should be the first link that pops up. After three weeks of being on Google Play, LTE Discovery is still a one-of-a-kind app. =]

~ Simply Advanced ~

UPDATE: Added hand stands as goal.



2012-11-10

Android Camera - A Problem I Spent Almost Twenty Hours On

Finally, there is a new post on my blog.SimplyAdvanced.net website. The last one I wrote was on 31 May 2012.

The Android development problem I talk about is the issues with the camera preview within onPreviewFrame() and setPreviewCallback(). The same code that worked for Android 2.2 didn't work for 4.0 and above.

http://blog.simplyadvanced.net/android-camera-a-problem-i-spent-almost-twenty-hours-on-trying-to-solve/

~ Simply Advanced ~