Skip to content

Instantly share code, notes, and snippets.

public getAvailability(apiToken) {
return new Promise((resolve, reject) => {
axios.get('api/connect/hotels/id/availability')
.then((response) => resolve(response.data))
.catch(error => reject(new HttpRequestError(error)));
})
}
const result = await polly().handle(console.error)
.waitAndRetry(retryTimes).executeForPromise(async () => {
return axios.get(`${apiUrl}/booking/v1/offer-index`, requestConfig);
})
@EdwardIII
EdwardIII / a.sql
Created April 17, 2020 15:18
Entries query
// These are all the queries being run
// also this is a bit slow
[10s] SELECT "entries".* FROM "entries" WHERE "entries"."referrer" = $1 ORDER BY "entries"."created_at" DESC [["referrer", "http://localhost"]]
[10s] SELECT COUNT(*) FROM "entries" WHERE "entries"."referrer" = $1 AND "entries"."widget_id" = $2 AND (content -> 'action' ? 'open' and content -> 'type' ? 'slide_callout') AND (created_at >= '1970-04-17 14:57:56.675928' AND created_at <= '2020-04-17 14:57:59.557860') [["referrer", "http://localhost"], ["widget_id", 1]]
[10s] SELECT COUNT(*) FROM "entries" WHERE "entries"."referrer" = $1 [["referrer", "http://localhost"]]
// this one seems to be the culprit
[10s] SELECT "entries".* FROM "entries" WHERE "entries"."referrer" = $1 AND (extract(year from created_at) = '2020') AND (extract(month from created_at) = '04') ORDER BY "entries"."created_at" DESC [["referrer", "http://localhost"]]
monolog:
handlers:
app:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%_app.log"
level: debug
channels: ["!event", "!request", "!security"]
formatter: app.line_formatter
excluded_404s:
- .*
@EdwardIII
EdwardIII / r.js
Last active November 17, 2016 15:29
import Ember from 'ember';
export default Ember.Route.extend({
'currentOrder': Ember.inject.service(),
model(){
return Ember.Object.create({
// in the template: (subclass of Ember.ArrayProxy) == :)
'invoices': this.get('store').findAll('invoice'),
// in the template: [object Object] == :(
'currentOrders': this.get('currentOrder').current()
import Ember from 'ember';
export default Ember.Component.extend({
});
ini_set("default_socket_timeout", "1");
class SocketWorker implements
{
private $socketResource;
private $socketErrorNum;
private $socketErrorStr;
<?php
try {
explode('not an array');
}catch(\Exception $e){
echo "Couldn't explode";
}
/* Outputs:
PHP Warning: explode() expects at least 2 parameters, 1 given in /private/tmp/test.php on line 4
import mechanize
from lxml import etree
from StringIO import StringIO
def get_text_recursive(node):
return (node.text or '') + ''.join(map(get_text_recursive, node)) + (node.tail or '')
def browser_to_xml(browser):
htmlparser = etree.HTMLParser()
try: