Skip to content

Instantly share code, notes, and snippets.

View nodkz's full-sized avatar

Paul Damnhorns nodkz

View GitHub Profile
@nodkz
nodkz / gist:94b8562661fb07d6cb67
Created December 9, 2014 13:16
jquery-ujs.js
(function($, undefined) {
/**
* Unobtrusive scripting adapter for jQuery
*
* Requires jQuery 1.6.0 or later.
* https://github.com/rails/jquery-ujs
* Uploading file using rails.js
* =============================
@nodkz
nodkz / gist:ab95552a743451ec958e
Created July 9, 2015 12:19
Beeline в Казахстане встраивает следующий html-код на чужие сайты для пользователей IPAD на мобильном интернете. Встраивает свою рекламу, без ведома площадок.
<div id="toolbar">
<iframe id="toolBarPcFrame" src="http://192.168.240.36:8080/ets/ToolBarPcServlet" allowtransparency="true"
background-color="transparent"
style="position: fixed; z-index: 2147483640; width: 140.4px; height: 146.4px; margin: 0px; padding: 0px; bottom: 0px; right: 0px; border: none;">
<html>
<head>
<meta name="viewport"
content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=0;">
<meta name="format-detection" content="telephone=no">
<style type="text/css">
@nodkz
nodkz / app_schema.js
Last active March 30, 2016 08:20
Schema configuration example for commit "Create schema2.js for getting more granular schema configuration" (https://github.com/nodkz/graffiti-mongoose/commit/08aa4a394c8b53a442ec05929f1b0035418a1ae0).
// This gist is a draft solution for extending graphQL schemas generated by graffiti.
import { getSchema, addMongooseModel, getGQType, getExistedType } from 'lib/graffiti-mongoose/src/schema/schema2';
import { User } from 'app/_schema/mongoose/user';
import { Cv } from 'app/_schema/mongoose/cv';
import { UserData } from 'app/_schema/mongoose/userData';
import ExtraFieldsWrapper from 'lib/graffiti-mongoose/src/wrappers/extra-fields';
import getFieldList from 'lib/graffiti-mongoose/src/query/projection';
@nodkz
nodkz / gist:bb0f4e050448225a8346cefa7077eab8
Last active April 11, 2016 09:04
What reindex.io will return on DELETE? Null, empty or the previous object data.
mutation {
deleteMovie(input: {clientMutationId:"123", id:"TW92aWU6NTZiODc5M2E4NzMwNzYxMjAwMGZhNWM2"}) {
clientMutationId
id
changedMovie {
id
title
}
changedMovieEdge {
cursor
@nodkz
nodkz / batchRelayNetworkLayer.js
Last active April 21, 2016 16:16
BatchRelayNetworkLayer + ExpressWrapMiddleware
/* eslint-disable prefer-template, arrow-body-style */
import 'whatwg-fetch';
// import fetchWithRetries from 'fbjs/lib/fetchWithRetries';
class AuthError extends Error {}
/**
* Rejects HTTP responses with a status code that is not >= 200 and < 300.
* This is done to follow the internal behavior of `fetchWithRetries`.
@nodkz
nodkz / compose.js
Created June 15, 2016 07:09
Help to annotate this function with Flow
/**
* Composes single-argument functions from right to left. The rightmost
* function can take multiple arguments as it provides the signature for
* the resulting composite function.
*
* @param {...Function} funcs The functions to compose.
* @returns {Function} A function obtained by composing the argument functions
* from right to left. For example, compose(f, g, h) is identical to doing
* (...args) => f(g(h(...args))).
*/
@nodkz
nodkz / graphql-js-on-flow27-errors.txt
Created July 1, 2016 05:47
graphql-js-on-flow27-errors
src/utilities/buildASTSchema.js:257
257: locations: directiveAST.locations.map(node => node.value),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call of method `map`
257: locations: directiveAST.locations.map(node => node.value),
^^^^^^^^^^ some string with unknown value. Property not found in
97: locations: Array<DirectiveLocationEnum>;
^^^^^^^^^^^^^^^^^^^^^ object literal. See: src/type/directives.js:97
src/utilities/buildASTSchema.js:258
258: args: makeInputValues(directiveAST.arguments),
@nodkz
nodkz / routes.js
Last active January 28, 2017 16:19
import React from 'react';
import Relay from 'react-relay';
import { relayStore } from 'app/clientStores'; // relayStore = Relay.Store;
import App from 'app/_components/App/App';
import Menu from 'app/Menu/Menu';
import MainPage from 'app/MainPage/MainPage';
import Page404 from 'app/_components/Page404/Page404';
import LoadingPage from 'app/_components/LoadingPage/LoadingPage';
import BrokenPage from 'app/_components/BrokenPage/BrokenPage';
@nodkz
nodkz / buildNodeImage.js
Created December 8, 2016 14:45
Building `node:slim` docker container with your node_modules via `node:build` container on Mac.
/* eslint-disable no-use-before-define, camelcase */
import cp from 'child_process';
import fsExtra from 'fs-extra';
import hashFiles from 'hash-files';
import chalk from 'chalk';
import {
repositoryName,
rootDir,
buildEnv,
@nodkz
nodkz / relayStore.js
Last active June 29, 2017 01:30
relayStore with `reset` and simplified `mutate` methods
let relayStore;
function relayCreateStore() {
const env = new Relay.Environment();
env.injectNetworkLayer(new Relay.DefaultNetworkLayer('/graphql'));
if (__DEV__) {
RelayNetworkDebug.init(env);
}
env.reset = () => relayCreateStore();
env.mutate = ({
query,