Skip to content

Instantly share code, notes, and snippets.

@Maxim-Filimonov
Maxim-Filimonov / converter.ts
Created August 16, 2022 16:48
ApolloGraphQLInteraction with Pact V3
function convertApolloToV3Interaction(
apolloInteraction: ApolloGraphQLInteraction,
states?: V3ProviderState[],
): V3Interaction {
const interaction = apolloInteraction.json();
return {
states,
uponReceiving: interaction.description,
withRequest: {
method: interaction.request.method,
@Maxim-Filimonov
Maxim-Filimonov / ex1.md
Last active June 12, 2018 04:12
Express.js assignments

Grocery List API

Build an API for grocery list mobile app.

POST /groceries/

Example request:

POST /groceries

{
  title: "Milk",
  category: "Milk based products",
 amount: 1
@Maxim-Filimonov
Maxim-Filimonov / index.js
Created July 31, 2017 15:29
Sinon stubbing of function
function getTodos(listId, callback) {
helpers.makeHttpCall({
url: '/todo/' + listId + '/items',
success: function (data) {
// Node-style CPS: callback(err, data)
callback(null, data);
}
});
}
// This wrapper is required for our stubbing to work
@Maxim-Filimonov
Maxim-Filimonov / HYgL-0.js
Created April 25, 2017 03:40
null created by Maxim-Filimonov - https://repl.it/HYgL/0
function magic() {
console.log("MAGIC")
}
@Maxim-Filimonov
Maxim-Filimonov / .babelrc
Last active May 18, 2016 03:04
Array#flatten in JS
{ "presets": ["es2015"] }
@Maxim-Filimonov
Maxim-Filimonov / nginx.conf
Last active September 27, 2015 02:51
Cloud66 nginx config
user nginx;
worker_processes {{ workers }};
error_log /var/log/nginx.log;
events
{
worker_connections 1024;
accept_mutex off;
}
@Maxim-Filimonov
Maxim-Filimonov / functional.js
Last active September 19, 2015 17:42
Playing with ramda
// Functional
var log = function(tag,val) { console.log(tag, val); return val; }
var isLightBackground = function(color) {
// 765 - max distance
log("color:",color);
return log("result:", log("distance:", xcolor.distance(color, 'white')) < (765/2));
};
filterMenuItems = function (menuItems, level, parentId) {
var childLevel = level + 1;
// filter out admin-only items if needed
if (!Users.is.admin(Meteor.user())) {
menuItems = _.reject(menuItems, function (item) {
return item.adminOnly;
});
}
sum: R.reduce(this.add, 0),
totalVotes: R.compose(this.sum, R.drop(1))(?votes?),
calculatePercent: R.compose(R.curry(Math.round), R.multiply(100), R.divide(R.__, this.totalVotes)),
@Maxim-Filimonov
Maxim-Filimonov / main.jsx
Last active August 29, 2015 14:27
Magic of Ramda maybes
createLogo() {
R.compose(R.map(function (v) {
return <img src={v}/>
}), R.pluck('logo'), RF.Maybe);
},
defaultLogo() {
return undefined;
},
render() {