This file contains 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 ExceptionRaisingHandler : HttpClientHandler | |
{ | |
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) | |
{ | |
throw new HttpRequestException(); | |
} | |
} |
This file contains 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 RequestBinClient | |
{ | |
private readonly HttpClient _httpClient; | |
public RequestBinClient(HttpClient httpClient) | |
{ | |
_httpClient = httpClient; | |
} | |
public async Task PostStuff<T>(T stuff) |
This file contains 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
[TestMethod] | |
public async Extend_request() | |
{ | |
var client = new HttpClient(new CustomHttpClientHandler()); | |
var response = await client.PostAsJsonAsync("http://requestb.in/1lcvbtp1", new {foo = "bar"}); | |
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); | |
} |
This file contains 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 CustomHttpClientHandler : HttpClientHandler | |
{ | |
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) | |
{ | |
var bytes = Encoding.ASCII.GetBytes(await request.Content.ReadAsStringAsync()); | |
request.Headers.Add("RequestSignature", Convert.ToBase64String(bytes)); | |
return await base.SendAsync(request, cancellationToken); | |
} |
This file contains 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
-- Add api | |
$ curl -i -X POST \ | |
--url http://localhost:8001/apis/ \ | |
--data 'name=requestbin' \ | |
--data 'upstream_url=http://requestb.in/' \ | |
--data 'request_host=requestb.in' | |
-- Update api |
This file contains 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
docker run -d --name kong-database \ | |
-p 5432:5432 \ | |
-e "POSTGRES_USER=kong" \ | |
-e "POSTGRES_DB=kong" \ | |
postgres:9.4 | |
docker run -d --name kong \ | |
--link kong-database:kong-database \ | |
-e "KONG_DATABASE=postgres" \ | |
-e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \ |
This file contains 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 BookmarksResolver : ValueResolver<LeObject, List<BookmarksDto>> | |
{ | |
protected override List<BookmarksDto> ResolveCore(LeObject source) | |
{ | |
return source.Bookmarks != null | |
? JsonConvert.DeserializeObject<List<BookmarksDto>>(source.Bookmarks) | |
: null; | |
} | |
} |
This file contains 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
var inputText = document.querySelector('#text_input'); | |
var output = document.querySelector('#output'); | |
var encodeBtn = document.querySelector('#encode_btn'); | |
var decodeBtn = document.querySelector('#decode_btn'); | |
encodeBtn.onclick = function() { | |
output.innerText = btoa(inputText.value); | |
}; |
This file contains 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
// Some stuff I started prototyping at work but then had to switch to more 'important' things | |
var child_process = require('child_process'); | |
child_process.exec('git log --decorate --oneline --stat=99999', (err, stdout, stderr) => { | |
var masterLineStart = "origin/master, origin/HEAD, master"; | |
var lines = stdout.split("\n"); | |
var lineAtMasterIndex = lines.findIndex(function(line){ | |
return line.indexOf(masterLineStart) >= 0 | |
}) |
This file contains 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
cd /usr/local/share/ | |
sudo wget http://phantomjs.googlecode.com/files/phantomjs-x.y.z-linux-x86_64.tar.bz2 | |
sudo tar jxvf phantomjs-x.y.z-linux-x86_64.tar.bz2 | |
sudo ln -s /usr/local/share/phantomjs-x.y.z-linux-x86_64/ /usr/local/share/phantomjs | |
sudo ln -s /usr/local/share/phantomjs/bin/phantomjs /usr/local/bin/phantomjs |