Not Everything Applies

Kjv1611

One of the biggest mistakes we can make as students of God’s Word is to incorrectly take what God has said to someone or some audience in a given context and apply it to ourselves. It’s dangerous breeding ground particularly in these the last days. Incorrect application has the potential to skew truth, incorrectly balance the message of scripture and challenge the simplicity of the Gospel. What gives me the confidence to say that you ask? Simply the number of cult ‘christian’ religions prevalent today who do not preach salvation through grace by faith in Jesus Christ. They have taken bible truth and applied it’s message to themselves instead as to whom God intended. Not everything in scripture applies to you!

Today I would like to raise an awakening, an awareness perhaps, both within myself and you as we study God’s Word, to be mindful of our approach and how we apply truth.

The messages (instructions or truth) of scripture can be broken down into 4 types, (a) Historical (b) Prophetical (c) Instructional (d) Spiritual.

Historical means in that specific portion of scripture God is re-enacting a historic event that took place for us. Like reading a History book, we would find facts, and accounts of people and key events. The Old Testament is largely a historic book revealing how God was working with His people, Israel. Now historical can become dangerous when we misapply it to ourselves, when God was clearly relaying a sequence of events from which we can indirectly learn about who He is, and what He desires.

Prophetical is simplistically a passage where God has made a prophecy about an event and it has happened, or will come to pass. The Bible has over 300 prophecies that have already been fulfilled. Now prophetical can become dangerous when we misapply what we see in scripture as current day events. For example; there have been numerous accounts of what “the four-horseman” are through the ages and while it’s great to draw these type of analogies, could it possibly be that the four horseman are literal? That may seem wrong but my point is that we must be careful in listening to others, watching Youtube videos or believing what we read on Facebook; simply because a prophecy has such strong association to current events.

Instructional is where God’s Word is giving direction, guidance or command. An example of this is the 10 commandments. However while there are plenty of cases where God provides instruction, not all of it is too us. Consider Israel’s instructions regarding their diet. Stoning those who broke certain laws. Who they should marry. Having altars, and offering animals unto God etc. Could those apply to us? Of course not. Does God’s Word ever change? No! It just has that appearance when we apply instructions to us (the bride of Christ) that were given directly to Israel. God left these accounts as a record to us, showing His nature and how He relates to man.

Now instructional can be dangerous when we rigidly follow God’s laws to an imbalance. This is known as legalism and involves being so rigid we do more harm than good. An example of this is the Pharisees and Sadducees who vehemently followed God’s laws, but had no heart for God.

Lastly, Spiritual is the process by which we take scripture and make it personal. This is the most common approach we take in our devotions, when reading our Bibles and when needing encouragement from God’s Word. Spiritual application can be very dangerous because we can take the words of God and bend it to mean anything. We fall into this trap because we feel it’s so real and applicable to us that the context of scripture may be completely ignored. Out of all four types this is the only one whose source is questionable, as we interpret the passage in light of the situation we are in. Is it “man” or is it the Holy Spirit giving the message? Whereas in the other three types, the message is already given by God.

There is a lot to chew on here and no supporting scripture, but my intent is merely to stimulate thinking and create awareness. I pray you were blessed by it!

For Christ, For You
Dane

Don't be shellfish...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone

Why should I use SASS?

 Problem:

Being a web developer one often hits that momentous stumbling block, of though being able to knit code together amazingly, that the “code’s face”, the actual UI is not quite what as “beautiful” as it’s internal structure. Perhaps a reason for this is not a lack of creativity, but rather a syntax that is “sour, leaving a bitter taste” in ones mouth – and that of CSS. Sometimes it’s not that the developer lacks “design skills”, but that he or she fails to come to terms with a language that’s “crude and difficult to read”. 

It’s kind of like an “artist” who has a palette with “two colors”, and the result of every painting is a boring stale end-result that is repeated over and over. However, if the “artist” is then informed, that he/she has an array of colors, as they find or choose to be necessary; then what can be created is truly marvelous!

My point – CSS for new developers can take a while to understand, grasp or even stomach, and in steps SASS (Syntactically Awesome Style Sheets). This then, is that introduction to something sweet that can help make your “web development” experience more pleasurable and less painful (easy to maintain, and less repeatable).

 

SASS

What Is SASS?

SASS friend, is simply a framework or rather a set of tools for allowing developers to leverage CSS in a manner that is more logical, and as “Rails developers like to say”, more DRY (Don’t Repeat Yourself).

Why use SASS?

Why use SASS? Now a Google will return lots of results and I mean there are so many frameworks out there, unless referred to by a colleague etc; you almost pass it by, thinking it’s just another “web” technology among the myriad. So to address that I would like to just cover 3 of Top “PRO’s” of SASS, that can bring immediate improvement to your “development time and experience” and perhaps persuade you to use it.

Variables

In developing any web site, I like to stick to 3 colors at a maximum to predominantly decide the look and feel or the UI. Often times, I find myself hunting down shades of one primary color, like blue, light-blue etc (or rather their HEX Values).

The beauty of SASS, is that we have Variables, yes, actual “Variables”, so you can do something like:

 $gray-Dark: #474546;

So now, when I need to reference that, let’s say for a 


header {
 background-color: $gray-Dark;
}

footer {
 margin-top: 30px;
 padding-top: 5px;
 border-top: 1px solid $gray-Dark;
 background-color: $gray-Light;
}

The power behind this of course, is now you have one reference point for changing a color as opposed to rippling through multiple CSS or a large CSS to change the color for all accompanying tags. Also a great plus, for quick “mockups”.

But let’s say, however, I wanted to make my footer slightly lighter as a variant of Gray. I could define a new variable, as such:


$gray-Light: lighten($gray-Dark, 20%);

footer {
 margin-top: 30px;
 padding-top: 5px;
 border-top: 1px solid $gray-Dark;
 background-color: $gray-Light;
}

There are a myriad of other functions, and you should check that out (like “darken”, “lightness” etc).

Nesting:

Now traditionally with CSS you would do the follow to NEST;


#header {
 background-color: $gray-Dark;
}

#header h1 {
 float: left;
}

With SASS, ‘nesting’ is much sweeter; we can NEST directly inside the target (class).


#header {
 background-color: $gray-Dark;

h1 {
 float: left;
 }

}

Functions:

Would you believe it, yes, your own functions. Now I cannot express enough the power behind this, but let’s use an example to give you some idea.


#header {
 background-color: $gray-Dark;
 border-radius: 10px;
 -moz-border-radius: 10px;
 -webkit-border-radius: 10px;

h1 {
 float: left;
 }
}

#nav-left {
 padding: 5px 12px;
 margin: 10px 0;
 border-radius: 10px;
 -moz-border-radius: 10px;
 -webkit-border-radius: 10px;
}

#footer {
 border: solid 1px $gray-Dark
 border-radius: 10px;
 -moz-border-radius: 10px;
 -webkit-border-radius: 10px;
}

Now as you can see the border-radius is repeated 3 times. A change to one would require me to meticulously make changes to all three. But that’s a bit cumbersome not to mention extra code, extending the size of my file, and decreasing readability. With SASS, I can instead rip out this ‘CSS’ and create a seperate function for this which I can address in all 3 places.

At the head of my file, where my variables are declared; we add in our Function, or as SASS calls it, MIXIN.


@mixin <name> {

// CODE TO REPEAT
}

@mixin rounded-corners {
 border-radius: 10px;
 -moz-border-radius: 10px;
 -webkit-border-radius: 10px;
}

And it’s implementation like this:


#header {
 background-color: $gray-Dark;
 @include rounded-corners

h1 {
 float: left;
 }
}

#nav-left {
 padding: 5px 12px;
 margin: 10px 0;
 @include rounded-corners
}

#footer {
 border: solid 1px $gray-Dark
 @include rounded-corners
}

But let’s say, the rounded corners are different for #nav-left – instead of 10px for the border-radius it should be 8px. How can SASS help us?

Well a “function” (mixin) is not a true function unless we can also provide “parameters” or “arguments”. So let’s modify our MIXIN a little to support custom radii.

That is:


@mixin rounded-corners($radius) {
 border-radius: $radius;
 -moz-border-radius: $radius;
 -webkit-border-radius: $radius;
}

But before we implement, how about a default, in places were the MIXIN is used, but no radius is specified;


@mixin rounded-corners($radius: 8px) {
 border-radius: $radius;
 -moz-border-radius: $radius;
 -webkit-border-radius: $radius;
}

Beautiful isn’t it, but let’s look at our implementation, which if you being any sort of developer should already have in your mind:


#header {
 background-color: $gray-Dark;
 @include rounded-corners(10px);

h1 {
 float: left;
 }
}

#nav-left {
 padding: 5px 12px;
 margin: 10px 0;
 @include rounded-corners(8px);
}

#footer {
 border: solid 1px $gray-Dark
 @include rounded-corners(10px);
}

But the programmability doesn’t end there, and again, so not to overload you with information, but to give you an understanding of it’s power; SASS also supports Conditional States (if, else if, else); as well as “For” loops and “For Each”.

Conclusion:

This is just the tip of the iceberg of SASS, and if you would like to learn more, you can visit the following links:

  1. SASS Website
  2. SASS Functions
  3. Beginner Tutorial on SASS
  4. Advanced Tutorial on SASS
Don't be shellfish...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone

HTML Scraper with Ruby

Introduction:

 

Great Gem

Being a .NET Developer by trade, I’ve become increasingly interested in Ruby. Being a C# developer for years, one finds one self often drifting to the “dark side” of open-source to play, learn and experience.

And on one such night, I decide how about test driving Ruby – and this little project. In South Africa we have an online business Directory, and I thought writing a HTML Scraper would be a great first project in this language that speaks of “Convention over Configuration”, and “DRY”.

So where to begin?

Requirements:

Well, firstly, what are our requirements:

(a) A quick review of the business directory, revealed a list of Supermarkets available across Africa, and that will be the data we will mine for 

(b) Obviously the output should be in a “form” that we can use, CSV/PlainText.

( c) Perhaps a Library (Gem) that we can use to Scrape the HTML (that is manipulate the HTML/DOM), and that is NokoGiri.

(d) Understanding the layout of the pages and understanding the data structure (Name, Postal Address, Telephone etc). As with all websites of any value – CSS is inherent, and standards for presenting large amounts of data in the same structure (so we should be one up already)

Reviewing the Structure:

  1. Determine what the URL is going to look like and obviously because the information for the super-markets/stores are large they are paginated, so let’s see if we can find a way to reference them directly (that is get their pagination address).  As you can see below that seems to be the constant URL, and reviewing the “pagination” links, a number is added to the end in iterations of 10. That is; /S0914E/10 or /S0914E/20Url
  2. Secondly, breaking down the structure of a store/supermarket – we can almost guarantee they will be broken down by a <div>. I’m using Chrome and “Inspect Element” to narrow down the data and it’s structure. Each store is found in a class called “list-directory_entry_4”, the title for the store in a div class called “list-entryTitlebar” in the TEXT of the <a href>. The class “list-details” gives extra details about the store (location). Also there follows a URL that links to extra information which we will scrape as well found in class, “list-entryInfoBar”Structure of Store's Data

Code Time:

  • Some points worth noting, I use am STDOUT in Ruby to create our CSV. I call “sync” at the end to dump after I complete a page, else it will build in Memory (not good when dealing with tons of pages)
  • Secondly, NokoGiri supports XPath which is wonderful for accessing the HTML. Note I am using XPATH with starts with to match for some inconsistencies in store “divs”. Very handy! page.xpath("//div[starts-with(@class,'list-directory_entry_')]")
  •  In this section of code, I am creating the URL’s I intend to work with; that is the paginated pages with the content. So that I can apply the generic HTML scraping algorithm to it. 
  • URLs
 
  • Then iterate each URL, using NokoGiri, and use the XPath explained above to find the “div” for a store to scrape.XPath


  • Thereafter I grab the specific data I need using “css selectors” found in NokoGiri; Selector
 
 
 
             Lastly, I make use of .gsub(/s+/, “”) to remove any spaces that are not necessary. That’s it really, nice and simple.
  • Gsub



Code:

 

require ‘rubygems’
require ‘nokogiri’

require ‘open-uri’
#Create File for Output
$stdout = File.new(‘console.out’, ‘w’)
arrPages = Array.new
pageLoc = 10
#First Page (396 paginated pages)

arrPages.push “http://x.x.com/type/supermarkets/any/supermarkets/S0914E/”

 

for i in 1..396

arrPages.push “http://x.x.com/type/supermarkets/any/supermarkets/S0914E/” + pageLoc.to_s()

pageLoc = pageLoc + 10;

end
arrPages.each do |pageToScrape|
page = Nokogiri::HTML(open(pageToScrape))

page.xpath(“//div[starts-with(@class,’list-directory_entry_’)]”).each do |store|


result = String.new

iUrl = String.new

array = Array.new

 

# Get Details [Name] + [Location]

array.push store.css(“h2 a”).text + “|”

array.push store.css(“.list-details”).text + “|”
# Get About
# Get’s the More Info Page, filters that

iUrl = store.css(“.list-entryInfoBar a”)[0][‘href’]
infoPage = Nokogiri::HTML(open(iUrl))

array.push infoPage.css(“.phone”).text + “|”

array.push infoPage.css(“.fax”).text + “|”

array.push infoPage.css(“.email”).text + “|”

array.push infoPage.css(“.web”).text + “|”

array.push infoPage.css(“.address_1”).text + “|”

array.push infoPage.css(“.address_2”).text + “|”

 

puts array.join{” “}.gsub(/s+/, “”)

$stdout.sync = true
end

sleep 20

end


Helpful Links

  1. NokoGiri Tutorial
  2. Ruby in 20 minutes
  3. Other Ruby Help
  4. Bastards Book of Ruby

 

 

Don't be shellfish...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone

Sencha Custom Build (ExtJs 4.0/4.1)

I cannot tell you, or express the deep frustration and anger I feel when a company who is so public, and who create such good software produces a tool to fulfill a desired task, but the documentation is near non-existent, the support lacking, and the tool itself, a piece of “junk” from the pits of hell. <rant over Sencha>

Moving along, if you want to build custom ExtJs, cause obviously the default one is too big to be used on production websites; here is the process to go about:

  1. Read This with a focus on the new MVC model as well as Sencha SDK –http://www.sencha.com/learn/getting-started-with-ext-js-4/
  2. Download the SDK (version 2 and not 1.2.3)
  3. Huge thanks to Sottilde – http://www.sencha.com/forum/showthread.php?203663-Sencha-SDK-Tools-2.0-and-ExtJS4-The-Missing-Docs (this is a must) – make sure you download the new PhantomJS file
  4. On the latter part of that forum, I posted my index-build.html, my configuration file (Layout.js) and some tips as well (especially if you using ASP.NET)

Hope that helps ya!

Don't be shellfish...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone

ExtJs Double Load

I recently starting working with ExtJS, moving away from jQuery UI Layout for a bug in their “splitter”. This was not fixed by them, despite my bug report. They did make an effort which  I appreciate. But I’m getting side-tracked. The problem I was experiencing in migrating to ExtJS was that I had an iframe that was loading in my “center” but it was loading twice.

No matter what I did, it just reloaded twice. Whether I added it with $(document).ready(). The solution was to add it to my “ExtJs” layout configuration, and success:

Don't be shellfish...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone

Notes On JavaScript

  1. JavaScript has nothing to do with “Java”, not is it an incomplete language because of that latter – “script”.
  2. JavaScript is a “Functional” programming language
  3. Best Book on JavaScript – http://books.google.co.za/books?id=2weL0iAfrEMC&printsec=frontcover&source=gbs_ge_summary_r&cad=0#v=onepage&q&f=false
  4. JavaScript has Prototypal Inheritance – where objects inherit from other objects. Not classes. This is a class free language.
  5. Javascript makes use of Lamba – use of functions as first class objects
  6. Only one number type in JavaScript – and represented by a 64-bit floating point (double)
  7. NAN – not a number (divide something by zero = NAN). It’s toxic – any arithmetic operation with NAN as an input will have NaN as a result. NAN is not equal to anything; NAN is not NAN
  8. Number(value) – converts 
  9. parseInt(value, radix) – good to put in radix (10 – decimal)
  10. Most useful Math function – takes the integer part of a Number
  11. Strings are “immutable”
  12. Strings you can use double or singe quotes
  13. Strings and Char are the same
  14. String(value) – turns number to string
  15. Null – isn’t anything
  16. Undefined – a variable uninitalized is initialized to Undefined
  17. Falsy Values – false, null, undefined, “”, 0, NAN
  18. All other values are “truthy”
  19. It is a object-orientated language
  20. Loosly – any value can be used, any function
  21. Use === for exact equals (yes three)
  22. JavaScript – every function will return a value 
  23. Object is unordered collection of name value pairs
  24. Object Literal – var myObject = {name: “Jack”, ‘goto’: ‘Jail’, grade: ‘A’} 
Don't be shellfish...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone

ASP.NET Web Garden – Optimization

A key thing to note about using Web Garden is that they require the objects to be [ Serializable ] so that they can be stored. They are stored in the database a Binary (VARBINARY).

Further to that, is that by Default on ASP.NET page – every page requires session state to be loaded during page initialization and to be flushed after the page has completed rendering. When using out-of-process session state, this means two round-trips to the state server for each page rendering.

You can set on the three options on the Page to determine what should be done

  1. EnableSessionState=true attribute (is default and cause’s the two round trips)
  2. EnableSessionState=readonly – here you can save a round trip, but only getting session information during initialization
  3. EnableSessionState=false – another save, which will not load or flush to disk when Page processed.

Image:EssentialASPNET10-6.gif

Further Reading (1) (2)

Don't be shellfish...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone