Skip to content

Instantly share code, notes, and snippets.

// context docs: https://paw.cloud/docs/reference/ExtensionContext
// request docs: https://paw.cloud/docs/reference/Request
// DynamicString docs: https://paw.cloud/docs/reference/DynamicString
// DynamicValue docs: https://paw.cloud/docs/reference/DynamicValue
function getUrlPattern(context, request){
var requestUrl = request.getUrl(true); // DynamicString
var components = requestUrl.components; // Array of DynamicString
var urlPattern = ''; // string
for (var i = 0; i < components.length; i++) {
var variable = context.getEnvironmentVariableByName('My Var Name')
variable.setCurrentValue('My new value')
// `Context` docs: https://paw.cloud/docs/reference/ExtensionContext
// `EnvironmentVariable` docs: https://paw.cloud/docs/reference/EnvironmentVariable
## Tests
/* This enpoint will wait 2 seconds before responding. */
assertEqual(exchange.responseStatusCode, 200, 'Status code')
assert(exchange.responseTime < 2800, 'Too long loading time')
assert(exchange.responseTime > 2000, 'Too short loading time')
@mittsh
mittsh / secret-path-to-paw-assertions-1.js
Last active April 20, 2017 10:01
secret-path-to-paw-assertions
## Tests
/* We can get the current testing context with `testContext`
* for example may want to get another request and assert
* some relationship between their responses
*/
var otherRequest = testContext.getRequestByName('Other Request Name')
var otherExchange = otherRequest.getLastExchange()
var otherBody = JSON.parse(otherExchange.responseBody)
(function(afterEl, descriptionUrl){
var fn = function() {
console.log('ready')
var html = '<a href="#" class="oic-button" data-mode="url" data-source="swagger" data-url="' + descriptionUrl + '"><img src="https://console.rest/github.io/assets/buttons/run_with_blue.svg" style="border: none; margin-bottom: 20px;" /></a>'
var containerTag = document.createElement('div')
containerTag.innerHTML = html
afterEl.parentNode.insertBefore(containerTag, afterEl.nextSibling)
ConsoleRest.bindModalToButtons()
}
@mittsh
mittsh / inject.js
Created December 12, 2016 23:49 — forked from anonymous/inject.js
(function(afterEl, descriptionUrl){
var fn = function() {
console.log('ready')
var html = '<a href="#" class="oic-button" data-mode="url" data-source="swagger" data-url="' + descriptionUrl + '"><img src="https://console.rest/github.io/assets/buttons/run_with_blue.svg" style="border: none;" /></a>'
var containerTag = document.createElement('div')
containerTag.innerHTML = html
afterEl.parentNode.insertBefore(containerTag, afterEl.nextSibling)
ConsoleRest.bindModalToButtons()
}

Keybase proof

I hereby claim:

  • I am mittsh on github.
  • I am mittsh (https://keybase.io/mittsh) on keybase.
  • I have a public key whose fingerprint is 8979 57DA 6FE6 BB9D CEAC 11E3 A994 1A2D 44D7 5798

To claim this, I am signing this object:

$ npm install -g pawpt # or, "yarn add pawprint-cli"
$ curl https://httpbin.org/get --trace - | pawpt
✓ Pawprint Created
Share Link: https://paw.pt/bR0Yz5jW
Embed as an iframe:
<iframe src="https://paw.pt/bR0Yz5jW/embed"></iframe>
To delete this Pawprint
+ (void)importFromJavaScript:(NSString*)string
{
// create a local "private queue" context
NSManagedObjectContext* managedObjectContext =
[[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
managedObjectContext.parentContext = document.managedObjectContext;
// run on the background context queue
[managedObjectContext performBlock:^{
@protocol LMJSRequest <JSExport>
// setHeader(name, value)
JSExportAs(setHeader, -(void)LMJS_setHeader:(JSValue*)headerName headerValue:(JSValue*)headerValue);
// setUrl(newUrl)
JSExportAs(setUrl, -(void)LMJS_setUrl:(JSValue*)url);
// setBody(bodyString)
JSExportAs(setBody, -(void)LMJS_setBody:(JSValue*)body);