Tag Archive for howto

oh-my-zsh p10k git branch name shortened

I use this and I experiened like this:

The branch name is shortened and can’t read.

So I have to change this line in `~/.p10k.zs` The line is AROUND at line 400 :

from: (( $#branch > 32 )) && branch[13,-13]="…" # <-- this line

to: (( $#branch > 40 )) && branch[20,-20]="…" # <-- this line.
It the branch name is over 40 char, It wil be cut from the 20th chat til the last 20 char.

src: https://stackoverflow.com/questions/61667666/keep-git-branch-name-untruncated-in-shell-using-p10k-oh-my-zsh-theme

Linux Desktop experiences

DRAFT

A long-long years ago (til 2007) I used linux as desktop (Gentoo exactly).

After, the windows 7 and the 10 also will be a very-very good PC OSs.

BUT I tried the Ubuntu 20.04, and it seems work wine from 1 month at my 2in1 PC with WWAN card (DELL 7390).

I would like to collect some useful programs which I found very userful, fast and maintined (actually).

Program typeLinux programWindows alternative
(what I liked to use)
Screenshot maker and editorFlameshotGreenshot
Clipboard managerCopyQDitto
LauncherULauncherLaunchy
File managerDouble CommanderTotal Commander
SSH session managerRemminaKitty
VNC session managerRemminaUltraVNC
RDP session managerRemminaRDCman (discontinued)

mdadm raid 5 all disk became spare

After an irregular restart, the raid 5 array became unreachable. D’oh!

# cat /proc/mdstat

$ cat /proc/mdstat 
Personalities : [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] 
md3 : inactive sdd3[3](S) sde3[4](S) sdf3[6](S) sdg3[5](S)
      6546850144 blocks super 1.2

As you can see all sd[cdefg]2 partitions are (S)pare.

First, we had to stop the array:

# mdadm --stop /dev/md3

and after we have to reassamle the array:

# mdadm --assemble /dev/md3 /dev/sdc3 /dev/sdd3 /dev/sde3 /dev/sdf3 /dev/sdg3 --verbose

After, we have to see like this:

$ mdadm --assemble /dev/md3 /dev/sdc3 /dev/sdd3 /dev/sde3 /dev/sdf3 /dev/sdg3 --verbose
mdadm: looking for devices for /dev/md3
mdadm: Fail create md3 when using /sys/module/md_mod/parameters/new_array
mdadm: /dev/sdc3 is identified as a member of /dev/md3, slot 0.
mdadm: /dev/sdd3 is identified as a member of /dev/md3, slot 2.
mdadm: /dev/sde3 is identified as a member of /dev/md3, slot 3.
mdadm: /dev/sdf3 is identified as a member of /dev/md3, slot -1.
mdadm: /dev/sdg3 is identified as a member of /dev/md3, slot 1.
mdadm: added /dev/sdg3 to /dev/md3 as 1
mdadm: added /dev/sdd3 to /dev/md3 as 2
mdadm: added /dev/sde3 to /dev/md3 as 3
mdadm: added /dev/sdf3 to /dev/md3 as -1
mdadm: added /dev/sdc3 to /dev/md3 as 0
mdadm: /dev/md3 has been started with 4 drives and 1 spare.

cool part of it:

mdadm: /dev/md3 has been started with 4 drives and 1 spare.

let’s check the result:

$ cat /proc/mdstat 
Personalities : [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] 
md3 : active raid5 sdc3[0] sdf3[6](S) sde3[4] sdd3[3] sdg3[5]
      4910137344 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]
      bitmap: 0/13 pages [0KB], 65536KB chunk

And it done, huh 🙂

Win 10 set default editor

1. Start the registry editor (regedit.exe) and select HKEY_CLASSES_ROOT.

2. Press Ctrl + F to open the Find dialog.

Image

3. Type systemfileassociations, enable “Keys” and deselect “Values” and “Data” check boxes.

4. Press ENTER.

You’ll now be taken to the HKEY_CLASSES_ROOT\SystemFileAssociations branch.

Expand the “SystemFileAssociations” branch by double-clicking on it
Scroll down until you see a subkey named “image”
Double-click “image”

Double-click “shell”

Double-click “edit”

Double-click “command”

src: https://answers.microsoft.com/en-us/windows/forum/windows_10-files-winpc/change-default-image-editor/4b01b777-338f-49c1-8300-9bcd7f60c160

How to modify a class file

You can follow these steps to modify your java class:

  1. Decompile the .class file as you have done and save it as .java
  2. Create a project in Eclipse with that java file, the original JAR as library, and all its dependencies
  3. Change the .java and compile
  4. Get the modified .class file and put it again inside the original JAR.

Outlook set sync folders

  1. You can open the Send/Receive Groups dialog by pressing the CTRL+ALT+S keyboard shortcut or as an alternative use:
    • Outlook 2007 and previous
      Tools-> Options…-> tab Mail Setup-> button Send/Receive…
    • Outlook 2010, Outlook 2013 and Outlook 2016
      File-> Options-> Advanced-> button Send/Receive…
  2. In the Send/Receive Groups dialog press the Edit… button.
  3. In the left section, select the account for which you want to modify the send/receive settings.
  4. In the Account Options section you can disable the option for “Receive mail items”.
  5. Press the OK button until you have closed all open dialogs.

How to get Apache Tomcat version

java -cp </usr/share/tomcat8>/lib/catalina.jar org.apache.catalina.util.ServerInfo

 

SSH-n keresztüli X Windows-on

Unix machines have been able to run software on a remote machine and display the GUI locally for almost two decades. Linux and Mac OS X support X Forwarding with no extra software. Any terminal on Linux should do X Forwarding, Mac users need to run “Applications > Utilities > XTerm“. In a command line terminal run “ssh -Y jdoe@compute.example.edu matlab” and you’ll be running matlab on “compute.example.edu” but seeing it on your desktop.

Windows users need two pieces of software: an secure shell program (ssh) to establish the remote connection and an X Server to handle the local display.

Prerequisites

Configuring Putty

    1. Add Unix hostname
    2. Switch Protocol to SSH
    3. Type name of session in saved sessions
    4. Click ‘Save’

    1. Expand the ‘SSH’ tab from the ‘Category’ list
    2. Choose ‘X11’ from ‘SSH’ list
    3. Check ‘Enable X11 Forwarding’

 

  1. Choose ‘Session’ from ‘Category’ list
  2. Click ‘Save’

Starting the X Server on Windows

Configuring Xming

Just run “All Programs > Xming Xming” and it should work if you’ve got PuTTY configured.

Connecting

    1. Start Xming
    2. Start Putty
    3. Double click on the saved session you want

  1. Enter username and password as requested
  2. You should now be able to run X applications from the host
    on your local desktop

Arduino fejlesztési környezet beállítása Eclipse C++-ban

Ezt, a kis szösszenetet magamnak fordítottam le (szabad fordításban ebből a forrásból), hogy meglegyen a wikim-ben későbbi felhasználás céljából. Sokat kutakodtam mire ráleltem, de megérte mert működik.

Tesztalanyunk egy Win7 64bit PC, + Arduino Duemilanove lap. Mással nem teszteltem!  Kéretik figyelembe venni! Ha valaki mégis mással is kipróbálná, és nem megy, de rájön miért nem, kérem, ossza meg és frissítem a cikket.

ÉS a lépések:

  1. Eclipse telepítése – letölt-> kitömörít -> örül 🙂 Ez most egy Eclipse Juno lett nálam.
  2. Eclipse AVR Plugin telepítése
    1. Eclipse-ben, menüsor: Help -> Install New Software
      update site: http://avr-eclipse.sourceforge.net/updatesite 

      1.  A plugin hely neve legyen mondjuk: Eclipse AVR Plugin
      2. Elfogadjuk a license-ket és, hogy digitálisan nem aláírt cuccot telepítünk.
      3. majd, telepítés, eclipse restart (File –Restart).
  3. Arduino SDK letöltése
    1. URL: http://arduino.cc/en/Main/Software (jelenleg (2013.08.25): v1.0.5 a legfrissebb
    2. Kitömörítjük: nálam pl: M:\arduino\  <- Az elérési utat jegyezzük meg, később kelleni fog!
  4. Eclipse AVR Plugin beállítása
    1. Eclipse-ben, menüsor: Window -> Preferences -> AVR szekció oldalon, Paths
      1. Válasszuk az AVR-GCC sort, kattintsunk az Edit-reA megnyíló ablakon belül Path source:-t állítsuk Custom-ra a lenyílóban, majd Browse. Az elérési út (Custom value): <arduino_base_path>\hardware\tools\avr\bin ami az AVR fordítóhoz az elérés (avr-gcc.exe) az arduino SDK mappában. Nálam ez így néz ki:
        M:\arduino\hardware\tools\avr\bin
      2. Válasszuk a GNU Make, sort, kattintsunk az Edit-reA megnyíló ablakon belül Path source:-t állítsuk Custom-ra a lenyílóban, majd Browse. Az elérési út (Custom value): <arduino_base_path>\hardware\tools\avr\utils\bin ami a make elérése az arduino SDK mappában. Nálam ez:
        M:\arduino\hardware\tools\avr\utils\bin
      3. Válasszuk az AVR Header Files, sort, kattintsunk az Edit-re. A megnyíló ablakon belül Path source:-t állítsuk Custom-ra a lenyílóban, majd Browse. Az elérési út (Custom value): <arduino_base_path>\hardware\tools\avr\avr\include ami az elérési út az AVR toolchain headers fájlok az arduino SDK könyvtárban. Nálam ez így néz ki:
        M:\arduino\hardware\tools\avr\avr\include
      4. Válasszuk az AVRDude, sort, kattintsunk az Edit-reA megnyíló ablakon belül Path source:-t állítsuk Custom-ra a lenyílóban, majd Browse. Az elérési út (Custom value): <arduino_base_path>\hardware\tools\avr\bin ami az elérés az  AVRDude binárisokhoz (ezeket használjuk az Arduino lapon való futtatáshoz) az arduino SDK könyvtárban. Nálam ez:
        M:\arduino\hardware\tools\avr\bin
      5. Kattinsunk az Apply, majd az OK gombra.
  5. ArduinoCore könyvtár (projekt) létrehozása

The ArduinoCore library will contain all the basic functionalities to deal with the Arduino board, this library can be seen as the standard c library equivalent for Arduino. If you write some code for Arduino in the Arduino IDE, this library is silently linked to your code, but if you plan to use Eclipse you have to manually link the library to each of our projects before deploying them on the Arduino board.
Here are the steps to create the ArduinoCore library (which is just the name I gave it):

    1. Az eclipse-ben New -> C++ Project majd AVR Cross Target Static Library majd válasszuk az Empty Project-et.
      1. Állítsuk a Project Name: mezőt ArduinoCore-ra majd kattintsunk a Next gombra.
      2. Debug mellől a pipát vegyük ki majd Next.
      3. Állítsuk az MCU Type és az MCU Frequency értékét. Ez lap specifikus az én Arduino Duemilanove lapom ATmega328P chip-pel szerelt, ami 16MHz (16000000 Hz). Ha nem vagy biztos az értékben menj az arduino weboldal Hardware szekciójában. Válasszuk ki a hardware-ünket, és nézzük meg a technikai specifikációját (tech specs). URL: http://arduino.cc/en/Main/Boards
      4. Kattintsunk Finish gombra.
      5. Most van egy üres könyvtár projektünk, amibe most bele fogjuk importálni az Arduino core fájlokat az Arduino SDK mappából.
    2. Eclipse-ben jobb klikk az ArduinoCore projektre, majd Properties -> C/C++ Build -> Settings majd listában
    3. az AVR Compiler listaelemben válasszuk a Directories-t.
      1. Adjuk hozzá az arduno core fájlokat tartalmazó útvonalat. Ez az arduino SDK belül található a következő helyen: <arduino_base_path>\hardware\arduino\cores\arduino. Nálam:
        M:\arduino\hardware\arduino\cores\arduino\
      2. Majd adjuk hozzá a pins_arduino.h header fájl elérhetőségét is. Ez megint lap specifikus (ne aggódj, alább jön egy kis magyarázat is). Az alábbi elérhetőségen található egy pár pins_arduino.h header fájl, de mind specifikus mappán belül.  A gyökér mappa helye <arduino_base_path>\hardware\arduino\variants\ Specifikus mappák a következőek
        1. <arduino_base_path>\hardware\arduino\variants\standard: Én ezt használom a Arduino Duemilanove lapomhoz.
        2. <arduino_base_path>\hardware\arduino\variants\mega: Úgy gondolom, hogy az Arduino Mega lapokhoz tudod használni
        3. <arduino_base_path>\hardware\arduino\variants\leonardo: Talán az Arduino Leonardo lapokhoz használható
        4. <arduino_base_path>\hardware\arduino\variants\micro: passz :/
      3. A B) lépést ismételjük meg az AVR C++ Compiler listaelem esetében is majd klikk az OK-ra.
      1. Jobb klikk az ArduinoCore projekten -> Import -> General -> File System. A felugró ablakban keressük meg core fájlokat az arduino SDK mappán belül. Helyük: <arduino_base_path>\hardware\arduino\cores\arduino
        1. Válasszuk ki minden fájlt kivéve a main.cpp-t!!!.
        2. Advanced gombra katt, majd válasszuk a Create links in workspace opciót. Ekkor a fájlok ténylegesen nem lesznek másolta a workspace-be, csak hivatkozás készül rájuk. Előnye, ha frissítjük az arduino SDK-t, akkor a hivatkozott könyvtárak is frissülnek automatikusan.
        3. Katt a Finish-re.

Ha minden rendben ment, akkor le tudjuk fordítani az ArduinoCore könyvtárat (projektet). Próbáljuk is meg: jobb klikk az ArduinoCore projekten -> Build Project

  1. Próba projekt létrehozása

Let’s now create a test project to check that everything’s fine.
Remember that these steps must be done with every new project that you create.

  1. A.  Eclipse-be New -> C++ Project majd AVR Cross Target Application és válasszuk az Empty Project-et.
    1. Project Name: legyen TestProject. Katt Next
    2. Debug pipáját vegyük ki! majd katt Next
    3. Állítsuk az MCU Type és az MCU Frequency értékeket ugyanarra, mint az ArduinoCore esetében tettük, majd Finish
    4. Jobb klikk a TestProject-re majd állítsuk be ugyanazokat a könyvtár eléréseket, mint az 5B és az 5C pontban tettük.

Right click on the “ArduinoCore” project, go to “Properties” and then “C/C++ Build” and in both “AVR Compiler” and “AVR C++ Compiler” add the same include paths that were added in the ArduinoCore library project plus the include path for the test project itself which is not added by default and can be added with this magic string: “${workspace_loc:/NULL}” which simply expands to your workspace directory followed by the test project directory.

  1. Ugyanúgy a listában található egy AVR C++ Linker az AVR Compiler, az AVR C++ Compiler alatt. A parancssor-t ez alábbi értékre állítsuk
    NULL --cref -s -Os NULLNULLNULL NULL -lm NULL

     

  2. Most kattintsunk a Libraries alelemre.
    1. In the “Libraries path” box add the path to the ArduinoCore library by clicking on the “Add” button on the top right corner of the box, then select “Workspace” and point it to the “Release” folder inside the ArduinoCore project. You can also directly insert this magic string:“${workspace_loc:/ArduinoCore/Release}” which is the same thing.

In the “Libraries” box add the ArduinoCore library by clicking on the “Add” button on the top right corner of the box and simply type “ArduinoCore”, this instructs the linker to link against “libArduinoCore.a” when linking the final executable.

In the project properties window, click on “Project references” in the left menu and check“ArduinoCore”, so the library will be automatically built (and re-built if needed) when building the test project.

In the test project create a new main.cpp file and paste the following code into it.
This is the classic Blink code sample that blinks the led linked on pin 13 of the Arduino board once every second:

#include <Arduino.h>

 

int ledPin =  13;    // LED connected to digital pin 13

 

// The setup() method runs once, when the sketch starts

void setup()   {

// initialize the digital pin as an output:

pinMode(ledPin, OUTPUT);

}

 

// the loop() method runs over and over again,

// as long as the Arduino has power

 

void loop()

{

digitalWrite(ledPin, HIGH);   // set the LED on

delay(1000);                  // wait for a second

digitalWrite(ledPin, LOW);    // set the LED off

delay(1000);                  // wait for a second

}

 

int main(void) {

 

init();

setup();

 

while(true) {

loop();

}

}

You’ll notice that there are some difference between this code and the usual code that you write for Arduino, the next post will focus on these differences, for now just take it as it comes. No questions. Or this post will never end.

Deploy on the Arduino board

After compiling and linking the binary a tool named AVRDude will deploy it on the Arduino board.
AVRDude must be configured to work with Arduino.
What we are going to do now is stealing the AVRDude configuration from the Arduino SDK.

From Eclipse go to “Window” then “Preferences” and select the “AVR” section on the left, then select “AVRDude”.
Check “Use custom configuration file for AVRDude” and set “AVRDude config file” to the one provided with the Arduino SDK: it can be found under<arduino_base_path>\hardware\tools\avr\etc\avrdude.conf.
Click “Apply” and then “OK”.

From Eclipse select the test project and open the project properties once more (right click->“Properties”).
Select the “AVR” section and the click on “AVRDude”
You now have to create a new programmer configuration for your board, this must be done only once.
Click “New”, in the window that appears insert these data:

  • “Configuration Name” : “Arduino”
  • “Programmer Hardware” : “Arduino”
  • “Override default baudrate” : 57600

And set “Override default port” to the COM port that you use to work with the Arduino board. If you do not know what this value is, plug your Arduino board in and start the Default IDE, the COM port is showed at the bottom of the IDE window, my Arduino IDE says:

Arduino Duemilanove w/ ATMega328 on COM10

My COM port is COM10 so my “Override default port” field is set to:

//./COM10

Don’t ask me what the “//./” prefix means, I don’t know.
Click “OK”

Back in the “AVRDude” window select the “Advanced” tab.
Check “Disable Device signature check” and click “OK”.

First deploy

It’s time. Plug your Arduino board in.

Select the test project and build it, then right click on it and select “AVR” and then “Upload project to target device”, the deploy will start and if everything’s fine you should have your program running on the Arduino board after a few seconds. Look at the led at PIN 13 and it should be blinking. Mine blinks.
That’s all, hope this guide is useful.
Again, let me know any problem you had so I can update the tutorial with your info.

Hava fun! 🙂

Kis alap main_cpp.

 

Jenkins install from binary on Gentooo

Edit /etc/layman/layman.cfg and add new overlay list :

overlays  : http://www.gentoo.org/proj/en/overlays/layman-global.txt
            http://godin-gentoo-repository.googlecode.com/svn/trunk/layman.xml

Or in one line:

layman -f -o http://godin-gentoo-repository.googlecode.com/svn/trunk/layman.xml -a godin

Add to sync list :

layman -S
layman -L
layman -a godin

Add to make.conf :

echo "dev-util/jenkins-bin" >> /etc/portage/package.keywords

emerge the ebuild:

emerge -av dev-util/jenkins-bin