$ rails g model User
belongs_to
has_one
=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 Api::RegistrationsController < Api::BaseController | |
respond_to :json | |
def create | |
user = User.new(params[:user]) | |
if user.save | |
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201 | |
return | |
else |
<html> | |
<head> | |
<title>Test</title> | |
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> | |
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> | |
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> | |
<script src="http://fb.me/react-0.5.1.js"></script> | |
<script src="http://fb.me/JSXTransformer-0.5.1.js"></script> | |
</head> |
When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:
const Article = require('../../../../app/models/article');
Those suck for maintenance and they're ugly.
(defn ignore-trailing-slash | |
"Modifies the request uri before calling the handler. | |
Removes a single trailing slash from the end of the uri if present. | |
Useful for handling optional trailing slashes until Compojure's route matching syntax supports regex. | |
Adapted from http://stackoverflow.com/questions/8380468/compojure-regex-for-matching-a-trailing-slash" | |
[handler] | |
(fn [request] | |
(let [uri (:uri request)] | |
(handler (assoc request :uri (if (and (not (= "/" uri)) |
angular.module('myMdl', []).config(['$httpProvider', function($httpProvider) { | |
$httpProvider.responseInterceptors.push([ | |
'$q', '$templateCache', 'activeProfile', | |
function($q, $templateCache, activeProfile) { | |
// Keep track which HTML templates have already been modified. | |
var modifiedTemplates = {}; | |
// Tests if there are any keep/omit attributes. | |
var HAS_FLAGS_EXP = /data-(keep|omit)/; |
This post also appears on lisper.in.
Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.
Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):
The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.
uninstall
JetBrains settings:curl -sL https://gist.github.com/denji/9731967/raw/jetbrains-uninstall.sh | bash -s
backup
JetBrains settings:curl -sL https://gist.github.com/denji/9731967/raw/jetbrains-backup.sh | bash -s