Skip to content

Instantly share code, notes, and snippets.

View moskrc's full-sized avatar

Vitalii moskrc

  • Spain
View GitHub Profile
@moskrc
moskrc / next_previous.py
Created June 26, 2012 10:50 — forked from dokterbob/next_previous.py
Django template tag to efficiently get the next or previous object in the Django queryset, with regards to the item specified.
from django import template
register = template.Library()
from templatetag_sugar.register import tag
from templatetag_sugar.parser import Constant, Variable, Name
from .utils import get_next_or_previous
"""
Efficient and generic get next/previous tags for the Django template language,
{
"name": "People Addon",
"description": "Atlassian Connect add-on",
"permissions": [
"browse_projects",
"read_users_and_groups",
"read_metadata",
"read_user_session_data"
],
"key": "x_people_addon",
@moskrc
moskrc / utils.py
Last active January 3, 2016 11:09
import urllib
import jwt
import hashlib
import datetime
import calendar
import requests
import urlparse
import httplib
from addon.models import JWT
from requests.auth import AuthBase
TRY TO SEND REQUEST
-------------------
-- JWT from the request header: {u'iss': u'jira:7a3b4c77-cfc3-4071-aae5-a887d197dc9d', u'iat': 1389874386, u'qsh': u'3a6ff1b66f60eb275d0e4cb6be4261d5d3b0216b91c58dc6524509227ef346de', u'sub': u'admin', u'exp': 1389874566}
-- Full Url: http://localhost:2990/jira/rest/api/2/project
-- Verify QSH from JWT token
-- Call: create_canonical_request(GET, /addon/?lic=none&tz=Europe%2FMoscow&cp=%2Fjira&user_key=admin&loc=en-US&user_id=admin&jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjEzODk4NzQ1NjYsInN1YiI6ImFkbWluIiwiaXNzIjoiamlyYTo3YTNiNGM3Ny1jZmMzLTQwNzEtYWFlNS1hODg3ZDE5N2RjOWQiLCJxc2giOiIzYTZmZjFiNjZmNjBlYjI3NWQwZTRjYjZiZTQyNjFkNWQzYjAyMTZiOTFjNThkYzY1MjQ1MDkyMjdlZjM0NmRlIiwiaWF0IjoxMzg5ODc0Mzg2fQ.WFg8X0Ngxc4bmto0PbJ5JKhbn8fAbJMvmRo35V3cL6o&xdm_e=http%3A%2F%2Flocalhost%3A2990&xdm_c=channel-servlet-click-me&xdm_p=1)
-- Canonical request (sorted): GET&/addon&cp=%2Fjira&lic=none&loc=en-US&tz=Europe%2FMoscow&user_id=admin&user_key=admin&xdm_c=channel-servlet-click-me&xdm_
2014-03-18 09:40:07,487 jira-monitoring-plugin DEBUG [jira.plugins.monitor.MetricsCollectorTask] Calling addSample() in: com.atlassian.jira.plugins.monitor.rrd4j.RrdUpdater@b9de3b6
2014-03-18 09:40:08,561 http-bio-2990-exec-10 INFO anonymous 580x5x1 - 0:0:0:0:0:0:0:1 /rest/api/2/issue [plugins.workflow.servlet.JWDSendRedirectFilter] send redirect filter running
2014-03-18 09:40:08,561 http-bio-2990-exec-10 INFO anonymous 580x5x1 - 0:0:0:0:0:0:0:1 /rest/api/2/issue [plugins.workflow.servlet.JWDSendRedirectResponseWrapper] response wrapper created
2014-03-18 09:40:08,565 http-bio-2990-exec-10 DEBUG - [atlassian.plugin.webresource.DefaultResourceDependencyResolver] About to add resource [jira.webresources:superbatch-default] and its dependencies: [jira.webresources:empty-js, com.atlassian.auiplugin:aui-reset, com.atlassian.auiplugin:aui-page-typography, com.atlassian.auiplugin:aui-page-layout, com.atlassian.auiplugin:ajs, com.atlassian.auiplugin:aui-badge, com.atlassian.auiplugin:aui-buttons, com.atla
//FIRST SERVER (server1.js)
var io = require('socket.io')(3000);
var redis = require('socket.io-redis');
io.adapter(redis({ host: 'localhost', port: 6379 }));
var test = 0;
io.on('connection', function (socket) {
@moskrc
moskrc / keep-fork-updated.md
Created June 12, 2018 10:19
How to update your fork from the original repo

Taken from here

Add remote branch:

git remote add --track master mleung git://github.com/mleung/feather.git

Verify:

git remote

@moskrc
moskrc / validators.py
Last active August 31, 2018 11:54 — forked from dokterbob/validators.py
Validator for files, checking the size, extension and mimetype. Modified to work with Django 2.0.6 and Python 3.6.4
from os.path import splitext
import mimetypes
from django.core.exceptions import ValidationError
from django.template.defaultfilters import filesizeformat
from django.utils.translation import ugettext_lazy as _
from django.utils.deconstruct import deconstructible
@deconstructible
@moskrc
moskrc / queries-mixins.less
Last active July 24, 2018 09:34
LESS media queries (xxs, xs, sm, md, lg) mixin
// Extra small screen / phone
@screen-xs: 480px;
@screen-xs-min: @screen-xs;
// Small screen / tablet
@screen-sm: 768px;
@screen-sm-min: @screen-sm;
// Medium screen / desktop
@screen-md: 992px;
@moskrc
moskrc / gist:db653a83e0293befe87b1253d1a32029
Created September 26, 2018 08:34
How to install mysqlclient on osx
$ brew install mysql-connector-c
$ vim /usr/local/bin/mysql_config
Change
# on macOS, on or about line 112:
# Create options
libs="-L$pkglibdir"
libs="$libs -l "
to
# Create options