Skip to content

Instantly share code, notes, and snippets.

View damianesteban's full-sized avatar
🎯
Focusing

Damian Esteban damianesteban

🎯
Focusing
View GitHub Profile
from datetime import datetime
now = datetime.now()
print now
current_month = now.month
current_day = now.day
current_year = now.year
current_hour = now.hour
current_minute = now.minute
current_second = now.second
print current_month
@damianesteban
damianesteban / gist:5906045
Created July 2, 2013 01:07
Python "PygLatin" Translator.
pyg = 'ay'
original = raw_input('Enter a word to be translated:')
word = original.lower()
first = word[0]
new_word = word + pyg
if len(original) > 0 and original.isalpha():
if first == 'a' or first == 'e' or first == 'i' or first == 'u':
print new_word
else:
new_word = word[1:] + word[0] + pyg
@damianesteban
damianesteban / basic_ftp
Created August 2, 2013 01:26
Basic FTP Implementation in Python
from ftplib import FTP
ftp = FTP('ftp.cwi.nl') # connect to host, default port
ftp.login() # user anonymous, passwd anonymous@
ftp.retrlines('LIST') # list directory contents
@damianesteban
damianesteban / basic_ftp_two
Created August 2, 2013 01:28
More basic implementation of ftp on python
import ftplib
ftp = ftplib.FTP('ftp.sunet.se', 'anonymous', 'anonymous@sunet.se')
print "File List: "
files = ftp.dir()
print files
@damianesteban
damianesteban / ip_address
Created August 2, 2013 01:42
What is my IP address?
import urllib
import re
print "we will try to open this url, in order to get IP Address"
url = "http://checkip.dyndns.org"
print url
request = urllib.urlopen(url).read()
@damianesteban
damianesteban / hangman
Created August 2, 2013 01:44
Simple Hangman Script
#importing the time module
import time
#welcoming the user
name = raw_input("What is your name? ")
print "Hello, " + name, "Time to play hangman!"
print "\n"
@damianesteban
damianesteban / simple_text_editor
Created August 14, 2013 03:38
Simple Text Editor in Python
# Captain Deadbones, activestate.com
from Tkinter import *
from tkSimpleDialog import askstring
from tkFileDialog import asksaveasfilename
from tkMessageBox import askokcancel
class Quitter(Frame):
def __init__(self, parent=None):
Frame.__init__(self, parent)
@damianesteban
damianesteban / droid_text_game
Created August 14, 2013 03:40
Simple Droid Text Game
# copied from jay on activestate.com
#droids.py
import time
import random
from random import randint
print('\n' * 100)
print('\n\n[-Droids : by jay : type help-]')
print('\n\n\n------------------------')
print(' DROIDS')
@damianesteban
damianesteban / two_text_games
Created August 14, 2013 22:44
Two simple text games in python
############################################################
# Cloned from jay on activestate.com
# - My version on the game "Dragon Realm".
# - taken from the book "invent with python" by Al Sweigart.
# - thanks for a great book Mr Sweigart.
# - this code takes advantage of python 3.
############################################################
#files.py
import random
@damianesteban
damianesteban / classes_in_game
Created August 15, 2013 00:54
text game with classes in python, from activestate.com
## bctg.py
## by andrew wayne teesdale jr.
class LL:
def __init__(self, ll, name):
import random
self.randnum=random.choice(['True', 'False'])
self.msg=random.choice(['I dont know.', 'Oh, Yes '+ll, 'I think '+name+' knows.'])
def say_to(self, msg):
## msging system
print msg