(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
:
Creating a Multi Page Form in Rails | |
Creating a multi-step wizard-like form is pretty difficult in Rails. | |
Especially when trying to apply REST and validations. There are many | |
different approaches to this problem, and the right one depends largely | |
on your application details. Here are four options, and then my final | |
recommendation. Skip to that if you're in a hurry. | |
1. Create the model at the beginning on the first page of the form, and | |
have each successive page update the model. Validations are tricky |
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
class RSpec::Core::Example | |
def passed? | |
@exception.nil? | |
end | |
def failed? | |
!passed? | |
end | |
end |
function slugify(text) | |
{ | |
return text.toString().toLowerCase() | |
.replace(/\s+/g, '-') // Replace spaces with - | |
.replace(/[^\w\-]+/g, '') // Remove all non-word chars | |
.replace(/\-\-+/g, '-') // Replace multiple - with single - | |
.replace(/^-+/, '') // Trim - from start of text | |
.replace(/-+$/, ''); // Trim - from end of text | |
} |
/* | |
Node.js, express, oauth example using Twitters API | |
Install Node.js: | |
curl -0 http://nodejs.org/dist/v0.6.11/node-v0.6.11.tar.gz | |
tar -zxf node-v0.6.11.tar.gz | |
cd node-v0.6.11 | |
./configure | |
make | |
make install |
#!/usr/bin/env python | |
"""(c) gorlum0 [at] gmail.com""" | |
import random | |
from sys import maxsize as inf | |
def merge_sort(A): | |
"""merge-sort which counts inversions""" | |
def merge(L, R): | |
m = len(L)-1 | |
B = [] |
-- I'd gladly pay you Tuesday for a hamburger today! | |
-- OK, see you next Tuesday. | |
SELECT * | |
FROM generate_series | |
( | |
current_date + '1 day'::interval, -- in case now() is same dow | |
current_date + '7 days'::interval, | |
'1 day' | |
) as s(a) |
From Meteor's documentation:
In Meteor, your server code runs in a single thread per request, not in the asynchronous callback style typical of Node. We find the linear execution model a better fit for the typical server code in a Meteor application.
This guide serves as a mini-tour of tools, trix and patterns that can be used to run async code in Meteor.
Sometimes we need to run async code in Meteor.methods
. For this we create a Future
to block until the async code has finished. This pattern can be seen all over Meteor's own codebase: