Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Damian Esteban damianesteban

🎯
Focusing
View GitHub Profile
View gist:5869988
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 Jul 2, 2013
Python "PygLatin" Translator.
View gist:5906045
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 Aug 2, 2013
Basic FTP Implementation in Python
View basic_ftp
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 Aug 2, 2013
More basic implementation of ftp on python
View basic_ftp_two
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 Aug 2, 2013
What is my IP address?
View 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 Aug 2, 2013
Simple Hangman Script
View hangman
#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 Aug 14, 2013
Simple Text Editor in Python
View simple_text_editor
# 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 Aug 14, 2013
Simple Droid Text Game
View 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 Aug 14, 2013
Two simple text games in python
View two_text_games
############################################################
# 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 Aug 15, 2013
text game with classes in python, from activestate.com
View classes_in_game
## 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