Recent Pads - Page 32

Total pad count: 686
created 6 years, 332 days ago
list-of-2-char-combinations-in-python

from itertools import combinations
chars = "abcdefghijklmnopqrstuvwxyz0123456789"
combs = combinations( chars * 2, 2 )
domains = []
for comb in combs:
    domains.append( ''.join( comb ) )
... view all 7 lines

created 6 years, 333 days ago
pyramid-mongodb-authentication-login-required-decorator

from pyramid.httpexceptions import HTTPFound

def login_required( fn ):
    """check user in session, return request and user"""
    def wrapped( request ):
        if 'user' in request.session:
            username = request.session['user']
... view all 15 lines

created 6 years, 333 days ago
a2611c43-e066-4bd2-8a23-92c35a632499

data/sessions/container_file$ ls
0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f


data/sessions/container_file/8/8c$ ls
8c03bb75d2fb4594b3c2b0c0c86474f2.cache  
8c6cfd5fb0c44c2fb3b63376cd35d076.cache  
... view all 9 lines

created 6 years, 334 days ago
python-filevault

from os import path
from os import makedirs
from uuid import uuid4
from hashlib import sha256
from itertools import permutations

HEX="0123456789abcdef"
... view all 55 lines

created 6 years, 334 days ago
akjdsnfaewnfandfakjsnfd

from os import path
from os import makedirs
from uuid import uuid4
from hashlib import sha256
from itertools import permutations

HEX="0123456789abcdef"
... view all 55 lines

created 6 years, 334 days ago
e48d3d95-0cc3-4c09-8ea2-fcc34f8a8282

(virtpy)fox@dan:~/hg/peekapi/lib$ df
Filesystem           1K-blocks      Used Available Use% Mounted on
varrun                 1048576        44   1048532   1% /var/run
varlock                1048576         0   1048576   0% /var/lock
varrun                 1048576        44   1048532   1% /var/run
varlock                1048576         0   1048576   0% /var/lock
varrun                 1048576        44   1048532   1% /var/run
... view all 27 lines

created 6 years, 336 days ago
2b90c55b-6a1e-47e7-84a4-d2f77f2195e3

from os import makedirs, path
from random import randrange as r
from uuid import uuid4

class Vault( object ):
    def __init__( self, path='', name='vault', l=65, w=65 ):
        self.path = path 
... view all 50 lines

created 7 years, 1 day ago
salt-stack-fqdn-id-glob-style-targets

# salt stack FQDN id glob style targets

akuma:~$ sudo salt akuma.foxhop.net test.ping
akuma.foxhop.net: True
akuma:~$ sudo salt akuma.* test.ping
akuma.foxhop.net: True
akuma:~$ sudo salt *.foxhop.net test.ping
... view all 15 lines

created 7 years, 3 days ago
8343304f-34a4-4379-b0ad-2682fc91a5b4

  cost | requests |   ratio | market
 15.00 |   15,000 | $1:1000 | Good for development
 60.00 |   75,000 | $1:1250 | Better for freelancers
180.00 |  270,000 | $1:1500 | Best for production
... view all 4 lines

created 7 years, 7 days ago
better-python-script-to-count-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 = {}
... view all 33 lines

created 7 years, 8 days ago
7e0b293b-acb8-443f-acd8-58023b61764f

>>> assetDict = {}
>>> for asset in api.assets()['response']['assets']:
...     try:
...         assetDict[ asset['id'] ] = { 'name': asset['name'], 'ips': asset['definedIPs'] }
...     except:
...         pass
... view all 6 lines

created 7 years, 9 days ago
spread-server-patch-over-time-period

from getservers import getservers

import datetime # used to create datetime objects

import sys # used to get args from cli

def datepool( startdate, days = 8 ):
... view all 55 lines

created 7 years, 9 days ago
python-read-and-seek-binary-file

file = open( 'binaryfile', 'rb' )

# read to the needed data, this does a seek
file.read( 48 )

header  = file.read( 12 )
drawing = file.read( 6 )
... view all 8 lines

created 7 years, 9 days ago
perl-check-if-pid-is-running

#cat check_if_pid_running.pl

sub check_pid_file{
    open(PIDFILE, $_[0]) || return undef;
    my $pid = <PIDFILE>;
    close(PIDFILE);
    $pid =~ /^\s*(\d+)/ || return undef;
... view all 22 lines

created 7 years, 12 days ago
05820f2b-c54b-43a9-98e2-8e83001fe370

  cost | requests |   ratio | market
 15.00 |   15,000 | $1:1000 | Good for development
 60.00 |   75,000 | $1:1250 | Better for freelancers
180.00 |  300,000 | $1:1665 | Best for production
... view all 4 lines

created 7 years, 13 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 7 years, 13 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 7 years, 18 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 7 years, 18 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 7 years, 19 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

pages 1 .. 30 31 32 33 34 35