Skip to main content

Posts

Showing posts from 2018

Getting Camera to work on Raspberry Pi with Just Terminal Access

Here is a simple guide to get started on Raspberry Pi Camera with just though ssh. Access through ssh ssh pi@<Pi's IP> Install $ sudo apt-get install python-picamera $ sudo apt-get install python3-picamera Enable Camera $ sudo raspi-config Interfacing options -> Camera -> Enable Create the Python script: $ touch test.py $ nano test.py paste one of the following: Camera sample code from picamera import PiCamera from time import sleep camera = PiCamera ( ) camera . start_preview ( ) sleep ( 10 ) camera . stop_preview ( ) Video Sample code camera . start_preview ( ) camera . start_recording ( '/home/pi/video.h264' ) sleep ( 10 ) camera . stop_recording ( ) camera . stop_preview ( ) $ python test.py Copy the file over to host $ scp <video or image file> <host user name>@<hosts's IP>:<host destination folder> The video file can be played through VLC.

Getting Used to tmux!

This is a short guide to multiplexing in your terminal! Installation Install  $ sudo apt install tmux launch $ tmux Core Commands Here is a small list of the most useful set of commands. Just remember these and you shall be tmuxing around in no time! Adding panes Add panes vertically ctl + b % Add panes Horizontally ctl + b "  Moving around panes Move to the panes to the right ctl + b <Right> Move to the panes to the left ctl + b <LEFT> Move to the panes to the up ctl + b <UP> Move to the panes to the down ctl + b <DOWN> Closing Window  Close current panes ctl + d Tip!!! You can resize panes by pressing: $ ctl + b + <arrow button> Scroll: $ ctl + b [ press < UP > or < DOWN > Quit $ q  

Disabling and Enabling Animation Effects in Ubuntu!

Window animation effects provide a nice and pleasant feel when using a desktop environment. At the same time, it is also end up hogging resources. So here are the terminal commands to enable and disable them! Enable $ gsettings set org.gnome.desktop.interface enable-animations true Disable $ gsettings set org.gnome.desktop.interface enable-animations false

Setting up SSH Keys for Git Account

Here is a simple guide to Generate ssh key: $ ssh-keygen just enter or say yes for every questions Enter your public key into your git account: cat ~/.ssh/id_rsa.pub Paste all the content of the file to the designated git account. The place where to put it may differ depending on what you are using (e.g. gitlab, github, etc...)  Tip: Almost all of them will be around the settings page of the git account Done!

Easiest Way to Connect Raspberry Pi Through SSH Over WiFi

Here is a simple way to connect raspberry pi and ssh into it. Note: If  you are using pi zero, it is assumed that you have a usb wifi adapter connected through the USB port. Open terminal in boot partition of the SD card. Enable SSH: $ touch ssh Set Wifi Network: $ touch wpa_suplicant.conf ctrl_interface = DIR = /var/run/wpa_supplicant GROUP = netdev network = { ssid = "YOUR_NETWORK_NAME" psk = "YOUR_PASSWORD" key_mgmt = WPA-PSK } Line 1 is only for Raspbien stretch. Delete it if you are using Jessie. Connect through SSH: Insert SD card and boot. Find the IP address of the Raspberry Pi by accessing the router. e.g. BT uses 192.168.1.254 $ ssh pi@xxx.xxx.x.xx Enter default password: raspberry Done!

Installing Raspberry Pi image to an SD Card

Here is a simple set of instructions to set up the SD card for your Raspberry Pi in Linux. Download desired OS image. ( https://www.raspberrypi.org/downloads/ ) Set your SD Card for image flashing: Unmount the sdcard. This should give full access to gparted. Open GParted Software. I you don't have GParted, you can install it through the Following instruction: $ sudo apt-get install gparted Delete All existing partitions in the SD card . Reformat all into fat32. Flash image to sd card through dd command: $ sudo dd bs=1M if=/home/enzero/Projects/2017-01-11-raspbian-jessie-lite.img of=/dev/mmcblk0 status=progress /dev/mmcblk0 - The SD card directory. In my case, I was using the card reader port so it is mmcblk0 /home/<DOWNLOAD_PATH>/2017-01-11-raspbian-jessie-lite.img - OS image location

Using a Scanner In Linux!

Here is a list of instructions I had to do to use my scanner in Linux. Hope you find it useful! Install $ sudo apt-get install sane $ sudo apt-get install xsane Plug scanner through usb. Look for the scanner connected e.g. (Bus 005 Device 035: ID 04b8:1103 Seiko Epson Corp.) by typing in the following command: $ lsusb Edit the configuration file of sane: $ sudo gedit /etc/sane.d/(scanner brand).conf There should be line with “USB”. Add the device and id number (values from lsub output) to the “USB” line. e.g. ( USB 0x0035 0x1103 ) Start the program! $ sudo xsane

Unit Testing Critical Legacy Code

I once worked on a medical project which required intense Unit Testing in C#. A problem I encountered is that all of the critical sections of the code can't be accessed or required a massive amount of object dependencies. The dilemma I was in drove me to search for a new soluion. Good thing I found TypeMock Isolator. TypeMock Isolator is a mocking framework that can take control of function calls regardless if it is accessible or not such as privately declared functions and etc. This Framework is center-focused on white box testing legacy code; although, can be used for black box testing. Why use it? Code not Written using SOLID Principles Tested code is not following TDD(Test Driven Development) Testing legacy code Unrefactorable tested code Excellent for mission critical code. Mock Instantiation Using Typemock Isolator, object instantiations can be ignored. Ignore Constructor ClassToTest obj = Isolate.Fake.Instance<ClassToTest> (Members.CallOriginal, Cons

How to Rename a Local Branch in Git?

Renaming a local branch in Git is quite simple. To rename a branch from another branch, use this: $ git branch -m <current-branch-name> <new-branch-name> On the other hand, if already in the current branch, use this: $ git branch -m <new-branch-name> -m specifies the move operation. Pretty much the same kind of operation you would use to rename file in terminal.

Adding a new driver in WinCE

Here is a short guide on how to create your very own driver in Windows CE:  In solution explorer, go to C:\WINCE800\platform\${whatever board}\SRC\DRIVERS right click driver and press "Add"->"New subproject..." Select WCE Dynamic Link library and empty project. Add the following in ${drivername}.bib: MODULES IF BSP_DRIVERSHELL IF _WINCEOSVER=600     ${drivername}.dll $(_FLATRELEASEDIR)\${drivername}.dll NK K ELSE     ${drivername}.dll $(_FLATRELEASEDIR)\${drivername}.dll NK ENDIF ENDIF Add the following in ${drivername}.reg: [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\${drivername}]     "Prefix"="XXX"     "Dll"="${drivername}.dll"     "Order"=dword:4 Add the following in ${drivername}.def: LIBRARY ${drivername} EXPORTS     XXX_Init     XXX_Deinit     XXX_Read     XXX_Open     XXX_Close     XXX_IOControl Note tha

Accessing USB device Through terminal

Identify usb device with lsblk. In this case, the usb is sda1. We first need to mount this into /media $ sudo mkdir /media/usb $ sudo mount /dev/sda1 /media/usb After that, we can now access the contents of the usb device through /media/usb You can check it by doing: $ ls /media/usb

Installing Qt Cross Compilation Toolchain for Beaglebone Black

This is the guide that I went through to successfully set the environment. If you get stuck on something, feel free to have a look at the references in the bottom most. These are the steps that worked for me so I hope it helps. Just making sure of the dependencies sudo apt-get update sudo apt-get upgrade sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 libstdc++6:i386 ia32-libs Assuming that you can get access to the root Set up Cross compiler Download and install wget -c https://releases.linaro.org/components/toolchain/binaries/6.4-2018.05/arm-linux-gnueabihf/gcc-linaro-6.4.1-2018.05-x86_64_arm-linux-gnueabihf.tar.xz tar xf gcc-linaro-6.4.1-2018.05-x86_64_arm-linux-gnueabihf.tar.xz export CC=`pwd`/gcc-linaro-6.4.1-2018.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- Test installation ${CC}gcc --version Download qt source #do this in a directory that is not in your root filesystem, i.e. ~ git clone git://code.qt.io

Setting Up Altera CPLD Development in Linux!

Here is a simple guide to setup your Linux machine to develop Altera's CPLD. Install 32 bit libraries: $ sudo dpkg --add-architecture i386 $ sudo apt-get update $ sudo apt-get install libxft2:i386 libxext6:i386 libncurses5:i386 Download Whole software from altera website. ( Version 15.1) Download IDE, ModelSim , and device here: Altera Download Link Make sure to include your desired CPLD board software in the download. Get the usb blaster working by setting up the permissions by following Intel's Instruction Page . This should get you started with everything.

Generating a PDF file from several images in Linux!

So you wanna build a PDF from pages you have scanned or images you have gathered? Here is the simplest way to do it through the amazing terminal! First, open the terminal and install the imagemagick software: $ sudo apt-get install imagemagick Next, freaking generate the PDF with this simple command! $ convert image1.jpg image2.png image3.bmp output.pdf And there you go!