Recent Pads - Page 29

Total pad count: 634
created 5 years, 281 days ago
how-python-dictionary-dicts-work

# Python how dictionaries work

# this is a comment

# lets create a dictionary (dict) named d

d = {}
... view all 50 lines

created 5 years, 281 days ago
45b1a477-00ca-46fc-95fc-ac7cac1b94af

# Python how dictionaries work

# this is a comment

# lets create a dictionary named d

d = {}
... view all 28 lines

created 5 years, 290 days ago
python-return-on-investment

cost = 76.43
revi = 124.81
roi  = ( revi - cost ) / cost
print( roi )

0.63299751406515758
... view all 7 lines

created 5 years, 293 days ago
salt-stack-python-renderer-create-user

#!py

group = {
  'groupname-fxhp' : {
    'group' : [
      'present',
      { 'gid': 1337 },
... view all 32 lines

created 5 years, 293 days ago
asdflkjasdflkjasdflkjasdf

#!py

group = {
  'groupname-rballestirni' : {
    'group' : [
      'present',
      { 'gid': 1337 },
... view all 32 lines

created 5 years, 303 days ago
0332eb74-569d-4b04-8854-9e18701458c5

>>> from os import path
>>> updated = path.getmtime( '/etc/motd' )
>>> UPDATED = datetime.fromtimestamp( updated )
>>> NOW = datetime.now()
>>> if (NOW - UPDATED).days > 1:
...     print "REFRESH"
... 
... view all 9 lines

created 5 years, 304 days ago
ffc425c9-9c2d-4f81-bf6a-37c1e2e1fe5f

$ egrep "succeeded in" test.log | awk '{print $8}' > times.txt
$ wc -l times.txt 
386 times.txt


>>> f = open( "times.txt", "r" )
>>> times = f.read().split()
... view all 11 lines

created 5 years, 304 days ago
0d6fc8c9-2770-4bea-94e0-b8eba49ae570

>>> f = open( "times.txt", "r" )
>>> times = f.read().split()
>>> T = [float(time[:-2]) for time in times]
>>> sum( T )/len( T )
5.4819964208416536
... view all 6 lines

created 5 years, 306 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 5 years, 307 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 5 years, 307 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 5 years, 308 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 5 years, 308 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 5 years, 308 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 5 years, 310 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 5 years, 340 days 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 5 years, 342 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 5 years, 346 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 5 years, 347 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 5 years, 348 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

pages 1 .. 27 28 29 30 31 32