Skip to content

Instantly share code, notes, and snippets.

View jacoor's full-sized avatar
💭
Building Community: https://pymasters.pl

Jacek Ostański jacoor

💭
Building Community: https://pymasters.pl
View GitHub Profile
@jacoor
jacoor / publish.py
Last active April 23, 2018 13:33
Publishing to slack #channel as jenkins
"""
to set up auth token first authorize jenkins as an slack app and install
https://wiki.jenkins.io/display/JENKINS/Slack+Plugin
Afterwards, use https://plugins.jenkins.io/credentials-binding, which is most likely available in your jenkins install
and use the instructions from there to share credentials with job. Accessing credentials in python requires: os.environ['xxx']
"""
import os
import requests
import json
@jacoor
jacoor / settings.py
Last active January 11, 2017 16:23
Simple Websocket Receiver using django
# update your app settings.py with RedisSubscriber:
WS4REDIS_SUBSCRIBER = 'your_app.your_module.subscriber.RedisSubscriber'
@jacoor
jacoor / JiraCopy.js
Last active December 18, 2020 17:33
Bookmarklet to copy jira ticket # + title for easier commit creation. Just install this as a bookmarklet in your browser (tested in chrome) and use.
javascript:!function(a){var b=document.createElement("textarea"),c=document.getSelection();b.textContent=a,document.body.appendChild(b),c.removeAllRanges(),b.select(),document.execCommand("copy"),c.removeAllRanges(),document.body.removeChild(b)}(document.title.split("]")[0].replace("[","")+" - "+document.getElementById("summary-val").textContent);
@jacoor
jacoor / DRFUSPhoneField.py
Created June 10, 2015 21:12
django rest framework us phone field
import re
from django.core.validators import EMPTY_VALUES
from django.utils.encoding import smart_text
from rest_framework.fields import CharField
from localflavor.us.forms import USPhoneNumberField as FormUSPhoneNumberField, phone_digits_re
from django.core.exceptions import ValidationError
@jacoor
jacoor / zipcode.py
Created June 10, 2015 20:20
Django rest framework uszipcode field
from rest_framework.fields import RegexField
from localflavor.us.forms import USZipCodeField as FormUSZipCodeField
class USZipCodeField(RegexField):
""""
A form field that validates input as a U.S. ZIP code. Valid formats are
XXXXX or XXXXX-XXXX.
.. note::
If you are looking for a form field with a list of U.S. Postal Service
locations please use :class:`~localflavor.us.forms.USPSSelect`.
@jacoor
jacoor / pylintrc
Last active August 29, 2015 14:15
pylintrc file used by ArabellaTech to find missing translations in python source code. Usage: pylint --rcfile=pylintrc module. Requires: http://www.technomancy.org/python/pylint-i18n-lint-checker/ and pylint 1.4.1
[MASTER]
# Specify a configuration file.
#rcfile=
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=
# Profiled execution.
@jacoor
jacoor / aa-ios-statusbar.js
Created November 24, 2014 14:37
ios status bar ngcordova directive
/* jslint browser: true, undef: true, newcap: true, forin: true, sub: true, white: true, indent: 4, unused: false */
/* globals define: true, Settings: true, console: true */
define([
'app/app',
'ngCordova',
], function(
App
) {
"use strict";
@jacoor
jacoor / aa-input.html
Last active August 29, 2015 14:06
angular simple aa-field directive for generating form fields from django options response
<li class="form-field" ng-class="{invalid: errors[name], error: errors[name]}">
<input ng-model="model" ng-init="model" type="{[{field.type}]}" ng-required="{[{field.required}]}" placeholder="{[{field.label}]}" ng-maxlength="{[{field.max_length}]}" name="{[{name}]}"/>
<ng-include ng-if="errors[name]" src="'templates/directives/aa-forms/error_list.html'"></ng-include>
</li>
@jacoor
jacoor / dates.py
Created August 25, 2014 13:39
Django template dates functions - template tags.
from datetime import datetime
from dateutil.relativedelta import relativedelta
from django.template import Library
from django.template import Node, TemplateSyntaxError
from django.utils.timezone import get_current_timezone
from django.template.defaultfilters import date
from django.conf import settings
register = Library()
@jacoor
jacoor / contenteditable
Created August 14, 2014 18:25
clearing clipboard contents from everything except <a href="*">*</a> on paste
elm.bind('paste', function(e) {
//console.log(e);
e.preventDefault();
var text = (e.originalEvent || e).clipboardData.getData("text/html");
if (!text){
console.log('no html');
text = (e.originalEvent || e).clipboardData.getData("text/plain");
}
var temp = $('<div />');
$(temp).html(text);