This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Generate a sorted list with the months of the year | |
''' | |
import datetime | |
months = [datetime.date(2000, m, 1).strftime('%m - %B') for m in range(1, 13)] | |
print months | |
''' | |
print months | |
['01 - January', '02 - February', '03 - March', '04 - April', '05 - May', '06 - June', '07 - July', '08 - August', '09 - September', '10 - October', '11 - November', '12 - December'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_or_create(session, model, **kwargs): | |
''' | |
Creates an object or returns the object if exists | |
credit to Kevin @ StackOverflow | |
from: http://stackoverflow.com/questions/2546207/does-sqlalchemy-have-an-equivalent-of-djangos-get-or-create | |
''' | |
instance = session.query(model).filter_by(**kwargs).first() | |
if instance: | |
return instance | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Brings all files from subdirectories to the root or to a designated folder | |
# to move to another folder substitute "." with the destination | |
# the backup=numbered option keeps files with the same name using a number | |
find /src/dir -type f -exec mv --backup=numbered -t /dst/dir {} + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To create a new policy where the users can send to 30 recipients a day | |
# and no more than 1 message per minute, you would use this command: | |
New-ThrottlingPolicy -Name LimitMessagesSent -RecipientRateLimit 30 -MessageRateLimit 1 | |
# To assign it to a user, use this command: | |
Set-Mailbox -Identity user_alias -ThrottlingPolicy LimitMessagesSent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
next((x for x in test_list if x.value == value), None) | |
''' | |
This gets the first item from the list that matches the condition, and returns None if no item matches. It's my preferred single-expression form. | |
However, | |
''' | |
for x in test_list: | |
if x.value == value: | |
print "i found it!" | |
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh-keygen -t rsa -C "[email protected]" | |
# Creates a new ssh key, using the provided email as a label |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM Rules are from here: http://www.veeam.com/kb1518 | |
REM On Hyper-V Host Server open these ports | |
netsh advfirewall firewall add rule name="VEEAM Backup and Replication TCP" dir=in action=allow protocol=TCP localport=135,137-139,445 | |
netsh advfirewall firewall add rule name="VEEAM Backup and Replication UDP" dir=in action=allow protocol=UDP localport=135,137-139,445 | |
netsh advfirewall firewall add rule name="VEEAM Installer Service" dir=in action=allow protocol=TCP localport=6160 | |
netsh advfirewall firewall add rule name="VEEAM Backup Proxy Service" dir=in action=allow protocol=TCP localport=6162 | |
netsh advfirewall firewall add rule name="VEEAM vPower NFS Service" dir=in action=allow protocol=TCP localport=6161 | |
netsh advfirewall firewall add rule name="VEEAM vPower NFS Service" dir=in action=allow protocol=TCP localport=6161 | |
netsh advfirewall firewall add rule name="VEEAM Standard NFS Ports TCP" dir=in action=allow protocol=TCP localport=111,2049-2059,1058-1068 | |
netsh advfirewall firewall add rule name="VEEAM Stand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fabric.api import run, env, settings | |
extreme_switches = {'172.31.100.21': 'RDSL-S042-DCore-1', | |
'172.31.100.22': 'RDSL-S042-DCore-2', | |
'172.31.100.41': 'GES-S042', | |
'172.31.100.61': 'DSDS-S042', | |
'172.31.100.81': 'DV-S042', | |
'172.31.100.101': 'SWJH-S042', | |
'172.31.100.121': 'EP-S042', | |
'172.31.100.141': 'AZD-S042', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Delio Castillo | |
BIS 221 C++ | |
Charles Godfrey, Instructor | |
Spring 2002 | |
Project Name : Project03A | |
Purpose of Program | |
To convert temperatures from Celsius to |
OlderNewer