(C-x means ctrl+x, M-x means alt+x)
The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:
| <?php | |
| /** | |
| * Get human readable time difference between 2 dates | |
| * | |
| * Return difference between 2 dates in year, month, hour, minute or second | |
| * The $precision caps the number of time units used: for instance if | |
| * $time1 - $time2 = 3 days, 4 hours, 12 minutes, 5 seconds | |
| * - with precision = 1 : 3 days | |
| * - with precision = 2 : 3 days, 4 hours |
| # Simple bijective function | |
| # Basically encodes any integer into a base(n) string, | |
| # where n is ALPHABET.length. | |
| # Based on pseudocode from http://stackoverflow.com/questions/742013/how-to-code-a-url-shortener/742047#742047 | |
| ALPHABET = | |
| "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split(//) | |
| # make your own alphabet using: | |
| # (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).shuffle.join |
NOTE I now use the conventions detailed in the SUIT framework
Used to provide structural templates.
Pattern
t-template-name
| do ($ = jQuery, exports = window) -> | |
| class ActiveDataBinder | |
| constructor: (uid) -> | |
| # Use a jQuery object as simple PubSub | |
| pubSub = $ {} | |
| # We expect a 'data' attribute specifying the binding |
| <div class="col-md-8 col-md-offset-1"> | |
| <div class="panel panel-default"> | |
| <%= form_for(@weekly_performance_review) do |f| %> | |
| <% if @weekly_performance_review.errors.any? %> | |
| <div id="error_explanation"> | |
| <h2><%= pluralize(@weekly_performance_review.errors.count, "error") %> prohibited this weekly_performance_review from being saved:</h2> | |
| <ul> | |
| <% @weekly_performance_review.errors.full_messages.each do |message| %> | |
| <li><%= message %></li> |
This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.
###Array ####Definition:
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| #Model | |
| @user.should have(1).error_on(:username) # Checks whether there is an error in username | |
| @user.errors[:username].should include("can't be blank") # check for the error message | |
| #Rendering | |
| response.should render_template(:index) | |
| #Redirecting | |
| response.should redirect_to(movies_path) |
| // The reducer function looks at each action that comes in | |
| // and based on the type generates a new state based on the | |
| // previous state and any additional data the action carried | |
| const reducer = (state, action) => { | |
| switch (action.type) { | |
| case "COUNT_INCREMENT": | |
| return { | |
| ...state, | |
| count: state.count + 1 | |
| }; |