Skip to content

Instantly share code, notes, and snippets.

View maapteh's full-sized avatar
🏠
Working from home

Mаартен - Maarten maapteh

🏠
Working from home
  • The Hague, Moscow
View GitHub Profile
#!/bin/bash
for tag in $(git tag)
do
git tag "${tag/v/}" $tag
done
for tag in $(git tag)
do
if [[ $tag = *v* ]]
import { Injectable } from '@angular/core';
import { environment } from '@dest-env/environment';

@Injectable({
  providedIn: 'root'
})
export class GmapService {

  private static promise;
import { Injectable, NgZone } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { environment } from '@dest-env/environment';
import { Destination } from './destination';
import { OpenFlight } from './open-flight';
@Injectable({
providedIn: 'root',
@maapteh
maapteh / apollo-client.ts
Created November 28, 2018 16:08
apollo client with batched http and option to get out of batch by setting important on context
import { InMemoryCache, NormalizedCacheObject } from 'apollo-cache-inmemory';
import { ApolloClient } from 'apollo-client';
import { ApolloLink, split } from 'apollo-link';
import { onError } from 'apollo-link-error';
import { HttpLink } from 'apollo-link-http';
import { BatchHttpLink } from 'apollo-link-batch-http';
// add fragments from apollo endpoint
import { fragmentMatcher } from './fragment-matcher';
// TODO: link http://gateway:8080/graphql and https://foo.bar/graphql for each environment
import React from 'react';
import { compose, graphql } from 'react-apollo';
import { QueryOne, QueryTwo } from './graphql.query';
import { OneQuery, TwoQuery } from '../../lib/_generated-types';
type InputProps = {
productId: number;
};
type Variables = {
import React from 'react';
import { MockedProvider } from '@apollo/react-testing';
import { renderHook } from '@testing-library/react-hooks';
// import { DATA_9200000111963040 } from '../../../server/test/__mocks__/stubs/product-9200000111963040';
import { useGetProductQuery } from '../../lib/_generated-hooks';
// import { GET_PRODUCT } from './get-product.graphql';
import gql from 'graphql-tag';
import { FRAGMENT_PRODUCT } from '../../lib/fragments/product.fragment.graphql';
@maapteh
maapteh / use-viewport.tsx
Last active March 23, 2024 03:40
useViewport hook for React
// MODULE
import React, {
FC,
ReactNode,
useState,
useEffect,
createContext,
useContext,
useCallback,
} from 'react';
@maapteh
maapteh / launch.json
Last active November 16, 2019 20:15
vscode bind on ws inspect
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "ah: API",
@maapteh
maapteh / url-batch-javascript
Last active November 30, 2019 08:59
retrieve urls in batches
// This is a mock request function
const sendRequest = (url) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(`request resolved ${url}`)
}, 2000)
})
}
// Helper: split array in batches
@maapteh
maapteh / local-benchmark.js
Last active December 9, 2019 16:10
local benchmark output
```
Summary:
Total: 30.7128 secs
Slowest: 1.7595 secs
Fastest: 0.4397 secs
Average: 1.0356 secs
Requests/sec: 38.2577
Total data: 315681375 bytes
Size/request: 268665 bytes