Difference between revisions of "Mika/Notes/Computer Stuff"

From WikiDotMako
Jump to navigation Jump to search
Line 104: Line 104:
 
* [http://wiki.mako.cc/Mika/Notes/Computer_Stuff/Debian_Installation Debian Installation]  
 
* [http://wiki.mako.cc/Mika/Notes/Computer_Stuff/Debian_Installation Debian Installation]  
 
* [http://wiki.mako.cc/Mika/Notes/Computer_Stuff/Debian_Maintenance Debian Maintenance]
 
* [http://wiki.mako.cc/Mika/Notes/Computer_Stuff/Debian_Maintenance Debian Maintenance]
 +
* 2019-07-08: Thunderbird stopped syncing mail; IMAP server not supporting the authentication method; had to fix dovecot; used this bug report https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=924580 and https://b4d.sablun.org/blog/2019-02-25-dovecot_2.3_upgrade_on_debian/ as main guidance.
 
* bluetooth not connecting; installed blueman, pulseaudio-module-bluetooth, rfkill unblock bluetooth, killall pulseaudio (one or more of those) fixed it; https://wiki.debian.org/BluetoothUser/a2dp
 
* bluetooth not connecting; installed blueman, pulseaudio-module-bluetooth, rfkill unblock bluetooth, killall pulseaudio (one or more of those) fixed it; https://wiki.debian.org/BluetoothUser/a2dp
 
* sid = unstable but pretty stable.  
 
* sid = unstable but pretty stable.  

Revision as of 17:08, 3 August 2019

Miscellaneous

Writing down things I've learned. Some miscellaneous stuff are:

  • AJAX example: Checks if the username you entered is taken.
  • Javascript example: Drag choices up and down.
  • The tool to take a screen-videoshot (screencast) is to install recordmydesktop.
  • i686 (or i386) are 32 bit. Intel 64 bit processor is usually marked by _64 (really?)
  • Add a keyword (i.e. g) to a bookmark (i.e. http://www.google.com/search?q=%s) to make a shortcut in the address bar in Firfox.
  • R tutorial
  • Vector graphics vs Raster graphics
  • To rid the high pitch noise on my X61s, add options processor max_cstate=2 to your /etc/modprobe.d/options file.
  • In order to have certain things started every time I start my laptop, I can add things to the .Xsession file and start the session with Xsession when I log in. I've added things like gnome-power-management and awesome (awesome should be at the end).
  • I installed chromium by following this instruction.
  • Change network manager keyring by Applications > Accessories > Passwords and Encryption Keys.
  • Firefox forgets history after 7 days even though it's set to remember for up to 90 days. I went about:config and changed browser.history_expire_days to 90 days.
  • Converting 3gp to avi: I had to do sudo apt-get install ffmpeg libavcodec-extra-52 to get extra libraries. Then, a variation of ffmpeg -i input.3gp -f avi -vcodec xvid -acodec mp3 -ar 22050 output.avi because it gave errors for xvid (change to libxvid) and mp3 (change to libmp3lame). Still not working but it at least makes the output file.
  • Things to check out: gcommons, bak, acabed
  • In order to hide oversized background on a website, use in CSS: overflow:hidden;
  • sh files --> sh file.sh
  • imap folder can be merged by tagging all msgs in one folder and ;s (save) in the folder of my choice.
  • tgz files: gzip -d filename
  • baobao: graphical tool for space analysis
  • ibus-daemon wasn't working. I couldn't start it by ctrl-space: 1) ps ax |grep ibus (this showed "defunct for ibus) 2) ps ax |grep X 3) restart X by killing

the process (That didn't fix it. See the next point.)

  • upon Ubuntu Upgrade, the Japanese input stopped working ("no input window" in ibus). I uninstalled scim and it's all fixed now.
  • smbclient -L (server name) to see the list of services on the server.
  • Start mutt. c and imap://(server name) to get emails on the local machine.
  • Thumbnail images for RAW files stopped working. Installed gnome-raw-thumbnailer (probably) again. Also created a file raw.thumbnail saying:
[Thumbnailer Entry]

Exec=/usr/bin/gnome-raw-thumbnailer -s %s %u %o MimeType=image/x-3fr;image/x-adobe-dng;image/x-arw;image/x-bay;image/x-canon-cr2;image/x-canon-crw;image/x-cap;image/x-cr2;image/x-crw;image/x-dcr;image/x-dcraw;image/x-dcs;image/x-dng;image/x-drf;image/x-eip;image/x-erf;image/x-fff;image/x-fuji-raf;image/x-iiq;image/x-k25;image/x-kdc;image/x-mef;image/x-minolta-mrw;image/x-mos;image/x-mrw;image/x-nef;image/x-nikon-nef;image/x-nrw;image/x-olympus-orf;image/x-orf;image/x-panasonic-raw;image/x-pef;image/x-pentax-pef;image/x-ptx;image/x-pxn;image/x-r3d;image/x-raf;image/x-raw;image/x-rw2;image/x-rwl;image/x-rwz;image/x-sigma-x3f;image/x-sony-arw;image/x-sony-sr2;image/x-sony-srf;image/x-sr2;image/x-srf;image/x-x3f;

  • Iceweasel/Firefox keyword shortcuts: Right click on a search box (i.e. Duckduckgo search box) and select "Add keyword shortcut" and add a keyword.
  • Piwik is like visitors. Used Piwik Analytics, a wordpress plugin. Make sure to insert / for the path to piwik.php etc and enter correct site ID obtained from the analytics code. I inserted the code from the Piwik server on other pages in index.html. Make sure that the text doesn't wrap in the middle of the code. In vim, :set textwidth=1000 etc.
  • Accidentally changed the WP siteurl on the admin page to a wrong url and couldn't log back in to fix it. I edited the theme's functions.php and added

update_option('siteurl','http://example.com/blog'); update_option('home','http://example.com/blog');

After logging back into the website, I deleted these lines -- it's important to delete them!
  • Pitivi: I can't separate the audio from the video. dpic suggests:

<dpic> hm. it doesn't happen to me but i highly recommend compiling the

            development version http://www.pitivi.org/?go=download

apt-get build-dep pitivi git clone git://git.gnome.org/pitivi cd pitivi

./autogen.sh && ./configure && make
bin/pitivi 
should work much better
  • A pdf file cannot be opened unless using Adobe. Downloaded their pdf reader from the website, chmod +x that file, ./the bin, and it's all set.
  • For each new computer, I should setup an ssh key and add .pub to my remote servers? keygen, id_rsa etc. See my link on ssh on links.
  • Was trying to upgrade my libreoffice but it seemed to have had problems with previous versions of libreoffice on my computer. apt-get remove libreoffice* did NOT do the trick. I had to locate libreoffice |less to identify what other libreoffice3.5 (previous version) were lurking around (i.e. .config/libreoffice in the home directory and other .libreoffice3.5 config files or /opt/libreoffice etc etc). Before removing these guys, dpkg -i on deb files in the downloaded libreoffice 3.6 files just led to libreoffice 3, which had no menus, pretty broken.
  • My server was very slow -- apache2 has spawned too many children: I ssh'ed (slowly) to my server and did sudo killall -9 apache2 . I can change in apache2.conf how many children to have. afterwards, instead of restarting apache2, I can just do sudo invoke-rc.d apache2 reload .
  • index html works locally but not on the server: permission issue. chmod.
  • logitech bluetooth/wireless mice work great with debian. Using M185. Less colorful than M325 but cheaper and as useful since I don't care about syncing with keyboard.
  • to save an attachment in mutt, type v on the email with the attachment -> select the attachment and hit s to save locally.
  • irc op: ask chanserv the list for each channel (/msg ChanServ access #(channel name) list)
  • irc op: /msg ChanServ op #(channel name) (nick) to add an operator
  • 2017-09-16 ThinkPad TrackPoint mouse started to move on its own (this always happens with Thinkpad after a few months of use). I want to disable the Trackpoint mouse. Solution here: https://cederlys.wordpress.com/2010/07/13/disabling-the-track-stick-in-ubuntu/

Step 1: Figure out the prop # for the trackpoint mouse xinput -list

Step 2: See how the particular prop is set up xinput -list-prop (the prop # you just looked up)

Step 3: Disable the mout xinput -set-prop "(Device name shown in Step 1 and 2)" "Device Enabled (or something like that as shown in Step 2)" 0

Zsh

  • after entering the first config info, I got this message:

The function will not be run in future, but you can run it yourself as follows:

 autoload -Uz zsh-newuser-install
 zsh-newuser-install -f

The code added to ~/.zshrc is marked by the lines

Lines configured by zsh-newuser-install
End of lines configured by zsh-newuser-install

You should not edit anything between these lines if you intend to run zsh-newuser-install again. You may, however, edit any other part of the file.

  • I added alias ls='ls --color=auto' in the .zshrc file to make directories look colorful.

Android

  • Install a new OS on the phone: 1) Check the latest [ROM] thread for the specific phone type (i.e. Mytouch 4G Slide Android Development) in XDA forum. 2) Follow the instruction (i.e. 1. Download and place the correct zip file for the new OS on the SD card 2. Unlock/root your device and install Clockwork Recovery via ROM Manager. Flash Recovery and then Reboot into Recovery. 2. Do a backup in the Recovery mode 3. WIPE in the Recovery mode

4. Install the ROM from the new zip file on the SD card 5. Optionally install the Google Apps (gapps from places like goo.im/gapps). There are great youtube videos for each step.

Debian

  • Debian Installation
  • Debian Maintenance
  • 2019-07-08: Thunderbird stopped syncing mail; IMAP server not supporting the authentication method; had to fix dovecot; used this bug report https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=924580 and https://b4d.sablun.org/blog/2019-02-25-dovecot_2.3_upgrade_on_debian/ as main guidance.
  • bluetooth not connecting; installed blueman, pulseaudio-module-bluetooth, rfkill unblock bluetooth, killall pulseaudio (one or more of those) fixed it; https://wiki.debian.org/BluetoothUser/a2dp
  • sid = unstable but pretty stable.
  • Look at packages.qa.debian for todo's and qa.debian under my name for all the bugs and other information.
  • Popcon means popularity contest but there are people who install a package but don't use popcon.
  • dpkg -l (package name): gives the version of the package.
  • dpkg --audit: get a list of broken packages.
  • dpkg --configure (package name):amd64 if I get apt-get install errors saying ambiguous packages and if audit is showing multiple architectures and if I don't have muliarch-support for some reason. Make sure to not put space after : before amd64.
  • To get the system up to date:
    • apt-get update (Used to re-synchronize the package index files from their sources. And then;)
    • apt-get upgrade
  • To upgrade to Squeeze (except I wanted testing = Wheezy):
    • change previous (lenny) to (latest) squeeze in /etc/apt/source.list
    • apt-get update
    • apt-get install apt dpkg apt
    • apt-get dist-upgrade: error message telling me /var/cache/apt/archives doesn't have enough space. Ran aptitude clean and it was cleaned up.
    • I changed to Wheezy because I wanted Gnome3.2. I changed on the /etc/apt/source.list.
    • I changed to jessie in /etc/apt/apt.conf
  • pitivi wasn't as good as dpic's. He said to do:
    • apt-get build-dep pitivi: Normally, specific headers and shared libraries need to be present in order for a source package to be compiled. All source packages have a field in their control files called 'Build-Depends:' that indicates which additional packages are needed for the package to be built from source. APT has a simple way of downloading these packages. Just run apt-get build-dep package, where `package' is the name of the package you're going to build.
    • git clone git://git.gnome.org/pitivi
    • cd pitivi
    • ./autogen.sh && ./configure && make (make is an essential program for installing much unpackaged source code software. The developers can write down all of the complex information about how to configure, compile, and install their work in make files that you usually won't have to read. Just check README or INSTALL files that come with the source code to see whether it uses this system, or has different instructions. Another program with similar functions is jhbuild.
    • bin/pitivi
    • after upgrading, the sound stopped working. No volume button on Gnome toolbar and no output/input devices in the settings. I did the following and rebooted, which restored the sound:
sudo apt-get remove --purge alsa-base
sudo apt-get remove --purge pulseaudio
sudo apt-get install alsa-base
sudo apt-get install pulseaudio
sudo alsa force-reload
    • after upgrading, calendar/iceowl in icedove didn't work. I had to reinstall iceowl-extension, which removed enigmail. I reinstalled enigmail after installing iceowl.
    • when a computer shuts down unexpectedly, check /var/log/kern.log and see what happened right before the reboot.
    • apt-get install -f <package name>:unstable to install unstable. <package name>=<version number> to install specific version number.
    • the time was a few minutes earlier. Fix: /etc/init.d/ntp restart.

Latex

  • For debian, apt-get texlive.

Inkscape

  • I wanted to use a landscape canvas: Go to File -> Document Property - Choose Landscape.
  • I wanted to use text: Press F8.

Bug Report

  • I have trouble using Inkscape because it crashes when I try to use text. Here's how to get a backtrace:

gdb <path to inkscape executable>

(gdb) run [parameters (optional)]
# Carry out the actions to make the program crash
(gdb) bt

R

  • expression and assignment
  • I had to manually install latest deb files for both rstudio and R. Afterwards, I had to reinstall all packages and some of the packages that these packages are dependent on (i.e. For Hmisc, I had to reinstall survival, lattice, and cluster first.)

PHP

Problem:

Again, I was doing this tutorial. I got the update/delete working but not insert. Even when I typed in the values, it returned Missing Values.

Solution

I said name="id" in select3.php in the form part for insert3.php but I said _POST[ID] in insert3.php. I changed it to id and it works fine now.


Problem:

I was doing this tutorial. First of all, I didn't quite write down the codes right:

  • incorrect update/delete versions linked from select.php
  • <?= is good <? = is not good
  • _GET['X'] is good but _GET["X"] is not good.
  • Don't free memory in the php that is required_once

After fixing all these, I got:

"failed query" SQL:SELECT Name WHERE ID =

Solution

Since I got the same message for both update and delete, I figured that the problem was elsewhere. I looked at select3 and after update3.php? I said id= instead ID= . I capitalized the id for bother update3 and delete3 and it works fine now.

GPS/Garmin/QGIS

Problem

  • I tried to download the waypoint data but Garmin device was not automatically connected. I did dmesg and /sbin/fdisk -l to see where it was.

Solution

 # apt-cache search gpsbabel
 # sudo apt-get install gpsbabel
 # gpsbabel
 # sudo apt-get install garmin-forerunner-tools 
 # dmesg
 # lsmod |grep garmin_gps
 # ls -l /dev/bus/usb/004/015
 # lsusb
 # ls -l /dev/bus/usb/004/016
 # gpsbabel 
 # sudo gpsbabel -i garmin -f /dev/ttyUSB5 -o gpx -F waypoint.gpx

Problm

  • I wanted to export a layer to a csv file, so that I can add new information (store categories) to the attribute table. And then back to GPX to open in QGIS
  • When I "Save As" in QGIS to save as a csv file, it lost lat/lon data. Subsequently, I couldn't open the edited csv file in QGIS as waypoints.

Solution

MySQL

To be sorted:

Cheat Sheet

  • command line to restart mysql: /etc/init.d/mysql start
  • check ps fax for mysqld to see if the mysql server is running.
  • mysql_connect()
  • mysql_select_db()
  • mysql_query()
  • mysql_num_rows()
  • mysql_free_result()
  • mysql_close()
  • This is for outputting mysql queries into a text file: mysql > select * from table INTO OUTFILE '/tmp/test.txt';

Problem:

I tried to write a php and connect to mysql in it but I got an error:

Fatal Error: undefined function mysql_connect()

Solution:

This page suggested that mysql isn't enabled by dafault in php5. I installed php5-mysql and restarted apache2 (don't know if that was necessary) and now it works.


Problem:

I restarted my computer because I couldn't start gimp unless I was root. Clint told me that I should sudo /etc/init.d/dbus restart , which basically restarted my whole computer. Since then, I couldn't use mysql because I kept getting this error:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Solution:

I followed this and restarted mysql by:

/etc/init.d/mysql restart

But it fails. It seems like I touched my.cnf and didn't restart mysql, so when my computer restarted, it incorporated the changes I made in my.cnf and mysql stopped working. I reinstalled mysql-server through apt-get, restarted mysql and now it's fine.



Problem:

I have a bunch of text files from USDA, which contain bits and pieces USDA ASCII databases. I want to put them into mysql.

Solution:

1. I found schema.sql that Erik created, so I'm going to borrow it rather than creating my own.

mysql databasename < schema.sql -p


Problem:

mysql> create database newdatabase;

ERROR 1044 (42000): Access denied for user 'user'@'localhost'...

Solution:

mysql

1. Check grants for 'user'@'localhost' in mysql:

mysql> show grants for 'user'@'localhost';

2. Log into mysql as root (has all privileges) and change grants for a specific user:

mysql> grant all privileges on *.* to 'user'@'localhost';

Query OK, 0 rows affected (0.00 sec)

3. Log back into mysql as user (now has all privileges) and try creating a new database again.


Python

To be sorted

  • TypeError: fetchone() takes exactly 1 argument (2 given)
    • This really means 1 argument given because each method comes with an argument to begin with.
  • To obtain input, I can use raw_input().
  • bpython
  • time
    • from datetime import date, timedelta (to do day calculations)
    • d=date.today()-timedelta(days=7)
    • In order to compare dates in string and dates in datetime in iso formats; n > d.isoformat():

Problem:

I wanted to create a wiki table from CIA's Infant Mortality Rate ranking data. I didn't want to change to the wiki table format, so I decided to write a python code.

Solutions:

I had to read a text file, make a list for each line, take out the words I need, and print in the wiki table format. I did the following first to change tabs to commas but that was probably not necessary:

    sed 's/\\t/,/g' Desktop/rawIMRdata.text > rawIMRdata2.text


When I forgot /g, it only outputted the last line.

Here's the python code:

    imr_data = open("rawIMRdata6.text")
    #f = file("imr_data","r")
    print {| class="wikitable" border="1" \n|- \n!  Ranking 1 \n!  Country 2 \n!  IMR \n
    for line in imr_data.readlines():
        # To make a list for each line from text file:
        a = line.split(',')
        #print a and strip the space after each word
        one = a[0].strip()
        two = a[1].strip()
        three = a[3].strip()	
        combined = '|-\n|' + one + '\n|' + two + '\n|' + three   
        print combined
    print r|}

Django


  • Tried setting up Django on my computer by following this tutorial

Problem:

It worked mostly ok but I couldn't go further than the second to the last coding box on page 4. I kept getting long error messages.

Solution:

Django tutorial about django.contrib.admin

1. Check if I typed in the correct codes.

2. Check if the output are the same everwhere:

Although the codes were correct, they didn't create all the necessary things, so it couldn't find the index.html.

  • I went to setting.py to specify:
    • the absolute path for Template_Dir. Don't forget the , after '/path/' .
    • two additional Installed_Apps: myprj_myapp (where I save my project) and django.contrib.admin . Run python manage.py syncdb afterwards.

This created myapp_post and django_admin_log in mysql database.


Javascript


JS Tutorial


HTML/CSS

Problem I couldn't put the content and the sidebar side by side.

Solution CSS: added floar:left to content.

Problem: I didn't know how to align text on both sides in html or css.

Solution: HTML: p style="text-align:justify CSS: p.special {text-align:justify;}

---

Problem:

I didn't know what meant.

Solution:

This website says: An HTML table has two kinds of cells:

   * Header cells - contains header information (created with the th element)
   * Standard cells - contains data (created with the td element)

Problem:

I didn't know what <form name="form1"> meant.

Solution:

"A form is an area that can contain form elements.

Form elements are elements that allow the user to enter information (like text fields, textarea fields, drop-down menus, radio buttons, checkboxes, etc.) in a form." とほほのjavascript

GPG/PGP

1. Make a gpg key. 2. Register on pool.sks-keyservers.net.

  • To open a pgp signed email in mutt, first imap-fetch to my email inbox. If the encrypted message doesn't ask my passphrase, download the attachment (hit v, download no description. file (the file name) should say PGP message), and run: gpg --output (outputfile.txt) --decrypt (downloaded file name). Enter passphrase.

3. Sign other people's keys:

gpg --recv (key) emacs .gnupg/gpg.conf (changed from x-pool.sks-keyservers.net to pool.sks-keyservers.net) gpg --recv (key) gpg --edit-key (key) (check fingerprint, check photoid if available, sign) gpg --send (key) gpg --list-sigs (key)

GNOME

  • Switch windows when a mouse moves over without a click: System -> Preference -> Windows

Wiki tricks

  • insert : to make a single indentation. Insert more for multiple indentation.
  • insert < blockquote> makes a paragraph blockquote -- couldn't find ways to insert breaks between lines within a blockquote.
  • insert < code>

Printing

  • localhost:631 in web browser to do admin/maintenance. Resume printer to resume.
  • invoke-rc.d cups restart to restart cups.
  • cat /etc/group to see which groups exist. adduser (user name) (group) to add a user.

Virtualbox

  • add to source.list deb http://download.virtualbox.org/virtualbox/debian jessie contrib
  • dynamically allocate disk space with max ~25GB
  • after installing and opening Windows, open file explore -> This PC -> Guest addition -> run the VM guest addition. This allows for auto-scaling of the window and integrated mouse (and maybe a few other good things?)
  • (the following may be out-dated):
  • apt-get virtualbox virtualbox-dkms virtualbox-qt virtualbox-guest-additions-iso
  • if running windows/office in virtual box:
download windows (version written with a product ID on the back of the computer) on a usb-stick
download office (via school)
run virtualbox
New
Add windows iso image to Controller:IDE as CD/DVD
Add Shared Folders to share folders between virtualbox and outside
  • to expand virtual hard disk space, I do:
1. VBoxManage modifyhd /path/to/vdi-file --resize x . x is the new size.
2. Start VM and go to Disk Management under Control Panel (in Windows 7: different instructions for different Windows versions).
3. Right click on C: and select expand volume.
This is virtual hard disk space, so I don't need to actually change the physical hard disk allocation in my Debian!
  • when using RDC on a bigger screen, click on options and Display tab to make sure Full Screen is chosen.
  • when VB gives me a kernl driver error, had to remove and reinstall virtualbox-dkms. Then, after starting Windows, had to right click on the CD image on the bottom right and rerun the Guest Addition.

Server stuff

  • Every time servers are assigned new IPs (i.e. move) , be sure to update IPs for both yukidoke and mika on mako's DNR.

Command line

  • arch: get architecture info
  • uname -a: print system info
  • xev: finds information on the pressed keys
  • xmodmap -e "keycode ###=Multi_key": Enter the key number in ### to set the compose key.
  • import -windows root screenshot.png: Takes a screenshot of the entire screen instead of a window.
  • sudo acpi -V: tells me the temperature of my computer.
  • cat /etc/issue: gives the current version of Ubuntu.
  • cat /etc/debian_version: give the current version of Debian.
  • apt-cache policy (package name) to get the policy info.
  • rsync -rP: synches data with the options recursive and partial.
  • ssh-keygen -p: lets me change the ssh password.
  • df -h: sizes for disk space. Useful for checking where things are mounted too.
  • du -h: sizes for all folders.
  • du -sk /* | sort -n: sort everything by size in /.
  • curl (url): prints out the content of the link.
  • bash (wordpress upgrade scrip) instead of sh because /bin/sh is no longer bash.
  • alias ls='ls --color=auto' to color directories. Needed it when switched to zsh.
  • zcat access.log.*.gz | visitors -
  • sudo fdisk -l: gives types of removable disk (ie fat16 fat32, in which case for mount, -t vfat)
  • mount -t vfat /dev/sd?? /mount/usb
  • tar xvzf file.tar.gz
  • mount: this gives the all the mounted items along with file system info etc.
  • lspci or lsub to find out wireless card types. Mine only does ad-hoc wifi.
  • ldd /usr/bin/bubblefishymon (or other executable files): show which shared libraries are linked to this file. Useful for troubleshooting. See atmarkit in Bookmarks.
  • ps -p $$ or echo $SHELL to find out which shell I'm using.
  • rename 's/x/y/' *file* changes files names by substituting x with y. If I do 's/x/y/g', g stands for global and if there are multiple x within one filename, it will replace all x's within that particular filename. Just like gsub in R.
  • history 1 to show all history (max set in ~/.zshrc as HISTSIZE).
  • ./duplicity-cloud to back up files. update duplicity_exclude if necessary.
  • send stuff between two computers using netcat: nc -l -p (port number) on one end and cat (whatever file)|pv|nc (whatever ip (get from ifconfig) (same port number) on the other computer