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
var crypto = require('crypto') | |
// Encrypt/Decrypt a string | |
var key = "SecretKey" | |
, message = "This is the text to cipher!" | |
// Encrypting | |
var cipher = crypto.createCipher('des-ede3-cbc', key) | |
, cryptedMessage = cipher.update(message, 'utf8', 'hex') | |
cryptedMessage+= cipher.final('hex') |
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
// How wait inside of loop... | |
// Countdown | |
var counter = 10 | |
var countdown = function() { | |
console.log(counter) | |
counter-- | |
return (counter > 0) | |
} |
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
//Read json object from json file. | |
//Write json object to json file | |
var fs = require('fs') | |
var util = require('util') | |
// __dirname is folder where script is running | |
// NOTE: Use always " in json file content | |
var cfgFile = __dirname + "/anything.json" |
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
// More info here: https://github.com/flatiron/winston | |
// Simple Example | |
var winston = require('winston') | |
var mongoTransport = require('winston-mongodb').MongoDB | |
var defaultLogger = winston | |
defaultLogger.level = 'silly' | |
defaultLogger.silly("Default logger") |
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
// More info here: http://sgmonda.github.io/stdio/ | |
var stdio = require('stdio') | |
var opts = stdio.getopt({ | |
'name': { key: 'n', description: 'Name', args: 1, mandatory: true }, | |
'surnames': { key: 's', description: 'Surnames', args: 2 }, | |
'age': { key: 'a', description: 'Age: ', args: 1 } | |
}) | |
console.log( 'Your full name is ' + opts.name | |
+ ' ' + opts.surnames.join(' ') |
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
# CheckIO - Home Challenge 5 : Xs and Os Referee | |
# http://checkio.org | |
# Tic-Tac-Toe, sometimes also known as Xs and Os, is a game for two players (X and O) | |
# who take turns marking the spaces in a 3×3 grid. | |
# The player who succeeds in placing three respective marks in a horizontal, vertical, | |
# or diagonal rows (NW-SE and NE-SW) wins the game. | |
# But we will not be playing this game. You will be the referee for this games results. | |
# You are given a result of a game and you must determine if the game ends in a win | |
# or a draw as well as who will be the winner. |
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
# CheckIO - Home Challenge 3 : House Password | |
# http://checkio.org | |
# Stephan and Sophia forget about security and use simple passwords for everything. | |
# Help Nikola develop a password security check module. | |
# The password will be considered strong enough if its length is greater than or equal to 10 symbols, | |
# it has at least one digit, as well as containing one uppercase letter and one lowercase letter in it. | |
# The password contains only ASCII latin letters or digits. | |
# Input: A password as a string (Unicode for python 2.7). | |
# Output: Is the password safe or not as a boolean or any data type that can be converted and processed as a boolean. In the results you will see the converted results. |
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
# CheckIO - Home Challenge 4 : The Most Wanted Letter | |
# http://checkio.org | |
# You are given a text, which contains different english letters and punctuation symbols. | |
# You should find the most frequent letter in the text. The letter returned must be in lower case. | |
# While checking for the most wanted letter, casing does not matter, | |
# so for the purpose of your search, "A" == "a". | |
# Make sure you do not count punctuation symbols, digits and whitespaces, only letters. | |
# If you have two or more letters with the same frequency, then return the letter which comes first in the latin alphabet. | |
# For example -- "one" contains "o", "n", "e" only once for each, thus we choose "e". |
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
# CheckIO - Home Challenge 2 : Median | |
# http://checkio.org | |
# A median is a numerical value separating the upper half of a sorted array of numbers from the lower half. | |
# In a list where there are an odd number of entities, the median is the number found in the middle of the array. | |
# If the array contains an even number of entities, then there is no single middle value, | |
# instead the median becomes the average of the two numbers found in the middle. | |
# For this mission, you are given a non-empty array of natural numbers (X). | |
# With it, you must separate the upper half of the numbers from the lower half and find the median. |
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
# CheckIO - Home Challenge 1 : Non-unique Elements | |
# http://checkio.org | |
# You are given a non-empty list of integers (X). | |
# For this task, you should return a list consisting of only the non-unique elements in this list. | |
# To do so you will need to remove all unique elements (elements which are contained in a given list only once). | |
# When solving this task, do not change the order of the list. | |
# Example: [1, 2, 3, 1, 3] 1 and 3 non-unique elements and result will be [1, 3, 1, 3]. | |
def checkio(data): |