Skip to content

Instantly share code, notes, and snippets.

rolandovillca

View GitHub Profile
View python-tips.py
# 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:
View python-helper-commands.sh
$ apt-get remove python-pip
$ easy_install pip
View mysql-commands.sh
# 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:
View bash-ubuntu-commands-v2.sh
# 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 Aug 29, 2015
GRADLE SETTING EXAMPLE
View my-gradle.gradle
//Add gradle to existing java project:
//Step 1:
build.gradle
//Step 2:
apply plugin: 'idea'
apply plugin: 'java'
//Step 3:
View dom-parsing-elements.js
$(".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')
View coffee-code-tips.coffee
###
$ sudo npm install -g coffee-script
###
# COMPARING TERNARY CODE:
@getInstance: ->
Instante ?= new DeviceManager()
DeviceManagerSingleton.getInstance = function() {
return Instante != null ? Instante : Instante = new DeviceManager();
View node-tips.js
//******************************************************************
// 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
View mongo-commands.js
// 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 }}}
View git-commands.sh
# 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
You can’t perform that action at this time.