Skip to content

Instantly share code, notes, and snippets.

View GuillermoPena's full-sized avatar

Guillermo Peña GuillermoPena

  • Green Box Software
  • Madrid, Spain
View GitHub Profile
@GuillermoPena
GuillermoPena / nodeJs.crypto.calculatingHash.js
Created February 26, 2014 16:30
NodeJS - CRYPTO : How to calculate a hash from file or string
var crypto = require('crypto')
, fs = require('fs')
// Algorithm depends on availability of OpenSSL on platform
// Another algorithms: 'sha1', 'md5', 'sha256', 'sha512' ...
var algorithm = 'sha1'
, shasum = crypto.createHash(algorithm)
// Updating shasum with file content
var filename = __dirname + "/anything.txt"
@GuillermoPena
GuillermoPena / 0_reuse_code.js
Created May 28, 2014 08:43
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@GuillermoPena
GuillermoPena / python_resources.md
Created May 28, 2014 08:43 — forked from jookyboi/python_resources.md
Python-related modules and guides.

Packages

  • lxml - Pythonic binding for the C libraries libxml2 and libxslt.
  • boto - Python interface to Amazon Web Services
  • Django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  • Fabric - Library and command-line tool for streamlining the use of SSH for application deployment or systems administration task.
  • PyMongo - Tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.
  • Celery - Task queue to distribute work across threads or machines.
  • pytz - pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher.

Guides

@GuillermoPena
GuillermoPena / checkio.1.01.Non-uniqueElements.py
Created May 28, 2014 08:50
CheckIO - Home Challenge 1 : Non-unique Elements
# 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):
@GuillermoPena
GuillermoPena / checkio.1.02.Median.py
Created May 28, 2014 09:02
CheckIO - Home Challenge 2 : Median
# 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.
@GuillermoPena
GuillermoPena / checkio.1.04.TheMostWantedLetter.py
Created May 28, 2014 09:08
CheckIO - Home Challenge 4 : The Most Wanted Letter
# 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".
@GuillermoPena
GuillermoPena / checkio.1.03.HousePassword.py
Created May 28, 2014 09:11
CheckIO - Home Challenge 3 : House Password
# 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.
@GuillermoPena
GuillermoPena / checkio.1.05.XsAndOsReferee.py
Created May 28, 2014 09:38
CheckIO - Home Challenge 5 : Xs and Os Referee
# 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.
@GuillermoPena
GuillermoPena / nodeJs.stdio.insertingArgumentsByConsole.js
Created May 28, 2014 09:52
NodeJS - STDIO : Inserting arguments by console
// 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(' ')
@GuillermoPena
GuillermoPena / nodeJs.loggingWithWinston.js
Created May 28, 2014 09:53
NodeJS - WINSTON : Logging with winston
// 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")