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
$.fn.select2.amd.define('select2/data/extended-ajax',['./ajax','../utils','jquery'], function(AjaxAdapter, Utils, $){
function ExtendedAjaxAdapter ($element,options) {
//we need explicitly process minimumInputLength value
//to decide should we use AjaxAdapter or return defaultResults,
//so it is impossible to use MinimumLength decorator here
this.minimumInputLength = options.get('minimumInputLength');
this.defaultResults = options.get('defaultResults');
ExtendedAjaxAdapter.__super__.constructor.call(this,$element,options);
#template for select option, I use it to show regions and draw country flags for each city
cityOptionTpl = (obj)->
_.tpl('CitySelectOption')(obj)
#helper for rendering option
renderCityOption = (entry)->
tplRes = cityOptionTpl({it:
title : entry.title
region : entry.region
country_name : entry.country_name
@govorov
govorov / stations.json
Created July 13, 2016 21:22 — forked from jarosluv/stations.json
List of Moscow Metro Stations — 2016 / Список станций Московского метро — 2016
[
{
"line": "Сокольническая",
"stations": ["Бульвар Рокоссовского", "Черкизовская", "Преображенская площадь", "Сокольники", "Красносельская", "Комсомольская", "Красные ворота", "Чистые пруды", "Лубянка", "Охотный ряд", "Библиотека имени Ленина", "Кропоткинская", "Парк культуры", "Фрунзенская", "Спортивная", "Воробьёвы горы", "Университет", "Проспект Вернадского", "Юго-Западная", "Тропарёво", "Румянцево", "Саларьево"]
},
{
"line": "Замоскворецкая",
"stations": ["Алма-Атинская", "Красногвардейская", "Домодедовская", "Орехово", "Царицыно", "Кантемировская", "Каширская", "Коломенская", "Технопарк", "Автозаводская", "Павелецкая", "Новокузнецкая", "Театральная", "Тверская", "Маяковская", "Белорусская", "Динамо", "Аэропорт", "Сокол", "Войковская", "Водный стадион", "Речной вокзал"]
},
{
@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
@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 / 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 / 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 / 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 / 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 () => {
import * as Koa from 'koa';
import { databaseInitializer } from 'initializers/database';
databaseInitializer().then(() => {
const app = new Koa();
app.use(async ctx => {
ctx.body = 'Works!';