FINALLY! SOME UPDATES! This website is being reconstructed. Some content will go away soon. If you want to see my new stuff, visit my github: https://github.com/jrcharney/.

May 14, 2014

The Big List

So much has changed with WebDev over the years. Much of it seems overwhelming because I haven't used everything, and to be quite honest, I've no desire to use everything, but a short list big things that I'm still trying to understand.

  • Overall Practices and Concepts
    • "Mustaching" - While I am familar with this concept having done some editing on Wikipedia, and to a greater extent sites that use MediaWiki, I'm actually surprised as to how many other languages do this. I wish someone had told me about it sooner.
    • JSON - Now as standard (ECMA-404), I'm still the kind of person who uses Sed and Awk to boil down big XML-ish documents into CSV files.
    • Lambdas - Reality snuck up and on me with a reminder I don't know everything. Case in point, I regret not using Haskell as much I should have. Why is it that after almost 10 years of being out of college, I can play with Mathematical Caculus like a boss but when the subject of Lambda caculus is brought up, I just want to curl up into a ball.
    • REST - CRUD can easily describe how Ruby on Rails uses MVC. But if I can just port RESTful concepts to CRUD, it would help. Perhaps I should link being RESTful to MVC then take what I ported between CRUD and MVC and together as a composite? Ditto for MVP which definitely sound like something Sass and Compass would use.
  • Git - I'll admit it. The only thing I really know what to do with Git is clone git repos. But I do have my own github page and have attempted to post at least a couple of projects on it. I have about the same experience using subversion that I do with Git, but I must say I do like using Git over Subversion mainly because GitHub encourages you to participate in making your own stuff. Also, you can use GitHub with Koding.com.
  • Make and CMake - I recently found an old book on how to use Make. I'm hoping it can provide me with some direction on how to develop make files for source projects.
  • Sed - I've been conteplating quite a bit lately as to how I can use Sed better in my bash script and other things. Awk not as much considering.
  • Ruby - I don't know what happened last year. At first I was into Ruby, then I just stopped. I want to get back into it again. I do know one thing is for certain: Use RVM to install Ruby from source, don't use the version that comes with your Linux distribution.
    • Ruby on Rails - Ditto for Rails. I almost had turned my Raspberry Pi into a mini Rails server that used Nginx and SQLite as part of the webserver software stack when the SD Card corrupted itself last night. So I got to figure out how to use dd to rescue what I have and probably reformat or find a new SD card. (This is why I only like using SandDisk brand SD Cards.)
    • JRuby - What better way for me to be motivated to use Java again (other than the fact that it is installed on Raspberry Pi) than to include JRuby which is the Ruby programming language built for the Java Virtual Machine. I might just become motivated to pick up Scala this way.
  • HTML5
    • Canvas - I don't just want to learn it, I want to MASTER it! However to be good at this, I shouldn't piggyback off some Canvas JavaScript library. I need my code to be raw and dirty first. Then we can tidy it up later. Using jQuery can be an exception though. I think we can all agree jQuery is a must have. I've been working very hard to learn from Supercharged JavaScript Graphics by Raffaele Cecco, because just about every other book on HTML5 Canvas decided from the beginning to use their own personal graphics library of choice rather than use something everyone can connect with.
    • CSS3 - I've been using CSS for a decade now, and still think it is the best thing to happen to HTML. But there are features that due to my limited resources, I feel I haven't tapped yet. I would like to master this as much as I would like to master HTML5 Canvas.
      • Sass - I think we can agree that Sass is a must know especially if you use Rails. While I will certainly miss the days tinkering with raw CSS, Sass should help strengthen my CSS abilities and understanding of Rails at the same time.
        • Compass - What better authoring framework tool to use with Sass than Compass! I was in the middle of installing this on my Raspberry Pi when all hell broke loose.
    • JavaScript - I understand the ECMA-262 parts easy. But the DOM parts just screw me way too often.
      • jQuery - Never fear! jQuery is there to rescue me from DOM Hell. However, I haven't exercised some of the more fun parts (effects and element manipulation) as much as I should. I'd like to fix that.
      • Node.js - I'm still trying to wrap my head around how this works. I know how the REPL works. Maybe I'm just don't have it installed correctly? Hmm.
        • NPM - If I'm going to learn how Node.js works, I should also learn how NPM works. I wonder if I can install it and Node.js as Ruby Gems?
        • CoffeeScript - To be quite honest, I was first reluctant to pursue using CoffeeScript considering I felt it was just another JavaScript framework. (Like the world needs any more of those!) Then I realized, that I can be installed using NPM.
      • Ext JS - I've seemed to notice this get's installed whenever you install Rails on RVM. I guess I should learn this. Beats the heck out of using Angular.js and its non-standard HTML4-ish attributes. Did the Angular guys forget about the existance of the HTML5 event attributes? It seems like it from some of the examples they have.
    • YAML - I've seem to notice there's alot of YAML stuff in Rails, might want to look into it.
    • TMUX - I've been using it for the past few years but lately I've been reading a book about it on my Kindle.
    • Vim - I know the basics and can use tabs like a pro. But there's alot about ctags that I don't know about but should. Also, I want to start using vim as an editor for LaTeX and PostScript and IDE for just about everything.

    So yeah, I got a lot on my plate. but I sure wish I had some guidance and a little more discipline to complete it all. Then of course there is fixing up this website...which for some reason I keep putting off. Maybe its because I'm content with it. On the other hand, if I fix that problem with my Raspberry Pi, I could finally phase out the PHP-centric site and start using all this new stuff. It's time this site got Ruby-fied.

March 29, 2014

Earthquake in the O.C.

Though the home office for JRCharney.com is in Florissant, Missouri (north of St. Louis), the business end of this site is in Brea, California (north on Anaheim, east of Los Angeles) home of one of the first two Carl's Jr. restaurants which are called Hardie's here in St. Louis.

Last night, the Southern California ground shook, like it does almost everyday if you check the USGS Earthquake Map regularly. However, around 9:09 PM PDT (11:09 PM CDT), the ground shook 2 miles west of Brea and produced this M5.1.

For some reason, the media outside of California doesn't speak of earthquakes like they did back in the 1990s.

This cartoon would have never existed if not for the 1994 Northridge Earthquake!

This has me concerned. For me, this is important information as a strong quake could knock out this site. Just a few years ago, the old website I used to run was threated by wildfire.

While it's no surprise that California is a disaster magnet with the fires, earthquakes, landslides, and drought, but manufacturing these disasters through hydraulic fracturing (a.k.a. fracking) for natural gas and then reporting them with low attention is a page out of a Rachel Carson book.

While the 4.4 quake that occurred near L.A. on March 17th may be your standard California earthquake, the fact that fracking is happening on California is quite possibly the most ignorant thing any energy producer could do.

The Far Side by Gary Larson
Fracking in California ANYWHERE in a nutshell

However, if history has taught us anything, it is that Big Oil energy producers have a have a consistent history of making big messes and a piss-poor job of cleaning them up.

In fact this week marks the 25th anniversary of the Exxon-Valdez Oil Spill where much of the Alaskan coastline is still covered in oily muck. This week, 15 barrels of oil spilled into Lake Michigan from a tanker near Gary, Indiana, one of the largest freshwater lakes in the world and source of drinking water for many communities from the Great Lakes through the St. Lawrence River in Canada. A collision of a boat and an oil tanker also occurred this week in the Houston Ship Channel in Houston's Buffalo Bayou near Houston, Texas spilling 5400 barrels of oil.

Fracking is the new technique of making a big mess. Rather than spilling oil, injecting a mix of waste chemicals to use pressure to extract natural gas cracks the rock that separate the pockets of natural gas from the water table beneath the earth where some people get their drinking water. Above ground, the "popping" produced by fracking produces earthquakes. Before fracking, earthquakes in Oklahoma where small like any other Midwestern earthquakes and as frequent as any other quakes that occurred along the New Madrid Seismic Zone (NMSZ). The NMSZ produces quakes around 1.0 most of the time. Sometimes a 2.5 would occur. In fact, the last large quake to hit the Midwest was back in 1812. Now, there's a 4.0 quake shaking he Oklahoma City are once every 2 to 3 months, with a 5.7 destroying 14 homes in Oklahoma back in 2011. The Mount Carmel (Illinois) quake that happened in 2008 was a 5.4 and it shook the St. Louis Area from a couple hundred miles away.

In Southern California, it's not uncommon to see oil fields in Los Angeles and Orange Counties as the geology makes for easy access to the pocket of oil below. It's been known to bubble out of the ground and is responsible for L.A.'s famous La Brea Tar Pits. However, fracking in one of America's largest metropolitan areas that is also earthquake country for methane is haphazardous and ignorant, but not reporting the dangers is as terrible as not reporting that there was a quake at all.

March 8, 2014

Recipe Time: Veggie Wrap

From time to time on this site, I sometimes like to talk about other things. Today seems like a good day to talk of cooking.

Here in the Midwest United States, we have a chain of gas station convenience stores called QuikTrip or QT for short. Think of it as 7-Eleven without being gross. The stores are kept clean. I can't think of any other place where every other time I went there there was someone moping the floor or maintaining the coffee makers as much as the local QT.

A few days ago on Ash Wednesday, I was looking for something that didn't have any meat in it for lunch. For those of you who don't know, during the forty days of Lent following Fat Tuesday (a.k.a. Mardi Gras), most Christian denominations observe this time by abstaining from meat on Ash Wednesday and every Friday through Good Friday. And yes, I will state that I am Roman Catholic. I live in a region of the country called St. Louis. If I was born and raised in a place like Islamabad, Pakistan or Jerusalem you would probably guess I would be a Muslim or Jew. But I'm not here to talk about religion or go into a fervored debate on the existence of God or all that other shallow "My God is better than your God" petty squabbles which seem to cause more divisiveness than peace and enlightenment. I'm not even that kind of person. Who you choose to worship--if you worship--is really your business. It's the part of pushing your faith upon other whether you believe in a higher authority or not is where most arguments start.

I'm here to talk about good eats. Like the healthy eats that everyone can enjoy no matter who you are, what you believe, or what your diet is.

I'm here to talk about Veggie Wraps or Veggie Pitas. However you wish to interpret or modify this recipe, there really is no wrong answer. Although, this recipe takes what I've learned from my experience and improves upon it.

The QuikTrip veggie wrap claims to be under 350 calories, but I'm not one for counting calories, not when fruits and vegetables are involved. I do know one thing is for certain, you can't claim to be under 350 calories if as a condiment you include a packet of ranch dressing. If there is any lesson to be learned from the not-as-healthy-as-advertized McDonald's salads a few years ago, you can't say you are under 350 calories if you drown everything in Ranch or Thousand Island dressings. It would be like encouraging people to eat more granola bars by dipping them in Nutella. I'll discuss more about salad dressing later.

My experience with QT's veggie wrap was somewhat enjoyable, but it did motivate me to create my own veggie wrap with some improvements. My recipe involves versatility, in that I mix all the ingredients for a veggie wrap into a container to be used within a week of making it. But there is a natural and healthy trick to making it last a bit longer which I will share in this article.

QT's veggie wrap came with mushrooms. While most people enjoy mushrooms, I'm not particularly a fan of them. So whether you like to keep them in your mix is your perogative. Though I do wonder what it would have been like with sliced artichoke hearts.

In any good veggie wrap, you'll want to start off with at least two greens. The first is freshly sliced cucumber for crunch. The other is generally something leafy. QT's wrap used your standard lettuce. It didn't specify what kind of lettuce but I think it may have been some kind of Bib Lettuce. Which is fine if you want to make a wrap that is crunchy as moderately filling, but my wrap mix used something much better: Spinach. Not the nasty lawn clipping in a can or box made famous by Popeye, but the good leafy kind.

Popeye
"Hmm, I knew their be something wrong with the way I'd been eating me Spinach. Better check the label."

Spinach is generally a bold green color and generally comes in a couple of sizes. A broad leaf spinach will generally require being torn apart. A more practical type of spinach that is used is called Baby Spinach because the leafs are much smaller. To prepare this leafy green, no matter what size you use, you must de-stem the leaves broad stem then under flowing cold water from the tap put the spinach into a sieve and wash the leaves thoroughly. I'm sure there's a cooking website elsewhere on the net that shows how to do that.

QT's veggie wrap came with shredded carrots. Carrots can add an extra crunch with some sweetness and a great companion to the sliced cucumber. However, in my mix, I choose sliced carrots. I did try this new product on the market called "Carrot Chips" which is basically sliced carrots cut into these wide crinkle-cut slices, but even if this was a pre-prepared item that claimed to be washed and ready to eat, there were still a few nasty ones in the bag. The morale: wash, peel, and cut your own carrots. Still, having something solid to crunch into other than the cucumbers was nice and had a better outcome that QT's recipe.

QT's veggie wrap had green bell peppers in small slices. I chose to use red bell peppers in slightly longer slices. There is something bell peppers other than aesthetics that when they turn a different color other than green they have a more zesty taste to them. Maybe it is something in the chemistry of peppers. Peppers bring another tasty crunch to the recipe.

QT's veggie wrap also fell short in the tomato department. It did include tomatoes, but the tomatoes were diced. However, like any good sandwich, wrap, or pita, you want a good medium size tomato to bite into that is juicy and satisfying. It is important to remember, to use a medium size tomato, not cherry (too small) or beefsteak (too large) varieties. Wash your tomatoes and take care when using a knife because unlike cucumbers, peppers and onions, you can't use a mandolin slicer unless you want to make a juicy mess.

By the way, if you do use a mandolin slicer, take care in using that, as those things are an easy way to slice your fingers to the point you will need to go to the hospital. Find a mandolin where there is a top half to protect your fingers. Maybe when I edit this article later, I will post a link to some good slicers on Amazon.

QT's veggie wrap did not include onions. My suggestion is to use a red onion (a.k.a. purple onion), and use only half if not less of the whole red onion, because onions are powerful. An onion exposed to air for a few days can become really powerful. Onions should be the last thing you ad in this recipe due to their strength and eye-stinging acidity. But don't let the fear of onions making your cry discourage you from using them. You will definitely want to use them, as they will accentuate the flavor of everything in your veggie wrap mix.

Lastly, we return to the subject of salad dressing. Most salad dressings on the market are a hodgepodge of chemicals. The goal of healthy eating is to eat as few of those as possible. With that said, if you are able to grow any of the vegetables I have mentioned in this article, grow them! Why not look into the subject of hydroponics and grow plants indoors? I'll talk more about that subject some other time. The whole point of this paragraph is to look at the back of the jar of Salad Dressing. Can you find most of the ingredients of that dressing elsewhere in the store or will you need a Sigma-Aldrich chemical handbook and catalog to find some of these items?

One brand of salad dressing that has never let me down is Newman's Own. You might know the brand by the picture of the late actor Paul Newman on the label.

Newman's Own
Trust in this guy's mug!

To finish off my Veggie Wrap mix, I pour half a bottle of Newman's Own Olive Oil and Vinegar Dressing on the mix. Not only does this add a few spices to the mix but the benefits of olive oil and vinegar are indisputable. Also, olive oil and vinegar are good natural preservatives so the mix won't dry out after a few days.

Finally, if there is one optional, but separate condiment I would suggest if you're not completely into veggie wraps is to give crumbly Feta Cheese a try. This salty goat's milk cheese is quite tasty and is perfect if you chose to use a pita pocket over the various tortillas that are marketed as "wraps".

In review, here's a list of all the ingredients that I used for my veggie mix wrap.

  • One regular sized cucumber, sliced.
  • 8 ounces of washed and de-stemmed baby spinach or torn regular spinach or Bib Lettuce.
  • 8 ounces of washed, peeled and sliced carrots.
  • One washed and sliced red bell pepper, de-cored before slicing.
  • Two washed and sliced medium-sized tomatoes.
  • Half of sliced a red onion.
  • One cup (or half a bottle) of Newman's Own Olive Oil and Vinegar dressing. (Don't forget to shake it!)
  • 8 ounces of sliced mushrooms (optional)
  • Two or three sliced artichoke hearts (optional)

The steps.

  1. Combine sliced cucumber, spinach, carrots, red bell pepper, tomatoes, and red onion in a one gallon plastic container that has a lid.
  2. If you prefer, you can add sliced mushrooms and/or artichoke hearts. This step is optional.
  3. Pour salad dressing on the vegetable mix.
  4. Put the lid on the container securely, and shake the vegetables and dressing until the vegetables are diversely mixed.

  5. Using tongs, take some of the mix and put it on a tortilla wrap or in a pita bread pocket.

  6. If you'd like you can add some crumbly feta cheese.
  7. If using a wrap, don't forget to wrap it up.

And that's a good step toward eating healthy. So go ahead and experiment. Try something out. It's actually quite good.

January 15, 2014

Ready and Load

One of the reason's I've chosen to reprogram my header's menu functionality is there was one important thing about jQuery I forgot about when I initially created my CMS: Where to put the jQuery code.

Often times, knowing how to use jQuery's .ready and .load functions is never explained in such a way that most people who just want to pick up jQuery and go with it find themselves with either code they thing does not work or code that feels like it's in the wrong part of a document.

Firstly, the proper syntax of using JavaScript is generally to put your code in the <head> element in a <script> element. It's a convention that is often not obeyed by programmers, especially since it is permissible to put JavaScript in the body either by using element attributes or by just putting a <script> element in the body.

In HTML5, the <script> element has a new attribute called defer. The purpose of defer is to put off executing a block of JavaScript in a page until it has finished parsing. However, many browsers still don't support it. And after trying it out, I find this to be a bad idea to use especially since a page can be loaded but not done parsing. Also, defer is meant for external scripts. So writing you <script> block where ever it is in the page will still make the code run even if you use a defer attribute.

Thankfully, jQuery has a better, and more elegant, way of doing this.

<doctype html>
<html>
<head>
...
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
...
<script type="text/javascript">
/* show or hide a page section */
function sectionToggle(me,you){
 $(me).next(you).slideToggle("slow");
}

$(document).ready(function(){
 $("h3").click(function()){
  sectionToggle(this,"pre");
 });
});
</script>
</head>
<body>
...
Using $(handler) as an alternative to $(document).ready(handler) is also acceptable, but the long way has more clarity.

The above code will change the display of any <pre> element that follows a <h3>. (Though, if you wish to use this example, add h3 + pre { display:none; } inside a <style> element preceding the <script> element.)

Without using $(document).ready(handler), the code inside does not work where it is. To make it work without it, $("h3").click(...) would need to be placed inside a <script> block, located at the end of the HTML document where </body> is.

The other important issue is how to use .load, not the depreciated .load function but the proper .load function.

Some of jQuery's functions, especially the ones that use AJAX will not work by playing around with some place like file:///home/you/Sandbox/file.html. When you want to do something that has AJAX involved in it, your sandbox URL should be http://localhost/Sandbox/file.html. Blame the "Same-origin policy" used in just about every browser. If you are lucky to have something like Apache HTTP Server or Nginx installed as you Hypertext Transfer Protocol Daemon (httpd) or "web server", all that is needed is to move the file you are playing with to where your web server calls home. For Linux users, that means somewhere in /var/www/. (See my last post for how to create a Sandbox folder).

$(document).ready(function(){
  $("h3").click(function(){
    $(this).next("pre").slideToggle("slow");
  });

  $("h3#something").next("pre").load("files/something.txt");
});
In the <pre> element following <h3 id="something">, load the file file/something.txt. This will only work online or on a web server!

Note that the .load function is inside .ready. This is ideal because you want to be "ready" before you "load" anything new anyway. But these are simple examples. I'm sure you can come up with something more complex. With this important knowledge, you can do so with confidence and write code more professionally.

January 14, 2014

Rails and Node.js

First post in nearly two months. My header is undergoing some changes, but I think it's time to settle a few matters with getting Ruby on Rails and Node.js running.

Node.js is the ideal software platform for working with Rails, because Rails needs a JavaScript engine and Node.js is happy to oblige.

So let's put this thing together!

Firstly, I don't think we need to stress how much Ubuntu (or several other Linux distros for that matter) loves to get people to use their repositories to download software especially when their repos are out of date most of the time. So, to avoid this, let's get our Node.js from a more reliable PPA. Chris Lea gladly provides this. So before we install Rails, let's install Node.js using Chris's PPA.

$ sudo add-apt-repository ppa:chris-lea/node.js
$ sudo apt-get update
$ sudo apt-get install nodejs
Installing Node.js is easy!

One of the things I like about Node.js is the fact that it has a REPL just like Google Chrome has. A REPL is an interactive environment just like Bash, Ruby, Perl, and Python has. In fact, if yo want to try out some REPLs interactively, you can go to REPL.it and give Ruby, Python, and other REPLs a test drive. When you have Node.js installed, you can boot it up and play around with it like so.

$ node
> 2 + 2
4
> "All your base " + "are belong to us."
'All your base are belong to us.'
> partyRock = "Everyday I'm shuffling";
'Everyday I\'m shuffling'
> partyRock.split(" ");
[ 'Everyday', 'I\'m', 'shuffling' ]
> 
(^C again to quit)
> 
$
To exit from node, type CTRL+C twice! Also, Node.js prints output IN COLOR!

Now that we have Node.js installed, let's take care of the other half of this post.

Hopefully, you've been reading my previous posts for how to properly install Ruby and JRuby. Here we use Ruby's gem program to install Rails, because using rvm is really only good for installing Ruby and jRuby (everything else is such a pain in the butt!). Using apt-get is also foolish! Besides, what did I just say about using Ubuntu's repos! On RubyGems.org there is a Rails gem. We'll be using that to execute the following installation commands.

$ gem install rails
That's it?

'Fraid so, figcaption element. However, there are somethings that are really REALLY important that I should point out.

  1. This gem will take some time to install. Do not press CTRL+C. Do not Google "installing ri documentation for rails-4.0.2 stuck" because that is part of the process. Do not pass Go. Do not collect $200. Do something productive because this will take a few minutes. Go make a sandwich or find that old HTML5 Canvas project you did, no that other one--and give it a good update.
  2. You do not need to be root to install gems. In fact, go tell sudo to make you that sandwich. Administrators might want to take heed of this...not that you have anything to worry about. *cough*

Lastly, there's the issue of getting Rails running. I find putting anything where I need to test stuff on 127.0.0.1 (a.k.a. localhost) where it should go, in /var/www/.

Rails is quite new to me, and I hope to write up a few more blog entries for how to do stuff with Rails this year especially in the next few weeks.

First, because I can, I want to do all my Rails stuff inside a special sandbox folder called railyard where I will set up a project called train. Because I can use sudo, I can also create this file in /var/www/.

$ cd /var/www/
$ sudo mkdir railyard
$ sudo chown jrcharney railyard
$ sudo chgrp jrcharney railyard
$ cd railyard
$ mkdir train
$ rails new /var/www/railyard/train/
$ rails server
ALL ABOARD!

So here's what happened. We told Rails to create a new project at /var/www/railyard/train. I'm not sure if I need to do mkdir train, but everything is working, so I'm happy with it. We then told Rails to start up the server. If everything is working, Rails should keep running in the prompt (which a good rails server & (with an ampersand) will let it run in the background), and you should see a Rails boilerplate page at http://localhost:3000/ since Rails is listening to port 3000. I'm sure there is a way to forward port 80 traffic, but for now it's running. Rails will stop if you type CTRL+C. If that happens, localhost:3000 will not become available, much like what happens when you stop the Apache HTTP server when you run sudo service httpd stop.

There are two other things I need to look into. Firstly, I need to see if Rails uses Apache HTTP Server or if it uses something else like Nginx. Secondly, what database server Rails uses. Rails claims that SQLite is the default SQL database engine, but I still have MySQL available (and phpMyAdmin) though I'd really like to give MariaDB a spin. Maybe if I got the time, I can just start over from scratch and put it all on a Raspberry Pi. Ray Hightower did it although now he recommends using a BeagleBone Black. There's a lot of stuff I would like to do this year like build a 3D printer out of old computer parts. If Kodjo Afate Gnikou can make one for about $100 in Togo, why should the folks who produce all that e-waste keep sullying the third world with perfectly usable technology?

Like I said, there's much to do still. The year is still young.

Twitter

Tags

Under Construction