Posts

Showing posts from October, 2016

How to comment multiple lines in Pycharm

Image
If you have a latin keyboard without numpad or any without slash key, maybe you couldn't use the shortcut enabled in Pycharm to comment multiple lines (Ctrl+Slash). To change this shortcut, you must create a default keymap copy to edit it, just clicking on Copy button. Go to File/Settings... and write keymap Now, filter by comment and add a new keystroke, like Shift+3 Enjoy it!

How to install pyqtgraph in Ubuntu 16.04

If you need any python module, the best alternative to install it is thrught pip: sudo pip install pyqtgraph but, I don't know why, if you try import pyqtgraph it doesn't recognize: python                   Python 2.7.12 (default, Jul  1 2016, 15:12:24)  [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import pyqtgraph as pg Traceback (most recent call last):   File "<stdin>", line 1, in <module> ImportError: No module named pyqtgraph Don't remember that always you can use apt-get for the same: sudo apt-get install python-pyqtgraph Now, you can see all examples with the following command: python -m pyqtgraph.examples Enjoy it!

Debug SDN Ryu controller with Pycharm

Image
If you want debug your Ryu App, you need execute ryu-manager throught Pycharm. To do it, you need execute the following python script in the same folder where you have the ryu app. I got the script from  https://www.mail-archive.com/ryu-devel%40lists.sourceforge.net/msg08519.html #!/usr/bin/env python # -*- coding: utf-8 -*- import sys from ryu.cmd import manager def main(): sys.argv.append('--ofp-tcp-listen-port') sys.argv.append('6633') sys.argv.append('simple_switch_13') sys.argv.append('--verbose') sys.argv.append('--enable-debugger') manager.main() if __name__ == '__main__': main() Where simple_switch_13 is your ryu.app.name. Run with Shift+F9 in Pycharm. If you choose any line in your Ryu app to debug, the console will show you the data about this variable like the following screenshot:

How to use Syntax Highlighter on Blogger

Image
You can see this video to know how to modifiy your blogger template to enable Syntax Highlighter. If you want add more brushes, you can add the code in this url to your blogger template: http://www.ikancomel.com/2016/08/cara-menambahkan-syntaxhighlighter-pada.html

Run wireshark as unprivileged user (without root)

Image
If you want to run wireshark without sudo, you will get this error and you couldn't capture traffic: To fix it, you must run these codes, and later reboot your machine: sudo groupadd wireshark sudo usermod -a -G wireshark $USER sudo chgrp wireshark /usr/bin/dumpcap sudo setcap cap_net_raw,cap_net_admin=eip /usr/bin/dumpcap sudo dpkg-reconfigure wireshark-common

How to import a graphml topology in mininet

If you want to load topologies in your network emulation with mininet, the best option is use grahpml format. I compared a lot extesions available from Gephi and Cytoscape (software for work with topologies) and graphml is one of the extensions that gives more information about the topology. You can export your topologies and save information like label, geolocalization, delay, bw, loss, etc. If you want real topologies, you can get them from Topology Zoo website . To import these topologies to mininet, you can use  Auto-Mininet (for mininet 2.0.0): git clone https://github.com/uniba-ktr/assessing-mininet.git cd assessing-mininet/parser wget  http://topology-zoo.org/files/Chinanet.graphml ./GraphML-Topo-to-Mininet-Network-Generator.py -f Chinanet.graphml -o chinaNet.py python chinaNet.py   File "test", line 44     Xi'an = self.addSwitch( 's18' )                             ^ SyntaxError: invalid syntax As you see, the script has incompatibility wi

How to install Gephi 0.9.2 snapshot version

Image
To install the lastest version, proceed to download it from github: git clone https://github.com/gephi/gephi.git cd gephi mvn clean install command not found: mvn To install maven, install it from repositories: sudo apt-get install maven mvn clean install cd modules/application   mvn nbm:cluster-app nbm:run-platform This last command will call to the following sentence to run gephi. /bin/sh -c /home/dragonx/Downloads/gephi/modules/application/target/gephi/bin/gephi --userdir /home/dragonx/Downloads/gephi/modules/application/target/userdir -J-Dnetbeans.logger.console=true -J-ea --branding gephi --jdkhome /usr/lib/jvm/java-8-openjdk-amd64 You can use it to create a .desktop file in your desktop to run it. [Desktop Entry] Type=Application Icon=/home/dragonx/Pictures/icons/gephi.png Name=Gephi Comment="Start Gephi" Exec= /bin/sh -c /home/dragonx/gephi/modules/application/target/gephi/bin/gephi --userdir /home/dragonx/gephi/modules/application/target/user

Change 8 spaces identation by default in vim by 4 spaces

To follow PEP-8 standar , for identation (tabs) it's recommended 4 spaces, not 8 as vim uses by default. To change this value, just add these lines to your vimrc file (usually located in /etc/vim/vimrc ). filetype plugin indent on " show existing tab with 4 spaces width set tabstop=4 " when indenting with '>', use 4 spaces width set shiftwidth=4 " On pressing tab, insert 4 spaces set expandtab if for some reason you need disable any command, just put an exclamation sign at the end of the command. For example: To enable number lines, use: set number To disable it, use: set number!

Mininet + Ryu + Faucet + Gauge + Influxdb

Image
First, to install faucet proceed to download it: pip install https://pypi.python.org/packages/a3/5a/197046b6fbad2f129e108358d7ba9674ebae638a227e6a1680cd77c7bd13/ryu-faucet-1.1.tar.gz or from the github: git clone https://github.com/onfsdn/faucet.git I had a problem to run gauge with this installer (maybe dependencies or something else). When I run gauge I got this error: raise SystemError('__init__ called too many times') SystemError: __init__ called too many times If you have the same issue reported as #19  or you want ot avoid it, they recommend to download the ryu-faucet VM to work on it: https://susestudio.com/a/ENQFFD/ryu-faucet/download/vmx The user is root and password is faucet I prefer work with byobu, to manage a lot tabs. To install on the VM just run: zypper install byobu If you try to run the ./test_config.py including in the faucet folder, you will see the following error: Traceback (most recent call last):   File "./test_config.py&q

How to control a MagicBlue LED bulb with Linux

Image
If you want to control your LED bulbs throught bluetooth, I recommend MagicBlue LED bulbs. Does not have an official API, but exists an unofficial on  https://github.com/Betree/magicblue First, I installed an old version of magicblue (gattlib based), but I'm going to tell you the steps if you need to solve it for a similar app. sudo apt-get install python3-pip  sudo pip3 install setuptools bluepy git clone https://github.com/Betree/magicblue.git cd magicblue sudo python3.5 setup.py install  sudo magicblueshell ImportError: No module named 'gattlib' pip3 install gattlib /usr/bin/ld: cannot find -lboost_python-py34     collect2: error: ld returned 1 exit status     error: command 'x86_64-linux-gnu-g++' failed with exit status 1 pip3 download gattlib tar xvzf ./gattlib-0.20150805.tar.gz cd gattlib-0.20150805/ sed -ie 's/boost_python-py34/boost_python-py35/' setup.py pip3 install . sudo magicblueshell list_devices Name         Mac addre

read command in zsh throws error

If you want emulate pause command in your shell, read is the most used command. In bash works without problems: read -p $'Press enter to continue...\n' ... but in zsh the argument -p is for coprocess, for that reason returns: read: -p: no coprocess To have a generic code to emulate pause command (independent of your shell), is better use the following sentence: printf 'Press enter to continue...\n';read ans Enjoy it!

How to accept pull request and update your master branch on github

If you have a project on github, probably you receive many pull request to update your project. To test the new branch, just write: git fetch origin pull/1/head:branch_name where 1 is the pull request number To push the new files, just write: git push origin branch_name If you want copy this branch to the master, just write: git push -f origin branch_name:master For more information, visit  https://help.github.com/articles/checking-out-pull-requests-locally/

Compile faster throught a RAM disk

Image
Compile programs takes a long time. Do you have an SSD and it takes more time than with your old HDD? A good solution is create a RAM disk and compile on them. First, you need to create a disk on your RAM (I chose 1Gb size) sudo mkdir /mnt/tmpfs sudo mount -o size=1G -t tmpfs none /mnt/tmpfs Now, for test the speed, procced to create a file on it with dd: dd if=/dev/zero of=file bs=1M count=100 On Ram disk (1.8 GB/s): On SSD disk (172 MB/s): It's a great difference! Enjoy it!

How to install Wireshark 2.3 on Ubuntu 16.04 with Iperf dissector compatibility

Image
To install this last version of wireshark, follow these steps: wget https://www.wireshark.org/download/automated/src/wireshark-2.3.0-947-g5a12a5e.tar.xz tar xvf wireshark-2.3.0-947-g5a12a5e.tar.xz cd wireshark-2.3.0-947-g5a12a5e ./autogen.sh ./autogen.sh: 1: ./autogen.sh: libtool: not found You must have libtool 2.2.2 or later installed to compile Wireshark. Download the appropriate package for your distribution/OS, or get the source tarball at ftp://ftp.gnu.org/pub/gnu/libtool/ Libtool usually already exists in the system, but with a different name. To solve it, just create a symbolic link with the name that autogen.sh expected: sudo ln -s /usr/bin/libtoolize /usr/bin/libtool Now, continue: ./autogen.sh ./configure  --with-lua checking for the location of lua.h... not found configure: error: Lua support was requested, but is not available You need to install liblua5.2-dev, because liblua5.3-dev is not recognized by wireshark by default. Wireshark

Add Valgrind to CLion

Image
Valgrind is an open-source memory debugger and you can use throught CLion (C IDE). I found this site where they show step by step how to add valgrim as external application to CLion. But... some mistakes that you could eventually find: 1.- You must install clang and obiously valgring: sudo apt-get install clang valgrind 2.- Modify the path to valgrim in valgrim.sh. Replace /usr/local/bin/valgrim by /usr/bin/valgrim 3.- You can find external tools configuration on:  File/Settings.../Tools/External Tools 4.- If you want the real icon to put it on toolbar, follow these commands: wget  http://support.dotriver.eu/lib/exe/fetch.php?cache=&w=64&h=64&tok=54e00f&media=presentation_des_logiciels:logo_valgrind.png convert logo_valgrind.png -resize 16x16 logo.png Now you can choose it to your toolbar If you run your code and you got no errors but suppressed errors, don't be afraid: You can see suppressed er

How to create a C project with CLion

If you create a new project on CLion, it will be a C++ project. If you want a C project, for the moment (2 years ago that users are asking the same to JetBrains here ) you will need to edit CMakeLists.txt file: replace: set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(SOURCE_FILES main.cpp) by: set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror") set(SOURCE_FILES main.c) Now, rename your main.cpp to main.c Enjoy it! Remember CLion (Jetbrains suite) it's free for students Free for students: Professional developer tools from JetBrains https://t.co/L8bxXBhwXA — NicolĆ”s Boettcher (@nicoboettcher) October 4, 2016 I enjoy student life @clion_ide pic.twitter.com/CxMNoW6cmg — NicolĆ”s Boettcher (@nicoboettcher) October 4, 2016

SNMP + Telegraf + InfluxDB

Image
First, install telegraf from github with the branch to fix-snmp-not-in-mib branch, that solves the issue #1833 git clone -b fix-snmp-not-in-mib --single-branch https://github.com/phemmer/telegraf.git After, I searched all MIB about an specific interface through bash language: IFACE="enp3s0" ID=`snmpwalk -v2c -c public localhost | grep "ifName.*STRING: $IFACE" | sed 's/\./ /g' | tail -n1 | awk '{print $2}'` snmpwalk -v2c -c public localhost | grep "^IF-MIB::if.*\.$ID" It outputs a lots MIBs, but most relevants are: IF-MIB::ifName.2 = STRING: enp3s0 IF-MIB::ifDescr.2 = STRING: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express IF-MIB::ifType.2 = INTEGER: ethernetCsmacd(6) IF-MIB::ifMtu.2 = INTEGER: 1500 IF-MIB::ifSpeed.2 = Gauge32: 10000000 IF-MIB::ifHighSpeed.2 = Gauge32: 10 IF-MIB::ifPromiscuousMode.2 = INTEGER: false(2) IF-MIB::ifConnectorPresent.2 = INTEGER: true(1) IF-MIB::ifPhysAddress.2 = STRING: AB:57:

Issues to display SNMP information

This is a typical error on snmpwalk at the beginning of the display information: snmpwalk -v1 -c public 127.0.0.1 system Expected "::=" (RFC5644): At line 493 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB Expected "{" (EOF): At line 651 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB Bad object identifier: At line 651 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB Bad parse of OBJECT-IDENTITY: At line 651 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB Bad operator (INTEGER): At line 73 in /usr/share/mibs/ietf/SNMPv2-PDU Unlinked OID in IPATM-IPMC-MIB: marsMIB ::= { mib-2 57 } Undefined identifier: mib-2 near line 18 of /usr/share/mibs/ietf/IPATM-IPMC-MIB Open /etc/snmp/snmp.conf and it should be as follows: mibs : mibs +SNMPv2-MIB But, if you run ... snmptranslate -m all -Tz -On | sed -e 's/"//g' > /tmp/oids.txt ... to create your oids.txt, you still see the same error. To fix them, you can edit th