Skip to content

Instantly share code, notes, and snippets.

@pcattori
pcattori / gist:2bb645d587e45c9fdbcabf5cef7a7106
Last active February 20, 2022 00:01
relay-style cursor-based pagination capable of filtering/sorting for SQL
import { Base64 } from 'js-base64'
import { Op } from 'sequelize'
import { fromGlobalId } from 'graphql-relay'
// https://github.com/graphql/graphql-relay-js/issues/94#issuecomment-232410564
const effectiveOrder = ({ last }, orderBy) => {
/* adds `id ASC` to end of `ORDER BY` if `id` is not already in the `ORDER BY` clause
flips `ASC` to `DESC` (and vice-versa) if pagination arg `last` is defined
*/
@antho1404
antho1404 / migration.js
Last active September 25, 2018 07:07
A script to be able to execute some data migrations with graphcool framework
const fs = require('fs')
const os = require('os')
const vm = require('vm')
const yaml = require('js-yaml')
const { paramCase } = require('change-case')
const { GraphQLClient } = require('graphql-request')
const cmd = process.argv[2]
const MIGRATION_PATH = `./db/migrations`
const isLocalTarget = target => target.startsWith('local/')
@jayphelps
jayphelps / package.json
Last active March 20, 2024 09:41
TypeScript output es2015, esm (ES Modules), CJS, UMD, UMD + Min + Gzip. Assumes you install typescript (tsc), rollup, uglifyjs either globally or included as devDependencies
{
"scripts": {
"build": "npm run build:es2015 && npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:umd:min",
"build:es2015": "tsc --module es2015 --target es2015 --outDir dist/es2015",
"build:esm": "tsc --module es2015 --target es5 --outDir dist/esm",
"build:cjs": "tsc --module commonjs --target es5 --outDir dist/cjs",
"build:umd": "rollup dist/esm/index.js --format umd --name YourLibrary --sourceMap --output dist/umd/yourlibrary.js",
"build:umd:min": "cd dist/umd && uglifyjs --compress --mangle --source-map --screw-ie8 --comments --o yourlibrary.min.js -- yourlibrary.js && gzip yourlibrary.min.js -c > yourlibrary.min.js.gz",
}
}
@OlegIlyenko
OlegIlyenko / Event-stream based GraphQL subscriptions.md
Last active February 24, 2024 04:41
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

@johgusta
johgusta / decorator
Last active December 15, 2016 17:03
Disable JIT compiler on Safari for $new
angular.module('lib.decorators', [])
.config(['$provide', function($provide){
'use strict';
var isSafari = /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor);
if(isSafari) {
$provide.decorator('$rootScope', ['$delegate', function($rootScope) {
var scopePrototype = Object.getPrototypeOf($rootScope);
var originalScopeNew = scopePrototype.$new;
@remy
remy / _README.md
Last active January 12, 2024 11:57
requestAnimationFrame helper

raf.js

A simple script with a few niceties that allows for multiple requestAnimationFrame calls, and FPS pinning.

How it works

The script polyfills rAF if required, then overloads requestAnimationFrame and cancelAnimationFrame with a process that allows multiple frames to be queued up for rAF to run.

This is useful if there are multiple animations running on the page, you want all the callbacks to happen at once, and not on multiple rAF calls. This script is meant as a drop-in solution to that problem.

@katowulf
katowulf / module.simpleLoginTools.js
Last active March 3, 2016 04:26
A service and several directives based on ng-cloak, which wait for angularFire to finish authenticating--rather than just until Angular bootstraps--before displaying it's content. Handy to get rid of those blips that display when user isn't logged in--oh, wait, now they are.
'use strict';
/**
* This module monitors angularFire's authentication and performs actions based on authentication state.
* directives/directive.ngcloakauth.js depends on this file
*
* Modify ng-cloak to hide content until FirebaseSimpleLogin resolves. Also
* provides ng-show-auth methods for displaying content only when certain login
* states are active.
*
@apla
apla / icons_and_splash.js
Created August 7, 2013 23:15
cordova hook script to copy icons and splash screens to platform directories
#!/usr/bin/env node
var cordova_util = require('cordova/src/util');
var projectRoot = cordova_util.isCordova(process.cwd());
var projectXml = cordova_util.projectConfig(projectRoot);
var projectConfig = new cordova_util.config_parser(projectXml);
projectConfig.name();
var fs = require ('fs');
@maccman
maccman / jquery.ajax.queue.coffee
Last active January 13, 2018 12:03
Queueing jQuery Ajax requests. Usage $.ajax({queue: true})
$ = jQuery
queues = {}
running = false
queue = (name) ->
name = 'default' if name is true
queues[name] or= []
next = (name) ->
@vijaydev
vijaydev / gist:1472145
Created December 13, 2011 13:35
Rails 3.2.0 Changelogs

The latest release notes is available at http://edgeguides.rubyonrails.org/3_2_release_notes.html

Railties 3.2.0 (unreleased)

  • Speed up development by only reloading classes if dependencies files changed. This can be turned off by setting config.reload_classes_only_on_change to false. José Valim

  • New applications get a flag config.active_record.auto_explain_threshold_in_seconds in the environments configuration files. With a value of 0.5 in development.rb, and commented out in production.rb. No mention in test.rb. fxn

  • Add DebugExceptions middleware which contains features extracted from ShowExceptions middleware José Valim