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 count_words(text): | |
"""Makes a statistic of the words appearing in the text | |
and returns a dictionary where keys are the words and | |
values are the number of occurrence of each word.""" | |
words = text.split() | |
result = {} | |
for word in words: | |
if word in result: | |
result[word] += 1 |
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 projects_repository import ProjectsRepository | |
from project import Project | |
def load_all_items_from_database(repository): | |
print("Loading all items from database:") | |
projects = repository.read() | |
at_least_one_item = False | |
for p in projects: | |
at_least_one_item = True |
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 bson.objectid import ObjectId | |
class Project(object): | |
"""A class for storing Project related information""" | |
def __init__(self, project_id=None, title=None, description=None, price=0.0, assigned_to=None): | |
if project_id is None: | |
self._id = ObjectId() | |
else: | |
self._id = project_id |
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 pymongo import MongoClient | |
from bson.objectid import ObjectId | |
from project import Project | |
class ProjectsRepository(object): | |
""" Repository implementing CRUD operations on projects collection in MongoDB """ | |
def __init__(self): | |
# initializing the MongoClient, this helps to | |
# access the MongoDB databases and collections |
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
<!DOCTYPE html> | |
<html> | |
<!-- HTML dokumentum fej része --> | |
<head> | |
<!-- Erre azért van szükség, hogy a böngésző meg tudja jeleníteni az ékezetes magyar betüket --> | |
<meta charset="utf-8"> | |
<!-- Hivatkozunk a hello_vilag2.js kódfájlra --> | |
<script src="hello_vilag2.js" type="text/javascript"></script> | |
</head> |
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
console.log("Hello Világ"); |
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
<!-- HTML fájlokba ezen jelek közzé lehet kommentárokat tenni --> | |
<!DOCTYPE html> | |
<html> | |
<!-- HTML dokumentum fej része --> | |
<head> | |
<!-- Erre azért van szükség, hogy a böngésző meg tudja jeleníteni az ékezetes magyar betüket --> | |
<meta charset="utf-8"> | |
<!-- Hivatkozunk az előzőekben megírt JavaScript kódfájlunkra --> | |
<script src="hello_vilag.js" type="text/javascript"></script> |
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
//minden szöveg, amelyet // előz meg, | |
//illetve /* ... */ jelek közzé teszünk | |
//a JavaScript kommentként kezeli és figyelmen kívül hagyja | |
alert("Hello Világ!"); |
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
// | |
// Method names taken from: http://nodejs.org/api/fs.html#fs_class_fs_stats | |
// | |
//stats is the return value if fs.statsync(PATH_TO_FILE) method | |
stats.isFile(); | |
stats.isDirectory(); | |
stats.isBlockDevice(); | |
stats.isCharacterDevice(); | |
stats.isSymbolicLink(); //(only valid with fs.lstat()) |
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
#!/usr/bin/env node | |
/* | |
This small node.js app should do exactly what the wc linux command does. | |
Quote from man wc: | |
Print newline, word, and byte counts for each FILE, and a total line if more than one FILE is specified. With no FILE, or when FILE is -, read standard | |
input. A word is a non-zero-length sequence of characters delimited by white space. The options below may be used to select which counts are printed, | |
always in the following order: newline, word, character, byte, maximum line length. |
NewerOlder