TJ Singleton

Software Engineer, Baptist Preacher

How Deep Is Your Love?

He that loveth not knoweth not God; for God is love.

1 John 4:8

Have you ever taken (or been forced to participate) in a “Love Quiz” or “Relationship Quiz.” I can’t recall ever have, and I probably wouldn’t admit it either if I had. I have seen them portrayed on TV. I did a little research to make sure I knew what I was talking about. I did a quick search on the ol’ google and was not surprised at the popular publication that was the 2nd result. I clicked in to find they many different quizzes. 20 alone that were considered love and relationship.

John has presented us with a little relationship quiz. It’s not a very long quiz at all. Just a single question you have to answer. Do you love one another?

The thermometer for you relationship with God is your relationship with the brethren. In verse 7, John states, “Beloved, let us love one another: for love is of God; and every one that loveth is born of God, and knoweth God.” John argues that if love is of God and God is love, then you demonstrate your relationship with God when you share that love with one another.

In verse 9-11, John reminds us of the wonderful proof of God’s love in that he “sent his Son to be the propitiation for our sins.” He did so when we did not love him. That is the kind of love that we should have one for each other; Unconditional, sacrificial love.

John challenged us to love each other and to allow that to be the gauge on our relationship to God. How’d you score?

The Right Order

Glory to God in the highest, and on earth peace, good will toward men.

Luke 2:14

This Christmas season, I have spent some time meditating on this verse. I must admit, I have never given it much consideration. Maybe I passed it over because of it’s familiarity. Maybe I missed it because it seems like a common, quaint saying such as Tiny Tim’s “God bless us, every one!” I realized this year though that this was the birth announcement God sent the world of the birth of his son, Jesus Christ and as such a precious verse.

I am ashamed to admit that I’d reckon if we were penning this chorus we might have left out the first part, or at least put it last. We often act as if God’s primary concern is serving us. I think the angels got it right when they put the glory of God first. Sure, God showed his good will towards mankind in giving us the Prince of Peace who would die for our sins, deliver us from the justice we deserved, and grant us peace with God. But, O’ how glorious is God for doing so. In the ages to come we will still be worshiping our Father for his kindness towards us in Christ Jesus. (Eph 2:7)

Just as the Angels started right by putting God’s glory first. We should start this year right by doing the same. After all, if the Angels have praised him for his mercy to us, should we be found wanting in our praise to him?

The Hope of Christmas

For unto us a child is born, unto us a son is given: and the government shall be upon his shoulder: and his name shall be called Wonderful, Counsellor, The mighty God, The everlasting Father, The Prince of Peace. Of the increase of his government and peace there shall be no end, upon the throne of David, and upon his kingdom, to order it, and to establish it with judgment and with justice from henceforth even for ever. The zeal of the Lord of hosts will perform this.

Isaiah 9:6-7

If we are not careful at Christmas we will only look back towards the past. It’s seems natural to do so. We have just come out of Thanksgiving where we examined the blessings of God on us in the last year. We’re quickly approaching the end of the year and the media begins recapping the most memorable events. As Christians, we know that Christmas is a time to celebrate the birth of Christ, an event which took place over two-thousand years ago. Why wouldn’t we focus on the past?

However, as we read the prophecy of the birth of Jesus, it points past just the events surrounding a manger. It points past today. It points to our blessed hope in the future.

The Christmas story doesn’t end at the temple with Simeon and Anna. It doesn’t end with Christ on the cross. It doesn’t even end with his resurrection. It ends with his revelation!

Yes! Jesus was born of a virgin. Yes! Christ died for our sins. Yes! His sacrifice was accepted and he rose that glorious third day. And Yes! He will be revealed as the King of Kings and Lord of Lords. He will rule and reign in righteousness. Every knee will bow and every tongue will confess that Jesus Christ is Lord!

Remember to look forward to the hope of Christmas. Even so, come, Lord Jesus.

Evan Light - Building a Recommendation Engine With Ruby and Redis

Context: Social soccer network.

  • Wanted a live feed of soccer data.
  • Display popular and relevant posts in near real time

Approximation

  • Popular: easy, measurable
  • Relevant: relative, subjective

Why didn’t we use better statistical methods? Clients just wanted to build it and trusted me. I pushed for it.

Why ruby? I thought Java might be a better fit. Java is fast. Client’s dev knew ruby.

Case Study

Nouns: User, Post, Comment, Team, Player

Verbs: Submit, Comment, Like

Popular based on comments, likes, and “taste makers”. Taste makers were influential people.

Relevance based on likes, comments, and if the term was mentioned in the past.

Algorithm was O(n2), but we were able to limit n to 3 days.

Lessons learned

  • Use strings instead of hash when need to put a time to live on the hash value
  • Minimize chattiness with pipelining or LUA scripting
  • Prune old data by adding a timestamp and remove on insert
  • More functional programming. Already stateless. Increase referential transparency.
  • Us a runtime faster than ruby

Notes from RubyConf 2013

Evan Light

Casey Rosenthal - Fault Tolerant Data: Surviving the Zombie Apocalypse

We are talking about distributed key-value databases.

There is SQL or other. This is why I find the other category so exciting. New databases are coming out that change how we model and what is possible.

When you search google, you expect it to return results. You don’t expect it to return the same results 5 minutes later or even in a different location. You don’t expect that it has all the latest information instantly available. We realize it takes some time for the newly indexed data to show up.

When you open your email, you expect it to be available. It may not be consistent. You may have messages in one client that haven’t been synced to another. You may have queued messages for delivery.

The expectation of the web is not one of a “high consistency” system. It is a the expectation of “high availability”. SQL has a strong idea of consistency.

In SQL, we have a use case, then model our data the best we can, and present it to a client.

In key-value, we have a use case, then figure out what we want to present to a client, then model the data.

The more complicated your query planner the harder it is to scale. Key-value is the simplest query planner.

Example Application: Enter zombies.

The CDC has 2 data centers on the east coast, 2 data centers on the west coast and one near Texas. Zombies take out the east coast data centers. Because the east coast never goes down.

Fault tolerance is a optimistic view that bad things will happen. In a fault tolerant system, that’s ok.

Data is stored like:

1
2
3
4
5
6
7
{
key: "patient_0",
data: {
    dna: "DNADNADNADNA",
    zip: 30019
  }
}

How do you find all the zombies in a zip code? Create an inverted index.

1
2
3
4
{
key: "zip_30019",
data: ["patient_0", "patient_1", ...]
}

Where to store the index?

  • Document Based: partition index w\ document. Good for write, bad for read.
  • Term Based: index outside document. Good for read, bad for write.

Use case should determine the paradigm.

How to deal w\ conflict in distributed system? The network between the west coast and Texas goes down. Someone runs a new wire between. patient_0 was updated in both the west coast and Texas data centers while the network was down.

How do you reconcile?

  • You don’t. Offer both records on read and let the client deal with them. “Sibling” records.

  • You use data types that can self resolve. Simple case is an array that only grows. You just union the list. Theses are called CRDT (Conflict-Free Replicated Data Types).

The only way to ensure uniqueness is to use immutable data.


Notes from RubyConf 2013

Casey Rosenthal

Gravy Gestapo

And lest I should be exalted above measure through the abundance of the revelations, there was given to me a thorn in the flesh, the messenger of Satan to buffet me, lest I should be exalted above measure. For this thing I besought the Lord thrice, that it might depart from me. And he said unto me, My grace is sufficient for thee: for my strength is made perfect in weakness. Most gladly therefore will I rather glory in my infirmities, that the power of Christ may rest upon me. Therefore I take pleasure in infirmities, in reproaches, in necessities, in persecutions, in distresses for Christ’s sake: for when I am weak, then am I strong.

2 Corinthians 12:7-10

The leaves are changing colors. Sweaters are being brought out of storage. Stores are stocking up for all sorts of frenzied sales. It is turkey time once again and you are guaranteed to be interrogated by family and friends.

“What are you thankful for this year?”, they will ask with a piercing stare. You will hear others start to rattle off their list of good things that have occurred to them recently. Uncle Joe will spout out the same list he has since 1995 when the Braves won the world series. However, I can’t ever recall sickness, heartache, trial, cancer, or death ever offered in response.

Paul alleged that he gloried in his infirmities. He claimed that he was thankful that God had given him this thorn in the flesh. He contends that he can find pleasure in it. How could this be?

Paul had realized that this trial that he was facing was ordained by God for his benefit. We don’t have the same understanding or perspective as God. Our troubles may seem designed to break us, but they are purposed to build us. Paul understood that God was molding him into the image of Christ.

This incident cause Paul to seek God for strength. Paul learned more about trusting the Lord, resting in God’s abilities, and enjoying the Father’s grace. This trouble demonstrated the power of God in Paul’s life. It was an advertisement for God’s glory. Paul could look at what he was learning. He could look at what he was teaching others. He could look at the comfort God was giving him. He could look at all this and say, “Thank you, Lord, for this thorn.”

So I ask you, “What are you thankful for this year?”

Jason Clark - Extending Gems

Pass it in

  • Loggers: Let them hand you an Object. Dependency Injection is easy in Ruby because of Duck Typing. Still has risks. Provide a spec to communicate contract.

  • Instrumentors: Example Excon. Only one instrumentor allowed. Can’t use without stomping on someone else’s instrumentor.

  • Backends: Example DelayedJob with ActiveRecord.

  • Gem Specific: Example Resque’s hooks. Has great docs.

Events

Notify external code important things have happened. Example simple events (on github).

Surfacing: You should front load. Make it easy to access. Example: NR::instance.events.subscribe { ... } or Resque.after_fork { ... }.

Be wary of things that are accept only one thing. Older versions of Resque only allowed one hook. Things would get stomped over.

Event ordering is iffy. If important, maybe do something different.

Middleware

Example is Rack. Have to be careful with the env. Everyone can modify. Can have a problem of seeing the whole chain. Sidekiq does a good job of seeing the whole chain.

Lifecycle

Forking: provide before & after hooks. Not everything carries over in a fork. Forks, Threads and Locks combined can be trouble.

Loading gems: Unicorn has two models for loading up. Preload: true or false. In one the hooks are called before the gems are loaded. Gems can’t take part in the hooks.

Names and Paths

Paths: Sequel.plugin :newrelice expects files to be in your libs top level directory. Maybe it’d be better just to provide a class/module.

Generic Names: ActiveRecord, DataMapper, and HTTPClient are very generic. Now you can’t use those names in your app. Be careful about using stdlib names like Logger, Thread. Constant resolution issues may occur. Gem writters should be careful about module lookup. Be explicit and use the :: operator as needed.

Config

YML was made for it. YML + erb is bearable. Maybe just use ruby instead.

Be sure to expose the configuration to in system and not just via file. File only is hard for gems to work with. Think Lib.configure { ... }.

Docs

README, most people won’t get past it. Sidekiq has a great experience. Don’t bury important things in the docs.

Make versioning part of your docs.


Notes from RubyConf 2013.

Matz - Living in the Fantasy Land

Escapism: Visiting the place of the unicorn

A story of 2 fantasy lands.

The first is Distopia.

  • Out of uni worked at a enterprise, waterfall shop. Lots of detailed documentation.
  • Felt wrong, couldn’t pinpoint why. 20 yrs of exp later gives insights.
  • We has false assumptions:

    1. Know what we make: Software isn’t physical. Hard to reason about. Not governed by physical laws unlike a building architect.

    2. Know what we want: Software is hard to imagine. Clients often would say, “That’s not what I wanted.” even after we delivered what they asked for. We don’t know what we should do to maximize business value.

    3. Know what will happen: We don’t know the future. We had the wrong forecasts. We don’t know anything. We ignored our ignorance.

2 Strategies

  1. Conservative: Learn from the past
  2. Ostrich Algorithm: Ignore everything and wait. Good strategy… when situation will recover. Easy for us to choose. Instinctual.

Be careful, unless you go forward with a false assumption.

In the past computers, software, and network was expensive. Possession was power. Had to optimize not to fail.

Now, computers, software and network are universal and ubiquitous. Possession is not enough. It’s all cheaper. We have better tools. We have better languages. Ruby. (And the crowd goes wild)

We have open source software. Great learning tool. Before, you didn’t have access to an operating system to read and study. Now we do.

We can collaborate on the internet. Social coding. We can do greater work than our own ability.

We have more power, freedom, joy.

However, we can’t ignore the mess. It’s reality. What we need is GC, garbage collectors. Not memory management, but waste. We rely on them to get the job done.

They are who:

  • Write books
  • Give talks
  • Write frameworks
  • Write languages
  • Write gems

As the open source community we must move forward or die like a shark.

A programmer is a creator. Come join open source software as a contributor. Make the world better. Be a GC. Take a part in keeping up the fantasy land. The fantasy land facade is a direct result of the efforts of GCs.

Examples: Contribute to CRuby. Fix bugs in OSS. Give a talk at a conference.

Create a great fantasy land. Take part and change the world. It’s the key to OSS and Ruby. I’m not a great programmer. I create bugs, but I respect myself and change the world.


Notes from RubyConf 2013.

How to Be More Attractive

Rejoice in the Lord, O ye righteous: for praise is comely for the upright.

Psalms 33:1

There are 4,200,000 results on Google for “how to be more attractive.” Google reports that the current trends for those exact search terms is 100 people a month and there have been 5,353 searches since September 2006. I have wonderful news for you and all those people desiring to answer this question once and for all. There is an absolute authority on how to be attractive. No, you won’t find the answer within the pages of the magazines lining the supermarket aisle. It is however contained in one of the best selling books of all times.

So you want to know how to be more attractive? It’s really, really simple. Praise the Lord. Yes sir, according to God’s word praise is comely for the upright. We don’t use that word comely too often today, but it’s just another word for attractive. I admit, this wonderful truth isn’t going to help us to win any beauty pageants. It does however teach us how to please God.

What does God find pleasing? What appeals to him? Worship. “Rejoice in the Lord,” demands the Psalmist. We talk about wanting a move of God. We say we want see God manifest his presence. Having said that, are we rolling out the red carpet for him? Are we inviting him with our praise?

Why don’t you take a moment right now and gussy yourself up for God with your praise?