Skip to content

Instantly share code, notes, and snippets.

View DrMartiner's full-sized avatar
😎

Alex Kuzmin DrMartiner

😎
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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
EMAIL_HOST = 'smtp.yandex.ru'
EMAIL_HOST_USER = 'login@example.com'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_PORT = 465
EMAIL_USE_TLS = True
@DrMartiner
DrMartiner / views.py
Created January 5, 2014 12:39
Generate csrf token
from django.core.context_processors import csrf
str(csrf(request)['csrf_token'])
karma-angular
@DrMartiner
DrMartiner / urls.py
Created May 12, 2017 12:52
Django's URL's error handlers
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
urlpatterns = [
# ...
]
handler400 = 'apps.common.views.handler400'
handler403 = 'apps.common.views.handler403'