Skip to content

Instantly share code, notes, and snippets.

@scf4
scf4 / app.js
Last active February 5, 2018 23:03
graphql koa app.js with http and ws endpoints
/* eslint-disable no-console */
import Koa from 'koa';
import bodyParser from 'koa-bodyparser';
import cors from 'kcors';
import { SubscriptionServer as WebSocketServer } from 'subscriptions-transport-ws';
import { execute, subscribe } from 'graphql';
import { graphqlKoa, graphiqlKoa as graphiqal } from 'graphql-server-koa';
import { formatError, isInstance } from 'apollo-errors';
@kaizhu256
kaizhu256 / gist:4482069
Last active October 20, 2021 16:25
javascript - very fast and simple uuid4 generator benchmarked on http://jsperf.com/uuid4/8
/*jslint bitwise: true, indent: 2, nomen: true, regexp: true, stupid: true*/
(function () {
'use strict';
var exports = {};
exports.uuid4 = function () {
//// return uuid of form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
var uuid = '', ii;
for (ii = 0; ii < 32; ii += 1) {
@otanistudio
otanistudio / chat-frontend.js
Created June 2, 2012 04:45 — forked from martinsik/chat-frontend.js
Node.js chat server, with the frontend changed to use BackboneJS
/*global $, Backbone, window, console, WebSocket, _ */
$(function () {
"use strict";
// for better performance - to avoid searching in DOM
var $content = $('#content')
, $input = $('#input')
, $status = $('#status')
// my color assigned by the server
@martinsik
martinsik / chat-frontend.js
Last active December 19, 2023 10:23
Node.js chat frontend and server
$(function () {
"use strict";
// for better performance - to avoid searching in DOM
var content = $('#content');
var input = $('#input');
var status = $('#status');
// my color assigned by the server
var myColor = false;
@kylelemons
kylelemons / piping.go
Last active July 4, 2022 01:25 — forked from dagoof/piping.go
piping exec.Cmd in golang (example sorts all regular files under a directory by their extension)
package main
import (
"bytes"
"exec"
"log"
"os"
)
// Pipeline strings together the given exec.Cmd commands in a similar fashion