Recent Pads - Page 32

Total pad count: 671
created 6 years, 325 days ago
python-file-rotation-with-retention-count

def rotate( target, retention = 3 ):
    """file rotation routine"""
    if path.isfile( target ): # check if we even need to rotate
        for i in range( retention-2, 0, -1 ): # count backwards
            old_name = "%s.%s" % ( target, i )
            new_name = "%s.%s" % ( target, i + 1 )
            try: move( old_name, new_name  )
... view all 10 lines

created 6 years, 325 days ago
python-file-rotation-with-varible-retention-count

from os import path
from shutil import move

tehfile = "junk"
retention = 3

if path.isfile( tehfile ):
... view all 23 lines

created 6 years, 330 days ago
python-count-file-extensions

# bash script to find all extensions in the current tree
find . -type f -name '*.*' | awk -F. '{print $NF}' > /tmp/extensions.txt

# python script to count extensions
extensions = {}
f = open( '/tmp/extensions.txt' )
for extension in f.readlines():
... view all 16 lines

created 6 years, 330 days ago
7aadb76f-0827-4fb0-92a3-d016d65e8b89

>>> f.close()
>>> f = open( '/tmp/extens.txt' )
>>> for ext in f.readlines():
...     ext = ext.rstrip('\n')
...     if ext in myDICT:
...         myDICT[ext] += 1
...     else:
... view all 9 lines

created 6 years, 330 days ago
pymongo-is-so-simple

import pymongo
db = pymongo.Connection( 'mongodb://localhost/' )[ 'linkpeek' ]
print sum( [ user['rcount'] for user in db.user.find() ] )
... view all 4 lines

created 6 years, 333 days ago
messing-with-python-callbacks

>>> from time import sleep
>>> def call_me_maybe( target, callback ):
...     print target
...     sleep( 5 )
...     callback( target.upper() )
... 
>>> def test_call_me_maybe( target ):
... view all 17 lines

created 6 years, 336 days ago
python-multi-arm-bandit

from random import random, choice

def choose_lever( levers ):
    """Accept a dict of levers, return tuple ( key, levers )"""
    if random() < 0.1:
        # exploration! choose random lever 10% of time
        explored_key = choice( levers.keys() )
... view all 45 lines

created 6 years, 336 days ago
test_hyphen_filenames

    def test_hyphen_filenames(self):
        info = DummyRendererInfo({
            'name':'app:moon-and-world.mak',
            'package':None,
            'registry':self.config.registry,
            'settings':{},
            'type': ''
... view all 11 lines

created 6 years, 337 days ago
5d498f88-5e8c-4f08-b73a-27d50a56ac11

@view_config( route_name="template")
def template(request):
    # check if template exists before rendering
    from pkg_resources import resource_exists
    from pyramid.renderers import render_to_response

... view all 17 lines

created 6 years, 337 days ago
3165a602-db16-417d-8c03-e1bcff0ab644

(virtpy)[fox@blanka linkpeek]$ pserve development.ini --reload
Starting subprocess with file monitor
Starting server in PID 4365.
serving on 0.0.0.0:9001 view at http://127.0.0.1:9001
2012-09-22 01:19:26,731 ERROR [pyramid_debugtoolbar][worker 0] Exception at http://127.0.0.1:9001/how-much-does-linkpeek-cost
traceback url: http://127.0.0.1:9001/_debug_toolbar/exception?token=15fac23dae77dfb5b654&tb=54746512
Traceback (most recent call last):
... view all 35 lines

created 6 years, 339 days ago
2652d76d-e09c-4ac0-af9f-0e973e715e40

    if page['state'] != 'serving': # if the page is not serving
        waited = 0
        while page['state'] != 'serving':
            sleep( 1 )
            waited += 1
            page = request.db.api.find_one( { 'uri': uri } )
            if waited >= 30 or not page:
... view all 13 lines

created 6 years, 340 days ago
049bf5e1-1c89-4fa8-825b-94737ef8d93a

/api/v1?uri=http://davematthewsbandspotify.com/&apikey=e0a8tumxz&token=8ca9b4af907c59d90820198cf93effff&size=560x280

/api/v2/e0a8tumxz/8ca9b4af907c59d90820198cf93effff?uri=http://davematthewsbandspotify.com/&size=560x280
... view all 3 lines

created 6 years, 340 days ago
fb0f5474-c229-4b2c-8505-5fb54c8f5005

/api/v1?uri=http://davematthewsbandspotify.com/&apikey=e0a8tumxz&token=8ca9b4af907c59d90820198cf93effff&size=560x280

/api/v2/e0a8tumxz/8ca9b4af907c59d90820198cf93effff?target=http://davematthewsbandspotify.com/&size=560x280
... view all 3 lines

created 6 years, 343 days ago
pyramid-inject-renderer-globals-title-and-analytics

def inject_renderer_globals( event ):
    """Inject some renderer globals before passing to template"""

    request = event['request']

    # Build ${title} from the current request.path  
    event['title'] =  ' - '.join( request.path.replace( '-', ' ' ).split( '/' )[1:] ).title()
... view all 11 lines

created 6 years, 343 days ago
65cc6c6f-10ab-44dd-b5e0-ef024b7364ff

what pad is this 
looks fast
... view all 3 lines

created 6 years, 346 days ago
a213fc26-5b26-45b6-a861-4fe755a72835

Delivered-To: northwindmanagement@gmail.com
Received: by 10.50.104.197 with SMTP id gg5csp61720igb;
        Wed, 12 Sep 2012 00:06:42 -0700 (PDT)
Received: by 10.182.193.7 with SMTP id hk7mr20884301obc.30.1347433600985;
        Wed, 12 Sep 2012 00:06:40 -0700 (PDT)
Return-Path: <Nick.Raymonde@sonymusic.com>
Received: from va3outboundpool.messaging.microsoft.com (va3ehsobe002.messaging.microsoft.com. [216.32.180.12])
... view all 66 lines

created 6 years, 350 days ago
e9f48aa9-27b7-4b60-bbca-4e8dde419ec2

Plan: good, Percentage: 66
Plan: better, Percentage: 0
Plan: best, Percentage: 8
Plan: super, Percentage: 16
... view all 5 lines

created 6 years, 351 days ago
yqbgsdqajfryrs

service zenoss start
Zenoss not initialized.  Performing first-boot initialization...
Fresh install pre steps
Checking RRDtool version >= 1.4.7: [ OK ] 1.4.7
Adding RabbitMQ user:
Error: {user_already_exists,<<>>}
Adding RabbitMQ vhost:
... view all 13 lines

created 6 years, 355 days ago
dcbf5ace-9989-4a4f-98ed-5fe173dc450b

22/tcp   open     ssh
80/tcp   open     http
389/tcp  filtered ldap
443/tcp  open     https
514/tcp  filtered shell
646/tcp  filtered ldp
1718/tcp filtered unknown
... view all 14 lines

created 6 years, 355 days ago
8291a4b5-193b-4b8b-be93-f5f74eaa3b2a

Not shown: 991 closed ports
PORT     STATE    SERVICE
22/tcp   open     ssh
80/tcp   open     http
135/tcp  filtered msrpc
139/tcp  filtered netbios-ssn
443/tcp  open     https
... view all 11 lines

pages 1 .. 30 31 32 33 34