Skip to content

Instantly share code, notes, and snippets.

View govorov's full-sized avatar

Stanislav E. Govorov govorov

  • TomTom
  • Rotterdam, the Netherlands
View GitHub Profile
//
// graphql/schema.ts
//
...
import { Mutation } from 'graphql/types/mutation';
...
const schemaDefinition = `
schema {
//
// graphql/resolvers.ts
//
import { cardResolver } from 'graphql/resolvers/card';
import { cardsResolver } from 'graphql/resolvers/cards';
export const resolvers = {
Query: {
export const databaseInitializer = async () => {
return await createConnection({
type : 'postgres',
host : '0.0.0.0',
port : 5432,
username : 'db_user',
password : 'db_password',
database : 'db_name',
entities: [
import * as Koa from 'koa';
import { databaseInitializer } from 'initializers/database';
databaseInitializer().then(() => {
const app = new Koa();
app.use(async ctx => {
ctx.body = 'Works!';
@govorov
govorov / graphql_001.connection.ts
Last active October 17, 2017 20:48
graphql post
//
// initializers/database.ts
//
const path = require('path');
import { createConnection } from 'typeorm';
import { Card } from 'entities/card';
export const databaseInitializer = async () => {
@govorov
govorov / pug underscore helpers
Created February 22, 2017 10:50
pug mixins for underscore template engine
//- pug mixins for underscore template engine
//- Examples:
+if('js_expression')
div ...
+else
div ...
+endIf
+each('js_arr','obj,key')
|{{key}} : {{obj.prop}}
@govorov
govorov / sorted-router-example.js
Created December 16, 2016 13:41 — forked from chrisdavies/sorted-router-example.js
A naive wrapper around Backbone router to make it understand route specificity (so route order doesn't matter)...
// Example usage of SortedRouter
var SortedRouter = require('./sortedrouter');
var router = new SortedRouter();
// Supports multiple URLs
router.route('', 'books', show('<h1>Books</h1>'));
router.route('books/new', show('<h1>New Book</h1>'));
router.route('books/:id', show('<h1>Show Book</h1>'));
@govorov
govorov / 00_templates.coffee
Created September 24, 2016 23:45 — forked from laser/00_templates.coffee
Marionette Best Practices
# unless there's a really good reason to do so, a view should not be passed a reference to a preexisting DOM element
view = new BadPhoneInputView(el: $('#phone'))
# instead, write your markup as a string-property of the view prototype to be evaluated at render-time
class GoodPhoneInputView extends Backbone.Marionette.ItemView
template: "<input type='text' name='phone'><a class='submit' href='#'>submit</a>"
# this allows us to unit-test the view in-memory, independently of the document
@govorov
govorov / stooge_loader.rb
Created September 5, 2016 23:06 — forked from bowsersenior/stooge_loader.rb
A demo of YAML anchors, references and nested values
require 'rubygems'
require 'yaml'
# A demonstration of YAML anchors, references and handling of nested values
# For more info, see:
# http://atechie.net/2009/07/merging-hashes-in-yaml-conf-files/
stooges = YAML::load( File.read('stooges.yml') )
# => {
# "default" => {
@govorov
govorov / routes.rb
Created July 30, 2016 22:23 — forked from shilovk/routes.rb
Интеграция Яндекс.Кассы с Rails
# config/routes.rb
YandexKassaIntegration::Application.routes.draw do
# ...
scope '/yandex_kassa' do
controller 'yandex_kassa', constraints: { subdomain: 'ssl' } do
post :check
post :aviso
get :success
get :fail