Skip to content

Instantly share code, notes, and snippets.

View DrMartiner's full-sized avatar
😎

Alex Kuzmin DrMartiner

😎
View GitHub Profile
EMAIL_HOST = 'smtp.yandex.ru'
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_PORT = 465
EMAIL_USE_TLS = True
@DrMartiner
DrMartiner / gist:7673870
Created November 27, 2013 10:54
Directive for idle timer
angular.module('app')
.directive 'idle', () ->
return {
restrict: 'E'
scope:
waitTime: '@ngIdleWaitTime'
afterRedirect: '&ngAfterRedirect'
link: (scope, element, attrs) ->
idleTimer = null
idleState = false
@DrMartiner
DrMartiner / gist:7524683
Created November 18, 2013 08:48
gruntfile.coffee
module.exports = (grunt) ->
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
watch:
coffee:
files: ['static/coffee/**/*.coffee']
tasks: ['coffee:dist']
less:
files: ['static/css/**/*.less']
tasks: ['less:dist']
@DrMartiner
DrMartiner / directives.coffee
Created November 12, 2013 05:15
Directive, who set\unset toggle class at the element, when the function-condition changed
toggleClass = angular.module('jobMapApp')
.directive 'ngToggleClass', () ->
return {
restrict: 'A'
scope:
condition: '&ngToggleCondition'
link: (scope, element, attrs) ->
scope.timerId = null
scope.$watch () ->
return scope.condition()
@DrMartiner
DrMartiner / utils.coffee
Last active December 26, 2015 02:29
Convert PostGIS point to Yandex-Map point
convertPostGisToYandex = (point) ->
coords = /POINT\s*\(\s*([0-9\.]+)\s*([0-9.]+)\s*\)/.exec point
if coords.length != 2
console.error 'Bad parse PostGIS point data', point
return []
return [parseFloat(coords[1]), parseFloat(coords[2])]
@DrMartiner
DrMartiner / gist:6121065
Created July 31, 2013 10:44
Test the migration on PostgreSQL
psql -c "drop database dbName"; psql -c "create database dbName;"; ./manage.py syncdb; ./manage.py migrate;
@DrMartiner
DrMartiner / gist:6053110
Created July 22, 2013 11:16
Cleanup and restore tables for dajngo app
(python manage.py sqlclear APP_NAME | python manage.py dbshell) && python manage.py syncdb
@DrMartiner
DrMartiner / content-height.coffee
Created July 12, 2013 10:02
Set content height to full window after resize
setContentHeight = () ->
$content = $('#content')
setMainHeight = () ->
height = $(window).height() - $('#menu').outerHeight() - $('#footer').outerHeight()
$content.height height
setMainHeight()
$(window).resize () ->
@DrMartiner
DrMartiner / gist:5927026
Last active December 19, 2015 08:39
AJAX form, who return errors in dictionary, else return HTTP 201 (code of success create)
# -*- coding: utf-8 -*-
import json
from django.http import HttpResponse
from django.views.generic import FormView
class BaseAJAXFormView(FormView):
mimetype = 'application/json'
@DrMartiner
DrMartiner / gist:4646463
Created January 27, 2013 05:01
Gzip JSON response at location
server {
# ...
location /api/ {
uwsgi_pass unix:///var/run/uwsgi/app/project/socket;
include uwsgi_params;
uwsgi_buffers 8 128k;
client_max_body_size 10M;