Skip to content

Instantly share code, notes, and snippets.

# When you have __init__.py (blank one), you can import the module using
from dirname import MyModule
# But when you dont have _init_.py at all, you cannot import the module without adding the path till that module to PYTHONPATH.
# In this case from dirname import MyModule FAILS, or reports error.
# If a directory (folder) contains a __init__.py file then it becomes a package.
# What you thought you read was not strictly correct, as you found.
# A package can be imported as if it was a module by itself, and any code in __init__.py is run, although it is often empty.
# Packages are a way of grouping multiple modules together, and you can load them using:
@rolandovillca
rolandovillca / python-helper-commands.sh
Last active December 14, 2015 21:36
PYTHON HELPER
$ apt-get remove python-pip
$ easy_install pip
@rolandovillca
rolandovillca / mysql-commands.sh
Last active August 29, 2015 14:27
ABOUT MYSQL TIPS
# SEARCH TABLE NAME:
SHOW TABLES FROM master LIKE '%table_name%';
# CHECK MYSQL CONF:
cat /etc/my.cnf
# BACKUP SINGLE DATABASE:
mysqldump -u username -p database_to_backup > backup_name.sql
# RESTORE SINGLE DATABASE:
@rolandovillca
rolandovillca / bash-ubuntu-commands-v2.sh
Last active August 29, 2015 14:23
UBUNTU COMMANDS V2
# AVOID SUDO PASSWORD:
# sudo: no tty present and no askpass program specified
$ sudo visudo
$ my_slave_user ALL=(ALL) NOPASSWD: ALL
# FORMATING A PENDRIVE:
# To show all the volume in your pc
sudo fdisk -l
# To see the usb flash drive suppose it may be /deb/sdb1
@rolandovillca
rolandovillca / my-gradle.gradle
Last active August 29, 2015 14:23
GRADLE SETTING EXAMPLE
//Add gradle to existing java project:
//Step 1:
build.gradle
//Step 2:
apply plugin: 'idea'
apply plugin: 'java'
//Step 3:
@rolandovillca
rolandovillca / dom-parsing-elements.js
Last active August 29, 2015 14:21
DOM HTML PARSING TIPS
$(".txtClass") => getElementsByClassName()
$("#childDiv2 .txtClass") => getElementById(), then getElementsByClassName()
$("#childDiv2 > .txtClass") => getElementById(), then iterate over children and check class
$("input.txtClass") => getElementsByTagName(), then iterate over results and check class
$("#childDiv2 input.txtClass") => getElementById(), then getElementsByTagName(), then iterate over results and check class
//Example:
$('.txtClass');
$('#childDiv2 .txtClass')
@rolandovillca
rolandovillca / coffee-code-tips.coffee
Last active August 29, 2015 14:17
COFFEESCRIPT NOTES
###
$ sudo npm install -g coffee-script
###
# COMPARING TERNARY CODE:
@getInstance: ->
Instante ?= new DeviceManager()
DeviceManagerSingleton.getInstance = function() {
return Instante != null ? Instante : Instante = new DeviceManager();
@rolandovillca
rolandovillca / node-tips.js
Last active December 6, 2015 00:17
NODEJS TIPS
//******************************************************************
// Steps to set nodejs, expressjs and grunt:
// 1. Install nodejs
// $ sudo npm install nodejs
// 2. Install expressjs//# 3. Install grunt-cli
// 5. Create a project using express (building a skeleton directory)
// 6. Install grunt
// 7. Create Package folder
// 8. Run grunt command
// 9. Create basic create and clean tasks
@rolandovillca
rolandovillca / mongo-commands.js
Last active August 29, 2015 14:16
MONGO DB QUERIES
// Count an array that is embedded into document.
// Document:
{name: 'Pepito', tags: ['A', 'B', 'C', 'D']}
//Mongodb query:
db.employees.aggregate(
{$match: {name : "Pepito"}},
{$unwind: "$tags"},
{$group: {_id: null, number: {$sum: 1 }}}
@rolandovillca
rolandovillca / git-commands.sh
Last active November 30, 2015 01:25
GIT COMMANDS
# CHECKOUT BRANCH
$ checkout branch -f
$ git pull
# CHECK CHANED FILES IN GIT COMMIT:
$ git log
$ git log -p -2
$ git log --pretty=oneline
$ git log --name-only
$ git log -1 --stat