background preloader

Learning Vim in 2014

Learning Vim in 2014

Effective Rails Development with Vim If you are new to Vim, be sure to read my introduction as it will help prepare you for this article. Here, I am focusing on using Vim for effective Rails development. Rails Plugin Tim Pope wrote a very useful Vim plugin called [Rails.vim][1] that provides a lot of great functionality, including enhanced syntax highlighting, partial extraction, and easier navigation in a Rails project. Installation Using Vundle As we saw in the previous tutorial, it’s very easy to install any plugin using Vundle. After that, type :PluginInstall, hit enter, and Vundle will do the rest. All of the commands in Rails.vim are namespaced under the letter R. Jumps Using gf There is an exception to the rule that every Rails.vim command begins with the letter :R, which is gf (short for Go to File). Also, if you try this on any method, Vim will also take you to the file where the method is defined, even if it is a Rails built-in method. Navigation in project files Open Files in Split Windows Open Files in New Tabs CTags

Elegantly using in backbone apps Backbone.js is my favourite modern MVC framework for client-side javascript. Not that I’ve seriously tried any others … simply didn’t feel the need to. The way apps are usually organised is Backbone is that data is king. A view reacts to some user action and changes some data in a model. Everybody who’s listening for that change then reacts and does something either to their view (adding something new on the screen, say) or data gets changed. Whatever, the important part is events are usually communicated through state changes. Events Despite the god-like status of models, most of your code goes into views. data changesuser actions Listening to data changes is easiest done in the initialize function, something like so: Okay, but what about user actions? That can get unwieldy real quick … Backbone has us covered with the events hash: Both of these approaches result in this.button_clicked being called when a user clicks the button. But what happens when you add to the mix? Events

FileBot - The ultimate TV and Movie Renamer / Subtitle Downloader Nested Views in Backbone.Marionette A couple of weeks ago we published an article about Functional Programming that used a bagel as an example. It was very well-received, so why not try again? This week @samccone is back with the delicious carbohydrate to talk about Nesting Views in Marionette.js. Nesting views can be a difficult task at first glance. Marionette makes your life easy with an elegant view layer that simplifies complexity and hides the implementation details. This allows you to focus on getting things done instead of reinventing the wheel. Suppose that we are tasked with creating an interface that covered the process of making a bagel sandwich. Making a sandwich is pretty darn complex though. Let's assume that the output we need to generate looks looks like this. It might look like this (click through to see code example): Programmatically rendering this bagel according to our data seems like it will be a pain. The three pieces we will use are Let start out with a foil Region that will hold our bagel.

Using Marionette to Display Modal Views For a while, I’ve been thinking about how best to handle showing modal dialog boxes for my applications while utilizing Backbone views. A lot of interesting ideas passed through my head, but none of them seemed exactly right. Then I saw a post by Derick Bailey where he described how he uses Marionette’s Regions to handle the work. His post is a bit on the old side and Regions have changed a bit since, so I decided to look into how to do it myself. The Issues There are several issues surrounding creating modal dialogs just with a view. Along with that, we lose reusability. The Solution Now that we know we need to pull the modal functionality out of the views, it’s just a matter or figuring out where to put it. All we need to do is augment a Region to call the plugin’s method for showing the modal when the view is shown, make sure to hide the modal when the view is closed, and close the view when the modal is hidden. There are a few things worth noting here: Now it’s simple to use: Conclusion

Graphical vi-vim Cheat Sheet and Tutorial Learning vi or vim is not easy. But it doesn't have to be that difficult, either. It is, in any case, faster, more powerful, and more productive than editing with any other editor, so you would do very well in investing the time and effort to learn it. Being a vi lover myself, I came up with the idea of providing a graphical cheat sheet for those learning vi or vim, and I also found out it was a very good way to structure a tutorial. By the way, I recently published the definitive article explaining why vi/vim editing is so much better than regular editing. Graphical cheat sheet This is a single page describing the full vi/vim input model, the function of all keys, and all major features. Graphical cheat sheet based tutorial The tutorial above is structured in 7 lessons that cover the major commands in vi/vim. Notes vim is an incredible editor by Bram Moolenaar, based on the original vi by Bill Joy, adding a ton of improvements over it. Relevant links Why, oh why, do those #?

Backbone.js Tips And Patterns Backbone.js1 is a popular open-source JavaScript “MV*” framework that has gained significant traction since its first release a little over three years ago. Although Backbone.js provides structure to JavaScript applications, it leaves a lot of design patterns and decisions up to the developer, for better or worse, and developers run into many common problems when they first begin developing in Backbone.js. Therefore, in this article, we’ll explore different design patterns that you can use in your Backbone.js applications, and we’ll look at many of the common gotchas that trip up developers. 2Applications, like buildings, are best built following known patterns. (Image: Matthew Rutledge3) Perform Deep Copies Of Objects Link JavaScript treats all primitive-type variables as pass-by-value. var helloWorld = “Hello World”;var helloWorldCopy = helloWorld; For example, the code above will set helloWorldCopy equal to the value of helloWorld. And let’s say you create a new person object: (al) (ea)

Casual Gameplay Design Competition #6 — "Explore" Welcome to the 6th Casual Gameplay Design Competition! All entries are available to play immediately.Each entry is represented by an icon on the left.Clicking on an icon will reveal more information about the entry. Click the "Play" button that appears to play the game.A section for comments will also appear, so please provide supportive feedback and constructive criticism to the game designers.The competition judging period is over. All entries and their icons have been randomized here and their order stored in a cookie so that you see the same order each time you visit.

Using a controller to change content in a marionette.layout · marionettejs/backbone.marionette Wiki A question was asked on IRC: The trick is to use an object that coordinates between all of the views and the layout. This is often referred to as a "mediator" - from the mediator pattern. Marionette provides aController type that fits this need perfectly. Use of the controller is simple enough, then: A Visual Guide to Marionette.js Views | Art & Logic Blog When I first began working on the front-end to this one interactive application, I decided to just write a few lines of JavaScript to handle some miscellaneous things behaviors on the front-end. However, that soon turned into a completely interactive front-end with thousands of lines of JavaScript trying to hack together the entire DOM. Luckily, Backbone.js came to the rescue which was later accompanied with Marionette.js. To help visualize the difference (and similarity) of layouts, regions, composites, collections, and item views, I’ve created helpful diagrams to visually demonstrate how the pieces of the puzzle fit together. Layouts Useful when you need to nest multiple views inside of a container and occasionally need to swap them out with other views or show/hide them. Layouts are the top-level component in your application. Regions What can go inside a region? Using our previous example of the word processor application, the layout would be created with the two regions. Item Views

Tmux and Vim, get married. | Garrett Dawson | thedrearlight Vim and Tmux are an excellent choice for a modern develpment environment on Mountain Lion. I describe how to combine create such an environment using homebrew. Using a rad, aesthetically pleasing, and efficient development environment is so crucial to having a good day. I’m going to describe mine, and give you the set of links from which I’ve assembled this confection. We’ll be using: Vim & MacVim First, one must install MacVim. $ brew install macvim Now we’ve got MacVim, which is a gui flavored Vim. The Vim that comes stock with OSX sucks all sorts of members. Installing Vim from hombrew/dupes can be sort of tricky, though. I manually changed what version of Vim is fetched from Google’s code repo. $ brew tap homebrew/dupes $ vim /usr/local/Library/Taps/homebrew-dupes/vim.rb url ' :tag => 'v7-3-617' $ brew install homebrew/dupes/vim Boom-Bapper! I still bounce back and forth from MacVim to Vim, though I’m getting more in the habit of sticking to Vim. Janus Tmux

Developing Backbone.js Applications - By Addy Osmani (@addyosmani) Available free for open-source reading below or for purchase via the O'Reilly store. Pull requests and comments always welcome. Prelude Not so long ago, “data-rich web application” was an oxymoron. Traditionally, web applications left the heavy-lifting of data to servers that pushed HTML to the browser in complete page loads. Think of the Ajax shopping cart which doesn’t require a refresh on the page when adding an item to your basket. The rise of arbitrary code on the client-side which can talk to the server however it sees fit has meant an increase in client-side complexity. Thankfully, there are a growing number of JavaScript libraries that can help improve the structure and maintainability of your code, making it easier to build ambitious interfaces without a great deal of effort. Begin with the fundamentals, work your way through the exercises, and learn how to build an application that is both cleanly organized and maintainable. Target Audience Credits <!

Part 2: Marionette Application, Modules and Controllers | “Marionette Maps” is an on-going series on building a loosely coupled, configuration driven map viewer using Marionette.js. Read Part 1 TL;DR; Version This covers Marionette Application, Module, Controller, ItemView, CollectionView and a little on Events. Code: github tagged v0.0.2 Demo: The Long Version… Working from the rough layout I created in the last post, the next thing to do is dive into the javascript. First, grab Marionette and it’s dependencies from Creating the Application The next thing we need is a Marionette Application. At this point the application is super simple as shown in this gist… As we develop the application we will setup more Regions – right now we just have the one region for the tools – and this is the container that will hold our tool items in the upper right. The Navbar: Module + Controller The top bar of our app has a few things to manage. Ok, now we need to write some code to manage the Navbar. Events Code

Introducing Backbone.Radio | Marionette.js Blog Marionette comes bundled with a library called Backbone.Wreqr, and in the coming months we will replace it with a new library by the name of Backbone.Radio. Radio is heavily inspired by Wreqr, but it was rewritten from the ground up. I wouldn’t be surprised if you’re unacquainted with Wreqr. In fact, I would wager it’s one of the lesser-used pieces of Marionette. This post will outline our decision to rewrite and replace Wreqr. What is Backbone.Wreqr? Backbone.Wreqr is a collection of three messaging patterns. There’s much interesting discussion about the pros and cons of event-driven architecture, but it’s beyond the scope of this post to get into those things. Why rewrite Wreqr? The decision to rewrite a library is a risky one, and it’s not an option I would normally consider for a library as popular as Marionette. We think that the risk of fragmentation with this rewrite is low. * One bit of undocumented, inconsistent functionality from Commands has been removed. The benefits of Radio

Related:  Veille technologique