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
| from flask.ext.mongoengine import MongoEngine | |
| from flask import Flask | |
| app = Flask('blog') | |
| app.config["MONGODB_SETTINGS"] = {'DB': "FlaskBlog"} | |
| db = MongoEngine(app) |
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
| u = User.objects.get(username=username) | |
| if u.password == hashlib.sha512(password).hexdigest(): | |
| session['logged_in'] = True | |
| flash("You successfully logged in.") | |
| return redirect(url_for('home')) | |
| else: | |
| flash("Wrong Pass") |
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
| get '/register' do | |
| erb :register | |
| end | |
| post '/register' do | |
| user = params[:username] | |
| pass = params[:password] | |
| pass_hash = BCrypt::Password.create(pass) | |
| @user = User.new(user, pass_hash) | |
| @user.save |
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
| - -> /register | |
| ArgumentError - wrong number of arguments (2 for 0..1): | |
| C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/mongoid-4.0.1/lib/mongoid/documen | |
| t.rb:103:in `initialize' | |
| app.rb:33:in `new' | |
| app.rb:33:in `block in <class:ApplicationController>' | |
| C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb | |
| :1603:in `call' | |
| C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sinatra-1.4.5/lib/sinatra/base.rb | |
| :1603:in `block in compile!' |
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
| string get_url = "www.foo.bar"; | |
| HttpWebRequest request = (HttpWebRequest)WebRequest.Create(get_url); | |
| HttpWebResponse response = (HttpWebResponse)request.GetResponse(); | |
| Stream stream = response.GetResponseStream(); |
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
| using (var responseStream = response.GetResponseStream()) | |
| { | |
| using (var streamReader = new StreamReader(responseStream)) | |
| { | |
| var result = streamReader.ReadToEnd; | |
| } | |
| } |
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
| req.pipe(map(function (chunk) { | |
| return chunk.toString().toUpperCase() | |
| })).pipe(res) |
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
| people = { | |
| { | |
| "name": "Anthony", | |
| "age": 17 | |
| }, | |
| { | |
| "name": "Thien", | |
| "age": 17 | |
| } | |
| } |
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
| package main | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "io/ioutil" | |
| "net/http" | |
| ) | |
| func main() { |
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
| $('#show').click(function() { | |
| var menu = $('#control_center'); | |
| if (menu.hasClass('extended')) { | |
| menu.removeClass('extended'); | |
| $('#control_center').animate({ | |
| width: "5%" | |
| }, 500); | |
| } else { | |
| menu.addClass('extended'); | |
| $('#control_center').animate({ |