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 8 : Roman Numerals | |
# http://checkio.org | |
# Roman numerals come from the ancient Roman numbering system. | |
# They are based on specific letters of the alphabet which are combined | |
# to signify the sum (or, in some cases, the difference) of their values. | |
# The Roman numeral system is decimal based but not directly positional and does not include a zero. | |
# Roman numerals are based on combinations of these seven symbols: | |
# Symbol Value | |
# I 1 (unus) |
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 7 : Feed Pingeons | |
# http://checkio.org | |
# I start to feed one of the pigeons. | |
# A minute later two more fly by and a minute after that another 3. | |
# Then 4, and so on (Ex: 1+2+3+4+...). | |
# One portion of food lasts a pigeon for a minute, but in case there's not enough food for all the birds, | |
# the pigeons who arrived first ate first. | |
# Pigeons are hungry animals and eat without knowing when to stop. | |
# If I have N portions of bird feed, how many pigeons will be fed with at least one portion of wheat? |
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 6 : Speech Module | |
# http://checkio.org | |
# Stephen's speech module is broken. This module is responsible for his number pronunciation. | |
# He has to click to input all of the numerical digits in a figure, so when there are big numbers it can take him a long time. | |
# Help the robot to speak properly and increase his number processing speed by writing a new speech module for him. | |
# All the words in the string must be separated by exactly one space character. | |
# Be careful with spaces -- it's hard to see if you place two spaces instead one. | |
# Input: A number as an integer. | |
# Output: The string representation of the number as a string. |
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 to create a simple web service with Express | |
// In App.js | |
// Dependencies | |
var express = require('express') | |
, http = require('http') | |
, port = 8080 | |
// Application | |
var app = express() |
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
// Managing websocket with socket.io | |
// Setting a web socket and sending a message from client to server. | |
// Server side | |
var app = require('express')() | |
, util = require('util') | |
, server = require('http').createServer(app) | |
, io = require('socket.io').listen(server) | |
, port = 8013 |
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 to send message from A user to B user, encrypting it (asymetric cryptology) and sign it | |
var ursa = require('ursa') | |
, message = 'Hello world!' | |
, encoding = 'base64' | |
, buffer = new Buffer(message, 'ascii') | |
// Creating a pair of keys of user A (a private key contains both keys...) | |
console.log('Generating Keys Pair of user A...') | |
var keysA = ursa.generatePrivateKey() |
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
// All you need to know about Mocha testing in 60 lines | |
// Mocha Testing: http://visionmedia.github.io/mocha/ | |
// Installation: npm install -g mocha | |
// Run: mocha [test folder or test file] | |
// Example: mocha . (Run all js tests in folder) | |
// | |
// Usefull parameters: | |
// mocha -w . : Watch file changes and re-run tests | |
// mocha -d . : Debug mode |
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 to encrypt/decrypt with ursa module (asymmetric cryptology) | |
var ursa = require('ursa') | |
, message = 'Hello world!' | |
, encoding = 'base64' | |
// Creating a pair of keys (a private key contains both keys...) | |
console.log('Generating Keys Pair...') | |
var keys = ursa.generatePrivateKey() | |
// Making a private key |
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') | |
, fs = require('fs') | |
var sourceFile = __dirname + "/testFile.txt" | |
, targetFile = __dirname + "/testEncryptedFile.txt" | |
, key = "SecretKey" | |
, algorithm = 'aes192' // Another algorithms: 'des-ede3-cbc' | |
, cipher = crypto.createCipher(algorithm, key) | |
, decipher = crypto.createDecipher(algorithm, key) | |
, rs = fs.ReadStream(sourceFile) |
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 varName1 = "varName2" | |
global[varName1] = "Hello World" // This is the important line ;) | |
var staticVarName = global[varName1] | |
console.log("Var1: Name/Value : varName1/" + varName1) | |
console.log("Var2: Name/Value : " + varName1 + "/" + global[varName1]) | |
console.log("Static Var: Name/Value : staticVarName/" + staticVarName) |