This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'securerandom' | |
| class Image < ActiveRecord::Base | |
| validates :title, presence: true | |
| validates :image, presence: true | |
| extend FriendlyId | |
| friendly_id :random_id | |
| belongs_to :user | |
| mount_uploader :image, ImageUploader |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Started POST "/images" for 127.0.0.1 at 2015-02-16 21:11:21 -0500 | |
| Processing by ImagesController#create as HTML | |
| Parameters: {"utf8"=>"✓", "authenticity_token"=>"dT3VZCHmn9xWlJLeWYU76eVvTTmBPSCwROjhQKQEVhj3JZSVJ58wBUb1D7gTbJpZw0krpyL7VbN7C2cJECs5mA==", "image"=>{"title"=>""}, "commit"=>"Upload"} | |
| [1m[35m (0.0ms)[0m begin transaction | |
| [1m[36m (0.0ms)[0m [1mrollback transaction[0m | |
| Redirected to http://localhost:3000new | |
| Completed 302 Found in 5ms (ActiveRecord: 0.0ms) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).ready(function () { | |
| $(".thumbnail").draggable(); | |
| $("#trash").droppable({ | |
| drop: function (event, ui) { | |
| var id = ui.draggable.attr('id'); | |
| $.ajax({ | |
| type: "DELETE", | |
| url: "/images/" + id, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'sinatra/base' | |
| require 'sinatra' | |
| require 'mongoid' | |
| Dir.glob('/controllers/*.rb').each { |file| require file } | |
| configure do | |
| Mongoid.load!("./mongoid.yml") | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'sinatra/base' | |
| require 'sinatra' | |
| require 'mongoid' | |
| require './controllers/post_controller.rb' | |
| configure do | |
| Mongoid.load!("./mongoid.yml") | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'sinatra/activerecord/rake' | |
| namespace :db do | |
| task :load_config do | |
| require './app' | |
| end | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'sinatra/activerecord/rake' | |
| namespace :db do | |
| task :load_config do | |
| require './app' | |
| end | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pymongo | |
| connection = MongoClient() #connect to the Mongo Client | |
| db = connection.foo # foo is the database | |
| collection = db.bar # bar is the collection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var commands = { | |
| foo: function(bar) { | |
| return "Hello " + bar + "!"; | |
| } | |
| }; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var crypto = require('crypto'); | |
| function register(user, pass) { | |
| var salt = crypto.randomBytes(256).toString('base64'); | |
| crypto.pbkdf2(pass, salt, 4096, 512, 'sha256', function(err, key) { | |
| if (err) console.log(err); | |
| var hash = key.toString('hex'); | |
| }) | |
| } |