Skip to content

Instantly share code, notes, and snippets.

View jangeador's full-sized avatar
🐵

Delio Castillo jangeador

🐵
View GitHub Profile
@jangeador
jangeador / month_generator.py
Last active August 29, 2015 14:05
Generate a list of the months of the year in Python
'''
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']
# 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 {} +
@jangeador
jangeador / LimitSentMessages.ps1
Last active August 29, 2015 14:06
Limit the number of messages that an administrator can send Exchange 2010
# 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
@jangeador
jangeador / find_object_in_list.py
Last active August 29, 2015 14:06
Find object in list of objects or return None
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
@jangeador
jangeador / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jangeador
jangeador / generate_keypair.sh
Last active August 29, 2015 14:06
Command to generate a key pair
ssh-keygen -t rsa -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label
@jangeador
jangeador / fabfile_gist.py
Created November 4, 2014 18:31
A script to backup several switches at once
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',
@jangeador
jangeador / temperature.cpp
Created January 12, 2015 15:11
Temperature Converter (From my early college days!)
/* Delio Castillo
BIS 221 C++
Charles Godfrey, Instructor
Spring 2002
Project Name : Project03A
Purpose of Program
To convert temperatures from Celsius to
#!/bin/bash
# Default Variable Declarations
DEFAULT="default.txt"
FILEEXT=".ovpn"
CRT=".crt"
KEY=".key"
CA="ca.crt"
TA="ta.key"
@jangeador
jangeador / baja_guia.sh
Last active August 29, 2015 14:21
Bajar la Guia del proyecto TVGuia para OpenElec
#!/bin/bash
# creado 5/19/15 por eljohnsmith para proyecto TVGuia
# Enlace a Dropbox Folder. Hay que asegurar que el final dice "dl=1" en vez de "dl=0"
dropboxlink=https://www.dropbox.com/sh/1bwe0nfpc92lmqb/AAAy0B2CxS56-74kZGAjore0a?dl=1
filedate=$(date +%Y%m%d)
tvguia=~/tvguia
downloads=~/downloads