Skip to content

Instantly share code, notes, and snippets.

View mockra's full-sized avatar

David Ratajczak mockra

View GitHub Profile
require 'spec_helper'
feature 'logging in' do
let(:user) { create :user }
scenario 'with correct credentials' do
visit login_path
fill_in 'session_email', with: user.email
fill_in 'session_password', with: user.password
click_button 'Log In'
{{gravatar-image email="test@example.com" size=50}}
<img {{bind-attr src=gravatarUrl}}>
import Ember from 'ember';
export default Ember.Component.extend({
size: 200,
email: '',
gravatarUrl: function() {
var email = this.get('email'),
size = this.get('size');
.credit-card {
padding: 7px 40px 7px 7px;
background: #FFF url('generic.png') 97% 50% no-repeat;
background-size: 25px 25px;
width: 100%;
}
input.visa {
background-image: url('visa.png');
}
$ ->
$('input.credit-card').payment('formatCardNumber')
$('input.cvc').payment('formatCardCVC')
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
}
var userSchema = new mongoose.Schema({
email: { type: String, unique: true, lowercase: true },
customerToken: String
});
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
@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";