Skip to content

Instantly share code, notes, and snippets.

View mockra's full-sized avatar

David Ratajczak mockra

View GitHub Profile
App.Router.map(function() {
this.route('login');
});
App.LoginController = Ember.Controller.extend(Ember.SimpleAuth.LoginControllerMixin);
<form {{action login on='submit'}}>
<label for="identification">Login</label>
{{view Ember.TextField id='identification' valueBinding='identification' placeholder='Enter Login'}}
<label for="password">Password</label>
{{view Ember.TextField id='password' type='password' valueBinding='password' placeholder='Enter Password'}}
<button type="submit">Login</button>
</form>
class SessionsController < ApplicationController
def create
user = User.find_by_email params[:username]
if user && user.authenticate(params[:password])
render json: { access_token: user.access_token }
else
render json: {}, status: 401
end
end
end
var gulp = require('gulp');
var concat = require('gulp-concat');
var stylus = require('gulp-stylus');
gulp.task('styles', function() {
gulp.src('./bower_components/bootstrap/dist/css/bootstrap.css')
.pipe(concat('vendor.css'))
.pipe(gulp.dest('./public'))
gulp.src('./assets/**/*.styl')
@mockra
mockra / nginx
Last active May 17, 2022 15:39
nginx config for static site
server {
listen 80;
root /var/www/yourdomain.com/public;
index index.html index.htm;
server_name yourdomain.com;
location / {
default_type "text/html";
class Post < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :post, counter_cache: true
end
# Migration
add_column :posts, :comments_count, :integer, default: 0
var userSchema = new mongoose.Schema({
email: { type: String, unique: true, lowercase: true },
customerToken: String
});
var stripe = require('stripe')('YOUR_API_KEY');
exports.create = function(req, res, next) {
stripe.customers.create(
{ email: user.email, plan: 'YOUR_PLAN_ID', card: req.body.stripeToken },
function(err, customer) {
if (err) return next(err);
user.customerToken = customer.id;
// Save your user, and redirect
}
$ ->
$('input.credit-card').payment('formatCardNumber')
$('input.cvc').payment('formatCardCVC')