Skip to content

Instantly share code, notes, and snippets.

View noisy's full-sized avatar

Krzysztof Szumny noisy

View GitHub Profile
@erik-sn
erik-sn / oauth.py
Last active January 23, 2020 07:09
import re
import requests
import json
from django.contrib.auth.models import User
from oauth2_provider.models import AccessToken
def generate_github_access_token(github_client_id, github_client_secret, github_code):
"""
@noisy
noisy / gist:e95de368014910464896
Last active September 7, 2015 07:49
Programistyczne zajawki
@etataurov
etataurov / fabtest.py
Last active August 29, 2015 14:03
BaseTestCase for testing fabric tasks in docker containers
# encoding: utf-8
from __future__ import print_function
import docker
import unittest
from fabric.api import env, run, execute
class DockerTest(unittest.TestCase):
def setUp(self):
self.client = docker.Client(**self.get_client_spec())
@noisy
noisy / .bash_prompt.sh
Last active January 12, 2016 10:03
.bash_prompt.sh (support for git + virtualenv)
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current git repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
@mxpr
mxpr / dashing-requests.py
Created December 15, 2013 17:22
Example of how to send data to dashing from python
# http://stackoverflow.com/questions/20211990/sending-data-curl-json-in-python
import requests #pip install requests
import simplejson as json #pip install simplejson
url = "http://<ip-address>:3030"
widget = "welcome"
data = { "auth_token": "YOUR_AUTH_TOKEN", "text": "Python Greetings!!" }
fullUrl = "%s/widgets/%s" % (url, widget)
@epicserve
epicserve / example_command.py
Created October 30, 2013 17:05
Example of how to setup logging for a Django management command.
from django.core.management.base import BaseCommand
from mymodule import main
import logging
class Command(BaseCommand):
help = 'Do foo'
def handle(self, *args, **options):

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]
@mkaz
mkaz / web_timing.py
Created July 4, 2012 14:55
Use Selenium to Measure Web Timing
#!/usr/bin/env python
"""
Use Selenium to Measure Web Timing
Performance Timing Events flow
navigationStart -> redirectStart -> redirectEnd -> fetchStart -> domainLookupStart -> domainLookupEnd
-> connectStart -> connectEnd -> requestStart -> responseStart -> responseEnd
-> domLoading -> domInteractive -> domContentLoaded -> domComplete -> loadEventStart -> loadEventEnd