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
#!/usr/bin/env ruby | |
# I have a csv file with some students scores. The data in the file looks like: | |
# Last Name,First Name,EID,Special Codes,Score,Percent | |
# DOE ,JOHN ,JHD123,,92,92 | |
# ... | |
# Total Records Read,352,,,, | |
# I need to add a specific value to the last two columns in each data row. |
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
Senhores (as), | |
Surgiu a oportunidade de uma vaga de Analista de Requisitos para trabalhar <Acme Inc.>. | |
Requisitos: | |
- 3 anos de experiência com requisitos; | |
- curso superior completo; | |
- conhecimentos em UML, RUP, modelagem de dados; |
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
C:\dev> curl -v -H "Accept: application/some_unknown_media_type" localhost:1705/api/values | |
* About to connect() to localhost port 1705 (#0) | |
* Trying 127.0.0.1... connected | |
* Connected to localhost (127.0.0.1) port 1705 (#0) | |
> GET /api/values HTTP/1.1 | |
> User-Agent: curl/7.21.1 (i686-pc-mingw32) libcurl/7.21.1 OpenSSL/0.9.8r zlib/1.2.3 | |
> Host: localhost:1705 | |
> Accept: application/some_unknown_media_type | |
> | |
< HTTP/1.1 200 OK |
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
public class NotAcceptableConnegHandler : DelegatingHandler | |
{ | |
private const string allMediaTypesRange = "*/*"; | |
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) | |
{ | |
var acceptHeader = request.Headers.Accept; | |
if (!acceptHeader.Any(x => x.MediaType == allMediaTypesRange)) | |
{ | |
var hasFormetterForRequestedMediaType = GlobalConfiguration |
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
protected void Application_Start() | |
{ | |
//Default Registration and configuration stuff | |
AreaRegistration.RegisterAllAreas(); | |
RegisterGlobalFilters(GlobalFilters.Filters); | |
RegisterRoutes(RouteTable.Routes); | |
BundleTable.Bundles.RegisterTemplateBundles(); | |
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
C:\dev> curl -v -H "Accept: text/unknown_media_type" localhost:1705/api/values | |
* About to connect() to localhost port 1705 (#0) | |
* Trying 127.0.0.1... connected | |
* Connected to localhost (127.0.0.1) port 1705 (#0) | |
> GET /api/values HTTP/1.1 | |
> User-Agent: curl/7.21.1 (i686-pc-mingw32) libcurl/7.21.1 OpenSSL/0.9.8r zlib/1.2.3 | |
> Host: localhost:1705 | |
> Accept: text/unknown_media_type | |
> | |
< HTTP/1.1 406 Not Acceptable |
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
public class CreateResponse : HttpResponseMessage | |
{ | |
public CreateResponse() | |
{ | |
StatusCode = HttpStatusCode.Created; | |
} | |
public CreateResponse(IApiResource resource) :this() | |
{ | |
var location = new ResourceLocation(); |
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
public class Person : IApiResource | |
{ | |
public int Id { get; set; } //whatever property is going to be used in the Get(int id) method in PeopleController | |
public void SetLocation(ResourceLocation location) | |
{ | |
location.SetInController<PeopleController>(x => x.Get(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
public HttpResponseMessage<Person> Post(Person person) | |
{ | |
_repository.Save(person); | |
var responseMessage = new HttpResponseMessage(person, HttpStatusCode.Created); | |
responseMessage.Headers.Location = new Uri(“http://api.example.com/People/”+person.Id); | |
return responseMessage; | |
} |
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
public class CreateResponse : HttpResponseMessage | |
{ | |
public CreateResponse() : base(HttpStatusCode.Created) { } | |
} |