Skip to content

Instantly share code, notes, and snippets.

View wreckah's full-sized avatar
🌵
Make tests green again

Alexander Perlamutrov wreckah

🌵
Make tests green again
  • Babylon
View GitHub Profile
@wreckah
wreckah / console.js
Last active July 7, 2021 07:26
Resolve Rollbar's issues in bulk
const ROLLBAR_HEADERS = {
accept: '*/*',
'cache-control': 'no-cache',
'content-type': 'application/json',
pragma: 'no-cache',
'sec-ch-ua': '" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"',
'sec-ch-ua-mobile': '?0',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
@wreckah
wreckah / example.sql
Last active January 9, 2019 14:56
example
CREATE TABLE users (
id serial NOT NULL PRIMARY KEY,
email text NOT NULL UNIQUE,
platform text NOT NULL DEFAULT 'ios',
created timestamp NOT NULL DEFAULT statement_timestamp()
);
CREATE TABLE orders (
id serial NOT NULL PRIMARY KEY,
user_id NOT NULL REFERENCES users (id) ON UPDATE CASCADE ON DELETE CASCADE,
@wreckah
wreckah / indludes_replace.js
Created October 31, 2018 06:06
Do we really need to check that string contains entity before replace?
const textAmp = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi tempor, elit accumsan semper pellentesque, magna metus fringilla mi, eu congue magna metus in nisi. Donec lacus nisl, dictum sed mollis nec, placerat iaculis nisl. Donec in augue at nisi ultricies congue. Integer eu elementum risus. Donec pharetra venenatis varius. In a faucibus metus. Nam pretium orci ligula, vitae faucibus enim venenatis non. Pellentesque eleifend lacus vel nisi ultricies ornare.
Etiam eu sollicitudin purus. In faucibus ut enim vitae malesuada. In enim metus, ullamcorper nec fermentum a, luctus congue enim. Nullam sed leo a mi efficitur mollis tempor id lacus. Sed sit amet commodo purus. Sed facilisis dictum est, in tristique odio mattis ac. Etiam posuere egestas nibh, ut rutrum felis pretium id. Mauris non felis luctus, porta tellus tristique, scelerisque justo. Pellentesque et ex est.
Donec vulputate consectetur urna at venenatis. Integer id molestie nisl, at blandit enim. Mauris risus magna, suscipit vitae ma
./node_modules/.bin/gulp
[18:19:03] Requiring external module coffee-script/register
module.js:549
throw err;
^
Error: Cannot find module 'internal/util/types'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
@wreckah
wreckah / B00DKXYNCU.json
Last active September 6, 2017 15:08
B00DKXYNCU Amazon UK's item
{
"asin": "B00DKXYNCU",
"expired_product_id": false,
"offers": [
{
"addon": false,
"buy_box_winner": true,
"comments": null,
"condition": "New",
"greytext": "In stock.",
@wreckah
wreckah / product.json
Created May 2, 2017 11:43
Best mother ever hoodie
{
"id": 4529,
"name": "\"Best Mom Ever\" Hoodie",
"merchant_id": 40,
"merchant_product_id": null,
"categories": [
264,
178,
276
],
@wreckah
wreckah / resp.json
Created April 27, 2017 15:37
Weird response
{
"num_offers": 1,
"offers": [
{
"addon": false,
"buy_box_winner": true,
"comments": null,
"condition": "New",
"greytext": null,
"handling_days_max": null,
@wreckah
wreckah / error.json
Created April 25, 2017 17:02
Zinc.io error
{
"status": "failed",
"_type": "error",
"code": "internal_error",
"message": "Zinc or the retailer you requested is experiencing outages. Please try again or contact support@zinc.io if this error persists.",
"data": {
"hostname": "pn6",
"details": "We've retried a lot of times",
"key": "RetriedTooManyTimesError"
}
@wreckah
wreckah / gift_message.md
Created April 19, 2017 23:46
Gift's message

How we prepare gift's message for Amazon

Amazon has a few restriction for messages:

  • doesn't accept unicode symbols (allowed latin alphabet, numbers and punctuation, emoji or cyrillic symbols are not allowed);
  • allows not more than 240 symbols and 9 lines.

So we use the next algorithm for preparing user's message:

  1. If gift's message is empty use our default message:
const _ = require('lodash');
const config = require('config');
const debug = require('debug')('intercom');
const request = require('request').defaults({
'auth': {
user: config.intercom.access_token,
pass: '',
sendImmediately: true
},
headers: {