Skip to content

Instantly share code, notes, and snippets.

View avalanchy's full-sized avatar

Mariusz Osiecki avalanchy

View GitHub Profile

Printing under Ubuntu/Debian.

  1. Install CUPS - Print Server sudo apt-get install cups
  2. Go http://localhost:631/admin
  3. Click Add printer.
  4. Log-in with as your system account.
  5. Select Internet Printing Protocol (ipp).
  6. Type ipp://10.93.5.160/ipp. (find IP using nmap -p 631 10.93.5.* --open) +[click continue]
  7. Type printer name i.e. myprinter. +[click continue]
  8. Select Generic. +[click continue]
@avalanchy
avalanchy / gae_venv.md
Last active December 22, 2015 02:28
Google App Engine and Virtualenv (Python 2.7)

Lets download SDK to /tmp. I assume that Virtualenv is already installed.

  1. Unpack
unzip /tmp/google_appengine_<VERSION>.zip -d /usr/local
  1. Create Virtualenv
virtualenv ~/demo
@avalanchy
avalanchy / most_commons.py
Last active December 22, 2015 14:19
Indexes of most common value in array of integers. Without importing any library
"""
Indexes of most common value in array of integers.
Without importing any library.
@author: avalanchy
Python 2.7
"""
# random 1 million
from random import randint
array = [randint(1, 100) for _ in xrange(1, 10**6)]
@avalanchy
avalanchy / exceptions.py
Created September 16, 2013 12:20
python exception inheritance
class A(Exception):
pass
class B(A):
pass
try:
raise B
except A:
@avalanchy
avalanchy / choinka.py
Last active October 1, 2018 06:56
Choinka Generator Python
import sys
import logging
C = 80 # console width
def cen(text):
return text.center(C)
if len(sys.argv) == 3:
@avalanchy
avalanchy / subtraction.py
Created September 18, 2013 12:54
Best way to stop forever loop on event - Python
In [1]: run = 1
In [2]: event = 17
In [3]: def a():
...: if event == 17:
...: run = 0
...:
In [4]: def b():
@avalanchy
avalanchy / cmd.md
Last active December 23, 2015 21:49
cmd.fm - soundcloud
#!python
"""Bootstrap distribute installation
If you want to use setuptools in your package's setup.py, just include this
file in the same directory with it, and add this to the top of your setup.py::
from distribute_setup import use_setuptools
use_setuptools()
If you want to require a specific version of setuptools, set a download
@avalanchy
avalanchy / .gitconfig
Last active September 9, 2019 05:25
~/.gitconfig
[user]
email = yourname@example.com
name = Joe Smith
[alias]
d = diff HEAD
dn = diff --name-only
co = checkout
b = branch
ci = commit
st = status
@avalanchy
avalanchy / prepend_file.py
Created February 6, 2014 12:27
python. prepend file with text
def prepend(path, text)
with open(path, 'r+') as f:
body = f.read()
f.seek(0)
f.write(text + body)