Skip to content

Instantly share code, notes, and snippets.

@siddharth-pandey
siddharth-pandey / http-status-codes.md
Created May 30, 2018 23:18 — forked from subfuzion/http-status-codes.md
General REST API HTTP Status Codes

Reference: RFC 2616 - HTTP Status Code Definitions

General

  • 400 BAD REQUEST: The request was invalid or cannot be otherwise served. An accompanying error message will explain further. For security reasons, requests without authentication are considered invalid and will yield this response.
  • 401 UNAUTHORIZED: The authentication credentials are missing, or if supplied are not valid or not sufficient to access the resource.
  • 403 FORBIDDEN: The request has been refused. See the accompanying message for the specific reason (most likely for exceeding rate limit).
  • 404 NOT FOUND: The URI requested is invalid or the resource requested does not exists.
  • 406 NOT ACCEPTABLE: The request specified an invalid format.
@siddharth-pandey
siddharth-pandey / mock-service-example.js
Created November 25, 2016 22:19 — forked from alicial/mock-service-example.js
AngularJS: Setting up a mocked service to use in controller unit tests.
// Mocked Service
angular.module('mock.users', []).
factory('UserService', function($q) {
var userService = {};
userService.get = function() {
return {
id: 8888,
name: "test user"
}
public class ComponentDataModelBinder : DefaultModelBinder
{
protected override object CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType)
{
var type = typeof(ComponentData);
var model = Activator.CreateInstance(type);
bindingContext.ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => model, type);
return model;
}
}
var array = [];
var instance = $(this);
array.push(getAnArrayItem(instance.val(), "1", "123.89")); //pass the values either by using harcode d values or from a input...
// function to use to get an item to push
var getAnArrayItem = function(product, quantity, price){ //parameters to construct an item
@siddharth-pandey
siddharth-pandey / gist:87d5af6288ebdb32657a
Created September 24, 2014 21:19
breadcrumbs angularjs
packagerApp.directive('breadcrumbs', function ($routeParams) {
return {
restrict: 'E',
controller: function ($scope) {
var rootUrl = "/Packager/Clients";
$scope.crumbs = [
{
url: rootUrl,
text: "Home"
<script>
$(document).ready(function() {
$('body').append("<iframe id=\"iembed\" name=\"iembed\" style=\"width: 1200px; height: 1000px; border: none; margin: 0 auto; display: block;\"></iframe>");
var params = $('form').serialize();
$.ajax({
type: "POST",
url: "http://localhost:1066/external/index",
data: params,
@siddharth-pandey
siddharth-pandey / gist:f7fb3e629a7d1a24d494
Created July 24, 2014 22:43
html in response from server.
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width">
[Thu Apr 24 2014 13:52:39 GMT+0100 (GMT Daylight Time)] #shell 404 Not Found get /Account/Login#/login
Error {message: "404 Not Found get /Account/Login#/login ", stack: "Error↵ at Object.Sammy.Application.$.extend.err…/localhost:36141/Scripts/Vendor/require.js:132:23"}
message: "404 Not Found get /Account/Login#/login "
stack: "Error↵ at Object.Sammy.Application.$.extend.error (http://localhost:36141/Scripts/Vendor/sammy-0.7.4.js:1346:47)↵ at Object.Sammy.Application.$.extend.notFound (http://localhost:36141/Scripts/Vendor/sammy-0.7.4.js:1335:22)↵ at Object.Sammy.Application.$.extend.runRoute (http://localhost:36141/Scripts/Vendor/sammy-0.7.4.js:1179:21)↵ at Object.Sammy.Application.$.extend._checkLocation (http://localhost:36141/Scripts/Vendor/sammy-0.7.4.js:1365:25)↵ at Object.Sammy.Application.$.extend.run (http://localhost:36141/Scripts/Vendor/sammy-0.7.4.js:971:12)↵ at http://localhost:36141/Scripts/App/common.js:36:19↵ at Object.context.execCb (http://localhost:36141/Scripts/V