Skip to content

Instantly share code, notes, and snippets.

View blizzarddreams's full-sized avatar
❄️
arctic fox

Blizzard blizzarddreams

❄️
arctic fox
  • Kentucky
  • 01:51 (UTC -04:00)
View GitHub Profile
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
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"}
 (0.0ms) begin transaction
 (0.0ms) rollback transaction
Redirected to http://localhost:3000new
Completed 302 Found in 5ms (ActiveRecord: 0.0ms)
$(document).ready(function () {
$(".thumbnail").draggable();
$("#trash").droppable({
drop: function (event, ui) {
var id = ui.draggable.attr('id');
$.ajax({
type: "DELETE",
url: "/images/" + id,
require 'sinatra/base'
require 'sinatra'
require 'mongoid'
Dir.glob('/controllers/*.rb').each { |file| require file }
configure do
Mongoid.load!("./mongoid.yml")
end
require 'sinatra/base'
require 'sinatra'
require 'mongoid'
require './controllers/post_controller.rb'
configure do
Mongoid.load!("./mongoid.yml")
end
require 'sinatra/activerecord/rake'
namespace :db do
task :load_config do
require './app'
end
end
require 'sinatra/activerecord/rake'
namespace :db do
task :load_config do
require './app'
end
end
import pymongo
connection = MongoClient() #connect to the Mongo Client
db = connection.foo # foo is the database
collection = db.bar # bar is the collection
var commands = {
foo: function(bar) {
return "Hello " + bar + "!";
}
};
@blizzarddreams
blizzarddreams / register.js
Last active August 29, 2015 14:15
register
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');
})
}