ServiceNow Design System
Use like this

<span class="icon-vcr-right" style="font-size:13px;"></span>
servicenow  icon  style  glyph  set  library 
2 days ago
Discrepancy in original headers and playback headers (bytes vs. strs) · Issue #122 · betamaxpy/betamax · GitHub
I'm getting an error from Betamax when it tries to record header values that are bytes instead of native unicode strings (in python 3).

TypeError: b'xj8h' is not JSON serializable

This is a pull request that has some links to an example of a binary serializer that someone wrote. Also, coming in Betamax 0.9.0, there are some changes in the core library to allow binary serializers to specify that they deal in binary (bytes), not text (strings).
python  betamax  unicode  header  bytes  string  json  encode  serialize  serializer 
3 days ago
orm - Unique fields that allow nulls in Django - Stack Overflow
class CharNullField(models.CharField):

Subclass of the CharField that allows empty strings to be stored as NULL.

description = "CharField that stores NULL but returns ''."

def from_db_value(self, value, expression, connection, contex):
Gets value right out of the db and changes it if its ``None``.
if value is None:
return ''
return value

def to_python(self, value):
Gets value right out of the db or an instance, and changes it if its ``None``.
if isinstance(value, models.CharField):
# If an instance, just return the instance.
return value
if value is None:
# If db has NULL, convert it to ''.
return ''

# Otherwise, just return the value.
return value

def get_prep_value(self, value):
Catches value right before sending to db.
if value == '':
# If Django tries to save an empty string, send the db None (NULL).
return None
# Otherwise, just pass the value.
return value
django  char  null  field  blank  text  string  db  sql  none  custom  orm 
10 days ago
vimrc - Opening a vertical terminal in Vim 8.1 - Unix & Linux Stack Exchange
:vert term

:vertical works with any command that splits a window, for example:

:vert copen
:vert help vert
vim  vertical  split  bash  terminal  window 
17 days ago
Reading output of a command into an array in Bash - Stack Overflow
while IFS= read -r line; do
my_array+=( "$line" )
done < <( my_command )
bash  command  array  output 
23 days ago
pytz: The Fastest Footgun in the West
Article from 2018 explaining why we should be using instead of pytz.
python  timezone  pytz  dateutil  utc 
23 days ago
stdout - Write lines to a file from less - Unix & Linux Stack Exchange
10Gmm1G|mcat > outfile.txt

(typed within less) seems to work as long as the input doesn't fit in one screen (in which case all the input ends up in outfile.txt for some reason).

10G brings you to line 10
mm sets the m mark there
1G (same as g in this case) brings you to line 1
|m pipe from the current line to mark m
cat > outfile.txt: that's piped to that command.
unix  less  write  lines  to  file  log 
25 days ago
PyPika - Python Query Builder — PyPika 0.15.5 documentation
PyPika is a Python API for building SQL queries. The motivation behind PyPika is to provide a simple interface for building SQL queries without limiting the flexibility of handwritten SQL. Designed with data analysis in mind, PyPika leverages the builder design pattern to construct queries to avoid messy string formatting and concatenation. It is also easily extended to take full advantage of specific features of SQL database vendors.
python  sql  orm  query  builder  pika 
27 days ago
The Most Diabolical Python Antipattern – Real Python
# The Python 3 version. It's a little less work.
import traceback

def log_traceback(ex):
tb_lines = traceback.format_exception(ex.__class__, ex, ex.__traceback__)
tb_text = ''.join(tb_lines)
# I'll let you implement the ExceptionLogger class,
# and the timestamping.

x = get_number()
except Exception as ex:
python  log  exception  traceback 
29 days ago
cheat-sheet for mathematical notation in code form
javascript  math  notation  explained  code 
4 weeks ago
Charles Dickens’Pets
But I think his strongest love, among animals, was for dogs. I find a delightful
anecdote told by him of a dog belonging to a lady whom he knew well, ”Of”, an
immense, black, good-humored, Newfoundland dog. He came from Oxford and
had lived all his life in a brewery. Instructions were given with him that if he were
let out every morning alone he would immediately find out the river, regularly taken
a swim and come gravely home again. This he did with the greatest punctuality, but
after a little while was observed to smell of beer. His owner was so sure that he
smelled of beer that she resolved to watch him. He was seen to come back from
his swim round the usual corner and to go up a fight of steps into a beer shop.
Being instantly followed, the beer shopkeeper is seen to take down a pot (pewter pot)
and is heard to say: ”Well, old chap, come up for your beer as usual, have you?”
Upon which he draws a pint and puts it down and the dog drinks it.
Being required to explain how this comes to pass the man says: ”Yes, ma´am.
I know he´s your dog, but I didn´t when he first came. He looked in, ma´am, as
a brickmaker might, and
he wagged his tail at the pots, and he giv a sniff round and conveyed to me as was
used to beer. So I draw´d him a drop, and he drunk it up. Next morning he came
again by the clock and I draw´d him a pint, and ever since he has took his pint reg´lar.”

Mamie Dickens: My Father as I recall Him
Chapter IV
E.P.Dutton & Co. New York 1897
charles  dickens  biography  mamie  newfoundland  dog  beer 
4 weeks ago
postgresql - Auto-truncating fields at max_length in Django CharFields - Stack Overflow
class TruncatingCharField(models.CharField):
def get_prep_value(self, value):
value = super(TruncatingCharField,self).get_prep_value(value)
if value:
return value[:self.max_length]
return value
django  truncate  field  database 
5 weeks ago
Turn Django admin interface in to a CMS. Edit, add, and delete rows with a nice interface.
django  admin  interface  edit  cms 
6 weeks ago
soap - Is there a way to provide an external WSDL file to a Python Suds client - Stack Overflow
Read wsdl from a local file, and then set the location that the service should query using `client.set_options(location=url)`
python  soap  suds  wsdl  file 
7 weeks ago
Documentation – suds
Internet Archive Wayback Machine snapshot of the old Suds documentation that used to be hosted at
suds  python  documentation  wayback_machine  soap  archive 
7 weeks ago
Ignore matching order for Axis SOAP Responses · macrojames/python-zeep@e2dc96e · GitHub
Patch to workaround Zeep problem parsing out-of-order parameters in response from Apache Axis SOAP web service.
python  soap  suds  doctor  zeep  apache  axis  web  server  order  response  parse  xml  error  workaround  patch  bug 
7 weeks ago
Order of elements in response: XMLParseError: Unexpected element · Issue #487 · mvantellingen/python-zeep · GitHub
Link to patch to workaround Zeep problem parsing out-of-order parameters in response from Apache Axis SOAP web service.
python  soap  suds  doctor  zeep  apache  axis  web  server  order  response  parse  xml  error  workaround  patch  bug 
7 weeks ago
GitHub - tpope/vim-abolish: abolish.vim: easily search for, substitute, and abbreviate multiple variants of a word
Vim plugin to do case-smart substitutions, and to convert from snake_case to camelCase.

:%S/supplier/product/g will do SUPPLIER->PRODUCT and Supplier->Product in one go
vim  plugin  tpope  text  snake_case  camelCase 
8 weeks ago
A different way of writing test case data. Instead of writing a big parameterize decorator before your test, you put your test case data in separate functions, and then decorate your test with @cases_data.

Interesting. I'm not sure if it's better than the big parameterize decorator. It might be more readable, but it separates the test data from the testing code.
pytest  plugin  pytest-cases 
11 weeks ago
Comparing Pulsar and Kafka: unified queuing and streaming
Pulsar does streaming (pubsub, like Kafka) and queueing (distributing work to multiple consumers, like RabbitMQ).
kafka  pulsar  queue  stream  message  pubsub 
11 weeks ago
Easy way to close class to new attributes (perhaps with attr.evolve syntactic sugar) · Issue #231 · python-attrs/attrs
How to close a class to new attribute creation.

class AlertContainer():
identifier = attr.ib()
title = attr.ib()

One advantage of using slots=True with attrs is that any creation of attributes outside of __init__ will raise an AttributeError.

Now, something like this will throw an error, as it should.

obj.some_dumb_typo = value
python  attrs  attribute  outside  init  slots  AttributeError  __init__ 
12 weeks ago
Git add lines to index by grep/regex - Stack Overflow
# check that the regex search correctly matches the changes you want.
git diff -U0 | grepdiff 'regex search' --output-matching=hunk

# then apply the changes to the index
git diff -U0 | grepdiff 'regex search' --output-matching=hunk | git apply --cached --unidiff-zero
git  regex  line  add  patch 
12 weeks ago
python - How to debug Celery/Django tasks running locally in Eclipse - Stack Overflow

- or -

You can do it using Celery's rdb:

from celery.contrib import rdb

Then, in a different terminal type telnet localhost 6900, and you will get the debug prompt.
celery  debug  local  pdb  set  breakpoint  step 
12 weeks ago
What's the fastest way to edit hundreds of Git commit messages? - Stack Overflow
git filter-branch --msg-filter 'sed "s/Refs: #xxxxx/Refs: #22917/g"' master..my_branch

And after you do git filter-branch, you can do this to get rid of the leftover head reference

git update-ref -d refs/original/refs/heads/whatever
git  rebase  reword  script  commit  message  edit 
12 weeks ago
Factory Boy Fun · Adam Johnson's Blog
Examples of how to use factory boy to create models for Django tests.
django  testing  model  factory  factory_boy  example 
july 2018
macos - OS X Color Picker: Removing a Colour Swatch - Ask Different
Method 1: Drag the swatch to the trash can in the dock.

Method 2: If you can click on the swatch and it gets a blue outline highlight, then you can press the Delete key on the keyboard to delete the swatch.
mac  macos  apple  color  swatch  picker  annoyances 
july 2018
« earlier      
annoyances ansible apache api apple application async asyncio audio automation backup bash blog book branch browser bug cd celery certificate chart cheatsheet cli client code command commit computer config configuration convert copy css culture data database dead debian debug debugging deployment design development diff diy django docs documentation download drive driver editor education email environment error example fabric file firefox flask food format forum forwarding framework france fun function game games ghibli gif git github google graph guide hardware hg howto html html5 http import install internet ios java javascript key keyboard kids ldap library line linux list local log low_power_server mac make manager map markdown memory merge microsoft mock monitor multiple music network nginx odbc online openssl oracle osx package pandas path pc pdf performance phone pick_pack pip plsql plugin port postgres postscript programming puppet putty pytest python python3 query radio recipe redhat reference remote requests rest review science screen script scripting search security selenium server service setup shell shopping soap software sound sql ssd ssh ssl stream string subversion sudo svn syntax template terminal test testing text time tips tmux tool tools trace transfer troubleshooting tutorial twisted ubuntu unicode unix upgrade user utilities utility vagrant vba version vi video vim virtualenv vmware vpn web windows workflow xp

Copy this bookmark: