All posts by J Stassen

Code: Laravel Scope Query on a Model

Let’s talk a bit about scoped queries in Laravel. First here is a basic Book Eloquent Model with two handy scopes for type and fewerPagesThan.

//Book Model
class Book extends Eloquent {
public function scopeType( $query, $type ) {
return $query->where( 'books.type', '=', $type );
}

public function scopeFewerPagesThan( $query, $pages ) {
return $query->where( 'books.pages', '<=', $pages ); } }

Using scoping

I often see confusion when we try to use scoping. Some would expect the following to give them back all 'autobiography' books:


Book::type('autobiography'); // This works right? Nope!

But it doesn't. Scoping functions will only refine your query. For instance all the following are great examples of using scoping:


Book::type('autobiography')->get();
Book::with('author')->type('autobiography')->get();
Book::fewerPagesThan(500)->type('autobiography')->get();

Building up scopes

When using scopes to refine and filter down which Models to retrieve, you will always need to add a ->get() at the end. This allows you can chain multiple "scopes" onto each other as in the 3rd example. Basically it needs to know when you are done filtering down and when to actually hit the database.

So the 3rd example could be broken down like this to really drive home the point:


$maxPages = 500;

$books = new Book();
$books->type('autobiography');
if( $maxPages )
$books->fewerPagesThan($maxPages);
$opportunities->get();

In every case before the ->get() call $books var is a Eloquent/Builder that is being built up.

After the ->get() call $books var gets overwritten with an Eloquent/Collection that has been filled with our data from the database.

This is a very powerful and flexible to way to scope and filter down models that are in your database. It is better to filter them down with scopes in the DB query than filter down a collection that has already been loaded into memory. Make the your DB do some weight lifting for you. ūüėČ

Utility: Bootable ISO on USB Drive

I’ve given up burning ISOs to a disc. CDs are in the past. It took time to burn them, store them, and find them.¬†I have all my CDs/DVDs¬†in¬†ISO form¬†using¬†another awesome lightweight utility that creates ISOs.

YUMI – Multiboot USB Creator

YUMI is a utility I’ve been using to load ISOs to a bootable USB disk.¬†¬†The process is pretty dead simple and takes but a few moments to transfer an image to the USB disk.

  1. Choose the destination USB Device
  2. The type of ISO
  3. The source .iso file

YUMI-Multiboot-USB-Creator

Removing ISOs is equally simple via the View and Remove Installed Distors.

YUMI-Boot-Menu

Providing your system has the proper boot order to allow booting from a USB, YUMI will startup and ask what ISO you wish to launch. From there Рbusiness as usual.

Download

YUMI.exe (1.2MB)
Developer’s Site

 

Learning: Podcasts for the Curious Mind

Here are some of my favorite podcasts.

I’ve been on quite a podcast kick recently, just striving to absorb information. I am subscribing to more podcasts every week with little hope to keep up, much less listen to past episodes. The best began to quickly surface for me.

The Podcasts

Podcast Name
( 15min average length, 1.5x playback speed, Genre or Topics)
A sentence or two of description which includes a narrative of my opinion in places.

  • Radiotopia: 99% Invisible
    (15 – 30min, 1x, Design, Story Telling, Investigative Journalism)
    Stories about the other 99% of things designed that go un-notice and exploring their back-story.
  • NPR: Radiolab
    (20min – 60min, 1x, Story Telling, Investigative Journalism, Learning)
    Topic exploration with applications that are deep and unique. Encourages internal reflection and deeper understanding.
  • APM: Marketplace
    (30min, 1.5x, Market Impact, Investigative Journalism)
    A quality podcast about how markets are effecting different industries, life, and other economies Рinvestigating how it all plays together.
  • NPR:¬†Planet Money
    (20min, 1.5x, Market Impact, Investigative Journalism)
    A quality podcast about the strange and interesting places money finds itself. How money impacts our daily life in ways you might not expect.
  • a16z
    (20min, 1.5x, Interviews, Technology Trends)
    Interviews with impactful entrepreneurs and critical discussions around the current trends in the technology space.
  • HBR IdeaCast
    (20min, 1.5x, Business Management & Growth)
    Topics from the Harvard Business Review publication. Topics range for HR, Investors, Effectiveness in the Workplace, to Talent and Recruiting.
  • NPR: Stuff You Should Know (No longer recommended)
    (30min – 60min, 2x, Learning)
    They talk very slow and information density is low I certainly recommend speeding them up. Topics tend to very from simple¬†to things you’ve never stop to think about. Good for passive listening.

Apps: My top iPhone / iPad apps

This will be an ever changing list, of apps I am currently big fan of.

All apps are free, unless noted. ¬†I won’t bother to mention some of the more popular app.

Socail

Photography & Video

Finance & Money

  • Splitwise – Shared group expenses
  • Mint – Tack spending and savings trends, owned by Intuit and trusted
  • PayPal – Nice way to send / receive money
  • CardStar – Store your loyalty card numbers/barcodes on your phone.
  • LevelUp – Simple rewards and discounts at restaurants.
  • PaperKarma – ‘Unsubscribe’ button for junkmail in your physical mailbox

Travel

  • Waze – Map directions with traffic, cop warndings, and red light camera notices.
  • Google Maps – Best map directions
  • WunderMap / AccuWeather – Combined they make the best weather app
  • Hipmunk – Flight search tool
  • Hopper – Finding best time to fly

Productivity & Organization

  • AnyList – Shared group todo/shopping list
  • OneNote – App+Web note taking app that breaks things down into notebooks
  • RD Client – One of the better experiences for remote desktop

UX: Flat Design

I’ve grown to become quite opinionated about the recent Flat Design trend. Ironically at this time of writing my blog is using a rather flat design, however it still uses borders, dividers, and background colors which as you will see many flat designs ignore or drop.

Gripe with Flat Design

Microsoft chose grey on light grey on white with their new flat design in MS Office 2013. This is very hard on the eyes and makes finding sections / ideas in the UI take a bit of studying to understand. I won’t even go into Windows 8 start screen or new desktop UI which both have other issues. Apple in iOS7 appears to be choosing border-less white divs with section breaks just being a larger padding between items. There is little to no affordance.

If these are the leaders, I’m concerned.

Some are using Flat Design well

However, in my opinion some companies are pulling off flat design well. For instance AVG 2013, they chose very intuitive layout that makes the UI simple and understandable, I don’t use the product, but I would trust my grandma to run it. Other fine examples are the games OLO, Letterpress – check them out.

Some companies are going for a Almost Flat Design, which I can agree is a good compromise, making things a bit more intuitive and have substance. Examples include LinkedIn app, Google products, Facebook. And now with Google announcing Material Design that becomes even more clear.

What I’m saying?

It’s not about emulating the ‘real world’ as it is giving items a sense of sections, and layers. First sections, A menu bar or sidebar ought to look separate from the content. More specifically, static vs. dynamic content ought to be separate. Second layers, if a menu has a drop down that is going to cover content, there ought to be (even a subtle) hint/shadow that is is currently above the content and has a border to visually show its identity. Users will intuitively know there is content under it and not mistake it being part of the content. And not to say ‘Real world’ is what I’m suggesting, if I were then I would want SPST Push Button or NTE 54-533 Switch Rocker.

Where are we heading?

I could dig in further with some closer examples, but I feel User Experience seems unfortunately been¬†placed on the side in many flat design cases. It seems we are in a UI counter-culture mood swing from our overdose on 3D buttons, and huge drop shadows. I get it. We just have to be careful to consider usability, intuitiveness, learnability, human errors, and other UX items. Maybe it is just poor flat design that I’m not a fan of or haven’t given it a full chance, but I’m concerned.

Thankfully with Google talking about Material Design, perhaps we can start to head in a smarter direction.

UX: iOS 8 Notification scroll state

Ever open Notification Center and find that you’re partially scrolled down? As of iOS 8 the scroll state is persisted from last time it was open.

IMG_6288.PNG

This causes confusion:
-additional gestures to see recent notifications
-unclear ordering or recency when view is show
-if scrolled by chance to only have one app banner, may be surprised to find additional notifications above.

Possible fix:
The scroll state could be reset after a new notification and after a timeout (perhaps 1 minutes). Preferably the state would be reset every time it is reopened always showing the freshest state.

Code: Backbone.js Selecting Elements with jQuery

Found a very nice succinct way to get a jQuery rapped DOM element that is within a subView in Backbone. using `this.$( )`. This is pretty handy because it traverses only DOM elements within the current view instead of the entire DOM tree.

Inside a backbone view:

this.$('.myElement')

Inside an event

this.$('.myElement') or $(argument1.currentEvent).find('.myElement')

Inside a Model / Collection:

You shouldn’t, that’s the View’s responsibility

Opinion: Zero-Rate Content a Threat?

I got thinking about¬†‘zero-rate content’ from internet providers. ¬†That is, websites and content that are¬†free to you simply because you are their customer.

It already exists

It is¬†really just a different way to phrase the net-neutrality issue issues. It’s really just a nuance of the ‘fast-lane’ concept that different packets are treated differently by speed, price, quality.total count allowed.

I recently experienced this when I traveled abroad, thus I know it exists. I was talking with AT&T before I left setting up my abroad minutes and data. The representative was very proud to inform me I could use the AT&T Information and AT&T wifi locator apps with no data fees, that is, they would pro-rate any data usage that I used within those apps. I could help my self but laugh at loud at them, and ask if he was serious… then I made a statement about net-neutrality.

I found it rather curious that they could detect the packet difference. I suppose it only makes sense, all you have to do is read the packets header to see its intended destination, check it against a white-list of “We’ll pay for that one, its on us”. According to the representative, they do something very similar to that, though he wasn’t familiar with what I meant by packet inspecting.

All the same, it is sort of a nice gesture by AT&T saying we’ll pay / help you out whenever you’re checking status on your account. You don’t have to worry if you are over your data cap ever when checking information about your account. I kinda dig that.

Data isn’t free

You’ll note that I said pro-rate the cost of the packet. Data isn’t free, cheep, but not free. In the international case it is a bit more expensive to get it from where I was to their servers, AT&T paid for that. Similarly when back home, even through AT&T towers the packets will have small cost, even if it is their packet. It’s just a matter of splitting the costs between the user and the provider.
In the case of video sharing sites..

Here is my theory: It won’t be sustainable for a provider like Verizon or AT&T to maintain a site with media, though they may be trying.

I think there are barriers they will run into

  • I find it hard to believe that any telco will produce a good enough app/site that wins the world over like a youtube or netflix.
  • They will be restricted to their shows they produce or partners produce, and maybe pull it from places like netflix. However that would hurt them greatly since adoption of a new platform would be low. Comcast is doing pretty good on this I suppose.
  • Cost of a video servicing infrastructure (server farms throughout the country/world)
  • Reliability of a video servicing infrastructure (remember old old youtube and netflix problems?)
  • Community (hard to get get viewers to jump to a place with lesser content)
  • Fragmentation (only customers of said telcom gain benefits aka smaller subset of world population. Presumably other providers would have their own deals)
  • Profitability (If this is done, it would be for money, where is the the money? Ads? Probably not. New customers? Will it really entice enough new clients to join the telco?)
  • Abuse, give away something for free, people will abuse it, then you need to cap it. Enter irony.
  • Why not partner with an existing provider, say Netflix or Hulu?

To widen the scope again to zero-rate content (cost paid by telco). It will exist, probably not for video streaming, but for other sites and partners.

Is zero-rate data a threat?

I’m not sure I see zero-rate content as a huge threat, (though a threat all the same) mainly since¬†each provider would¬†have a different selection of partnerships.

Opinion: Graph Search

I am a big fan of the flexibility of graph search. Graph search has been around since before March 2013 when I wrote a few notes about my favorite searches. I figured it was time to share a few.

I have met people that I remember a list of facts about and have been able to find them via the Graph Search. It is simply fantastic.

Here are some fun uses of Graph Search on Facebook:

  • “My friends who live in New York”
  • “Places in Chicago my Friends have been to”
  • “Friends of Joe in Backbone.js Developers Group”
  • “Friends of My Friends who like Swing Dancing”
  • “My friends who are Females who are Single”
  • “Events my friends are going to”
  • “People named Christopher who live in Seattle, WA who like Passion Pit”
  • “Friends of Beth named Tim”
  • “Mutual friends of Beth and Jake named Tim”