JSend What? - Put simply, JSend is a specification that lays down some rules for how JSON responses from web servers should be formatted. JSend focuses on application-level (as opposed to protocol- or transport-level) messaging which makes it ideal for use in REST-style applications and APIs. Why? - There are lots of web services out there providing JSON data, and each has its own way of formatting responses. So how's it work? A basic JSend-compliant response is as simple as this: When setting up a JSON API, you'll have all kinds of different types of calls and responses. Example response types ¶ Success: When an API call is successful, the JSend object is used as a simple envelope for the results, using the data key, as in the following: GET /posts.json: GET /posts/2.json: DELETE /posts/2.json: Required keys: status: Should always be set to "success". data: Acts as the wrapper for any data returned by the API call. POST /posts.json (with data body: "Trying to creating a blog post"): Optional keys:
Best Practices for Designing a Pragmatic RESTful API | Vinay Sahni Your data model has started to stabilize and you're in a position to create a public API for your web app. You realize it's hard to make significant changes to your API once it's released and want to get as much right as possible up front. Now, the internet has no shortage on opinions on API design. But, since there's no one widely adopted standard that works in all cases, you're left with a bunch of choices: What formats should you accept? How should you authenticate? In designing an API for Enchant (a Zendesk Alternative), I've tried to come up with pragmatic answers to these questions. ... or just skip to the bottom and signup for updates Latest from the Enchant blog How to make your app lovable A decent app helps you get the job done. ... and those apps, the ones that make things feel effortless, are the ones we love the most. But what makes an app feel effortless? Key requirements for the API Use RESTful URLs and actions But what can I make a resource? SSL everywhere - all the time
JWT: JSON Web Tokens in AngularJS and Laravel With the rising popularity of single page applications, mobile applications, and RESTful API services, the way web developers write back-end code has changed significantly. With technologies like AngularJS and BackboneJS, we are no longer spending much time building markup, instead we are building APIs that our front-end applications consume. Our back-end is more about business logic and data, while presentation logic is moved exclusively to the front-end or mobile applications. These changes have led to new ways of implementing authentication in modern applications. Authentication is one of the most important parts of any web application. What is a JSON Web Token? A JSON Web Token, or JWT, is used to send information that can be verified and trusted by means of a digital signature. Because of it’s compact structure, JWT is usually used in HTTP Authorization headers or URL query parameters. Structure of a JSON Web Token JSON Web Token example: Example Header Payload (Claims) Registered Claims
Cookies vs Tokens. Getting auth right with Angular.JS Introduction There are basically two different ways of implementing server side authentication for apps with a frontend and an API: The most adopted one, is Cookie-Based Authentication (you can find an example here) that uses server side cookies to authenticate the user on every request.A newer approach, Token-Based Authentication, relies on a signed token that is sent to the server on each request. Token based vs. Cookie based The following diagram explains how both of these methods work. What are the benefits of using a token-based approach? Cross-domain / CORS: cookies + CORS don't play well across different domains. What's JSON Web Token? Asuming you have a node.js app, below you can find the components of this architecture. Server Side Let's start by installing express-jwt and jsonwebtoken: $ npm install express-jwt jsonwebtoken Configure the express middleware to protect every call to /api. The angular app will perform a POST through AJAX with the user's credentials: Angular Side What's next?
Form Design For Dummies: 10 Simple Tips On Designing A Form That Converts | Outside The Jar Web forms have become an integral part of most websites and the internet in general. Their primary purpose is to help both users and businesses achieve their separate goals by establishing a relationship or initiating a conversation between the two. Registration forms are what allows people to become members of online communities or services. Think of Facebook – their 1 billion+ users all joined through a registration form;Checkout forms allow transactions to happen through the web. Subscribing to a paid service and people purchasing products are a couple of examples which happen through a checkout form;Data submission forms are how people share knowledge, post information and communicate online. Even with their extensive importance online, it is surprisingly common to come across very poorly made forms – which is a shame. First off, let’s explore what elements a form is made up of and some best practices. Labels Input fields Input fields are what allow your users to fill in your form.
js - jQuery plugin for HTML5+JSON interactive tables and more Demo Processing... To get started, simply install jquery.dynatable.js (along with jQuery), and add the following in the document.ready or after the table: $('#my-table').dynatable(); How it works Dynatable does three things: Read / Normalize The HTML table is scanned and normalized into an array of JSON objects (or collection) where each JSON object (or record) corresponds to a row in the table. This 3-step approach has several advantages: Efficient reading/operating/writing Since the logic and operations occur on the JSON collection, the DOM operations (reading and writing/drawing) are grouped together, making interactions quick and efficient. Normalization The first module normalizes an HTML table into a JSON collection. The following table: Results in this JSON collection: Converting attribute names By default, dynatable converts headings to JSON attribute names using: We could also define our own column-name transformation function. Click the button to the right. Run Code So this: Existing JSON
HTTP Basic Auth | Flask (A Python Microframework) By Armin Ronacher filed in Authentication For very simple applications HTTP Basic Auth is probably good enough. Flask makes this very easy. To use this decorator, just wrap a view function: @app.route('/secret-page')@requires_authdef secret_page(): return render_template('secret_page.html') If you are using basic auth with mod_wsgi you will have to enable auth forwarding, otherwise apache consumes the required headers and does not send it to your application: WSGIPassAuthorization. This snippet by Armin Ronacher can be used freely for anything you like.
jQuery editTable Plugin | Html Use Download Demo jQuery editTable is a very small jQuery Plugin (~1Kb gzipped) that fill the gap left by the missing of a default input field for data tables. jQuery editTable can be used both in ajax and/or HTTP POST contest and let you preset the title and number of columns or just let complete freedom to the user. You can even append custom behaviors to single column cells (ex. jQuery UI Datepicker). jQuery editTable is a very small jQuery Plugin (~1Kb gzipped) that fill the gap left by the missing of a default input field for data tables. jQuery editTable can be used both in ajax and/or HTTP POST contest and let you preset the title and number of columns or just let complete freedom to the user. You can even append custom behaviors to single column cells (ex. jQuery UI Datepicker). The only limit is your imagination! To use it you just have to include jQuery and a copy of the plugin in your head or footer: There are of course many methods which can be used on the created table.
A guide to Python's function decorators | The Code Ship Python is rich with powerful features and expressive syntax. One of my favorites is decorators. In the context of design patterns, decorators dynamically alter the functionality of a function, method or class without having to directly use subclasses. In this post I will be discussing Python's function decorators in depth, accompanied by a bunch of examples on the way to clear up the concepts. Essentially, decorators work as wrappers, modifying the behavior of the code before and after a target function execution, without the need to modify the function itself, augmenting the original functionality, thus decorating it. What you need to know about functions Before diving in, there are some prerequisites that should be clear. Assign functions to variables def greet(name): return "hello "+name greet_someone = greetprint(greet_someone("John")) # Outputs: hello John Define functions inside other functions Functions can be passed as parameters to other functions More commonly known as a closure.
Dimitri Gielis Blog (Oracle Application Express - APEX): January 2015 I doubted to set the title of this post to "Running APEX 4.2 and 5.0 in the same Oracle instance", but decided not to do that, but that is basically what I will do. Before going into details, I'll share my architecture. In December 2013 I wrote it was time to update your APEX environment and I gave a quick overview of the architecture we're using. I'm using Apache as a reverse proxy in front of Tomcat. A few years ago we had the discussion about mod_plsql vs APEX Listener (now Oracle REST Data Services - ORDS). For APEX I'm always on the latest version as fast as I can, as with every new release there're great improvements and fixes. And finally the Oracle Database I'm on 12cR1 because I like the pluggable database concept and the other features it brings. But in this post I want to show you how easy it is to prepare your environment for APEX 5 and to test the upgrade with an architecture as above. Step 1. Step 2. alter pluggable database apex50_pdb open; Step 3. That's it... Step 4.