<commit_before>================================
TITLE: INSTALL RASPBERRY PI 3
================================

Notes:
- to reinstall: press shift when booting
- to repair
  . press shift when booting
  . add to config   init=/bin/sh
  . mount -o remount,rw /

Install from NOOBS flash card

Configure using raspi-config
- disable X windows, use console login screen
- Note - X windows can be broght up later using 'startx'

Add user account 
- create .bashrc, .bash_profile, .vimrc, .ssh
- add sudo access

Updates, and additional packages, run as root:
  apt-get update
  apt-get install libudev-dev
  apt-get install libevdev-dev
  apt-get install tk
  apt-get install vim

Install SDL2
- script is here, or see copy below
    https://gist.github.com/blacktm/8268a468f933eba46f80
- description of problem getting keybd events
    https://forums.libsdl.org/viewtopic.php?t=10483&sid=38991cf938c103990a18f389312e0f42

To Run SDL2 Program 
- export LD_LIBRARY_PATH=/usr/local/lib
     The following note is from the SDL build output:
          If you ever happen to want to link against installed libraries
          in a given directory, LIBDIR, you must either use libtool, and
          specify the full pathname of the library, or use the `-LLIBDIR'
          flag during linking and do at least one of the following:
             - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
               during execution
             - add LIBDIR to the `LD_RUN_PATH' environment variable
               during linking
             - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
             - have your system administrator add LIBDIR to `/etc/ld.so.conf'
      See any operating system documentation about shared libraries for
      more information, such as the ld(1) and ld.so(8) manual pages.
- run as root

Apply USB Patch
- add the folloing to /boot/cmdline.txt, and reboot
      dwc_otg.fiq_fsm_enable=0
- see https://github.com/raspberrypi/linux/issues/618 for information
- this seems to fix a webcam failure that occurs when closing and reopening the /dev/video0

Enable core dumps for suid processes
- add te following to /etc/sysctl.conf, and reboot
      fs.suid_dumpable=1

=================================
TITLE: GRAPHICS ACCELERATOR
=================================
 
Not needed to run the fusor instrumentation program.

To test graphics accelerator:
- need to configure advanced gpu driver using raspi-config
- sudo apt-get install mesa-utils
- glxgears
- should see about 60 FPS and no graphics glitches
- note: I did see a hang with graphics accel enabled, when resising terminal
        window;  so suggest don't use X windows

================================
TITLE: BUILD AND INSTALL SDL2 ON RASPBERRY PI
https://gist.github.com/blacktm/8268a468f933eba46f80
================================

#!/bin/bash

# --------------------------------------------------------
# Installs SDL2 from source on the Raspberry Pi (Raspbian)
#
# Run from the web:
#   bash <(curl -s raw_script_url_here)
# --------------------------------------------------------

bold="\033[1m"
normal="\033[0m"

# Welcome message
echo -e "\n${bold}This will install SDL2 from source."
echo -e "It will take about an hour to compile on the Raspberry Pi.${normal}"

# Prompt to continue
read -p "  Continue? (y/n) " ans
if [[ $ans != "y" ]]; then
  echo -e "\nQuitting...\n"
  exit
fi
echo

# Time the install process
START_TIME=$SECONDS

# Setting up SDL2 variables
url="http://www.libsdl.org"

sdl="SDL2-2.0.3"
sdl_url="${url}/release/${sdl}.tar.gz"

image="SDL2_image-2.0.0"
image_url="${url}/projects/SDL_image/release/${image}.tar.gz"

mixer="SDL2_mixer-2.0.0"
mixer_url="${url}/projects/SDL_mixer/release/${mixer}.tar.gz"

ttf="SDL2_ttf-2.0.12"
ttf_url="${url}/projects/SDL_ttf/release/${ttf}.tar.gz"

get () {
  cd /tmp
  wget -N $1
  tar -xzf $2.tar.gz
  cd $2
  ./configure && make && sudo make install
  rm /tmp/$2.tar.gz
  rm -rf /tmp/$2
}

get ${sdl_url} ${sdl}
get ${image_url} ${image}
get ${mixer_url} ${mixer}

sudo apt-get install -y libfreetype6-dev  # ttf dependency
get ${ttf_url} ${ttf}

# Print the time elapsed
ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo -e "\n${bold}Finished in $(($ELAPSED_TIME/60/60)) hr, $(($ELAPSED_TIME/60%60)) min, and $(($ELAPSED_TIME%60)) sec${normal}\n"

================================
TITLE: SAMPLES of .bashrc, .bash_profile, .vimrc
================================

---- .bashrc ---

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

# update ulimit for core dump
ulimit -c unlimited

# General Command aliases
alias ls='ls -l --color=always --group-directories-first --human-readable'
alias bashrc='source ~/.bashrc'
alias bash_profile='source ~/.bash_profile'

# cd aliases
alias pf='cd ~/proj_fusor'

--- .bash_profile ---

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi

# User specific environment and startup programs
export PATH=$PATH:.:$HOME/bin
export GIT_EXTERNAL_DIFF=~/bin/git_external_diff
export LD_LIBRARY_PATH=/usr/local/lib
export PS1='[HOME \u@\h \W]\$ '

--- .vimrc ---

" use 4 spaces for tab indent
set expandtab
set tabstop=8
set softtabstop=4
set shiftwidth=4
set background=dark
colors default
syntax on
set hlsearch
<commit_msg>update notes on how to install mccdaq software<commit_after>================================
TITLE: INSTALL RASPBERRY PI 3
================================

Notes:
- to reinstall: press shift when booting
- to repair
  . press shift when booting
  . add to config   init=/bin/sh
  . mount -o remount,rw /

Install from NOOBS flash card

Configure using raspi-config
- disable X windows, use console login screen
- Note - X windows can be broght up later using 'startx'

Add user account 
- create .bashrc, .bash_profile, .vimrc, .ssh
- add sudo access

Updates, and additional packages, run as root:
  apt-get update
  apt-get install libudev-dev
  apt-get install libevdev-dev
  apt-get install tk
  apt-get install vim

Install SDL2
- script is here, or see copy below
    https://gist.github.com/blacktm/8268a468f933eba46f80
- description of problem getting keybd events
    https://forums.libsdl.org/viewtopic.php?t=10483&sid=38991cf938c103990a18f389312e0f42

To Run SDL2 Program 
- export LD_LIBRARY_PATH=/usr/local/lib
     The following note is from the SDL build output:
          If you ever happen to want to link against installed libraries
          in a given directory, LIBDIR, you must either use libtool, and
          specify the full pathname of the library, or use the `-LLIBDIR'
          flag during linking and do at least one of the following:
             - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
               during execution
             - add LIBDIR to the `LD_RUN_PATH' environment variable
               during linking
             - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
             - have your system administrator add LIBDIR to `/etc/ld.so.conf'
      See any operating system documentation about shared libraries for
      more information, such as the ld(1) and ld.so(8) manual pages.
- run as root

Apply USB Patch
- add the folloing to /boot/cmdline.txt, and reboot
      dwc_otg.fiq_fsm_enable=0
- see https://github.com/raspberrypi/linux/issues/618 for information
- this seems to fix a webcam failure that occurs when closing and reopening the /dev/video0

Enable core dumps for suid processes
- add te following to /etc/sysctl.conf, and reboot
      fs.suid_dumpable=1

Install support software for the Measurement Computing USB 204 ADC
- The procedure outlined below is from http://www.mccdaq.com/TechTips/TechTip-9.aspx
- Procedure ...
    # make a director
    mkdir mccdaq
    cd mccdaq/
  
    # Download MCC Drivers and test apps are contained in the MCCLIBHID.1.61.tgz 
    sudo apt-get install ftp
    ftp lx10.tx.ncsu.edu   (anonymous  <your-email-address>)
      cd pub/Linux/drivers
      get 61-mcc.rules
      cd USB
      get MCCLIBUSB.tgz
      exit
  
    # Install libusb, a C library that provides generic access to USB devices:
    sudo apt-get install libusb-1.0-0 libusb-1.0-0-dev
  
    # Copy the mcc USB rules file to the /etc/udev/rules.d directory, renaming it to 99-mcc.rules 
    # (preventing an issue with the standard naming on the Raspberry Pi): 
    sudo cp 61-mcc.rules /etc/udev/rules.d/99-mcc.rules
  
    # Clone the hidapi GIT repository to the home/pi directory, and
    # build & install
    sudo apt-get install libudev-dev libfox-1.6-dev autotools-dev autoconf automake libtool
    git clone git://github.com/signal11/hidapi.git
    cd hidapi
    ./bootstrap
    ./configure 
    make
    sudo make install
  
    # reboot
    sudo reboot
  
    # install MCC Linux software
    cd mccdaq/
    tar zxvf MCCLIBUSB.tgz
    cd mcc-libusb
    make
    sudo make install
    sudo ldconfig
  
    # run the test app
    cd mcc-libusb
    ./test-usb20X

================================
TITLE: BUILD AND INSTALL SDL2 ON RASPBERRY PI
https://gist.github.com/blacktm/8268a468f933eba46f80
================================

#!/bin/bash

# --------------------------------------------------------
# Installs SDL2 from source on the Raspberry Pi (Raspbian)
#
# Run from the web:
#   bash <(curl -s raw_script_url_here)
# --------------------------------------------------------

bold="\033[1m"
normal="\033[0m"

# Welcome message
echo -e "\n${bold}This will install SDL2 from source."
echo -e "It will take about an hour to compile on the Raspberry Pi.${normal}"

# Prompt to continue
read -p "  Continue? (y/n) " ans
if [[ $ans != "y" ]]; then
  echo -e "\nQuitting...\n"
  exit
fi
echo

# Time the install process
START_TIME=$SECONDS

# Setting up SDL2 variables
url="http://www.libsdl.org"

sdl="SDL2-2.0.3"
sdl_url="${url}/release/${sdl}.tar.gz"

image="SDL2_image-2.0.0"
image_url="${url}/projects/SDL_image/release/${image}.tar.gz"

mixer="SDL2_mixer-2.0.0"
mixer_url="${url}/projects/SDL_mixer/release/${mixer}.tar.gz"

ttf="SDL2_ttf-2.0.12"
ttf_url="${url}/projects/SDL_ttf/release/${ttf}.tar.gz"

get () {
  cd /tmp
  wget -N $1
  tar -xzf $2.tar.gz
  cd $2
  ./configure && make && sudo make install
  rm /tmp/$2.tar.gz
  rm -rf /tmp/$2
}

get ${sdl_url} ${sdl}
get ${image_url} ${image}
get ${mixer_url} ${mixer}

sudo apt-get install -y libfreetype6-dev  # ttf dependency
get ${ttf_url} ${ttf}

# Print the time elapsed
ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo -e "\n${bold}Finished in $(($ELAPSED_TIME/60/60)) hr, $(($ELAPSED_TIME/60%60)) min, and $(($ELAPSED_TIME%60)) sec${normal}\n"

================================
TITLE: SAMPLES of .bashrc, .bash_profile, .vimrc
================================

---- .bashrc ---

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

# update ulimit for core dump
ulimit -c unlimited

# General Command aliases
alias ls='ls -l --color=always --group-directories-first --human-readable'
alias bashrc='source ~/.bashrc'
alias bash_profile='source ~/.bash_profile'

# cd aliases
alias pf='cd ~/proj_fusor'

--- .bash_profile ---

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi

# User specific environment and startup programs
export PATH=$PATH:.:$HOME/bin
export GIT_EXTERNAL_DIFF=~/bin/git_external_diff
export LD_LIBRARY_PATH=/usr/local/lib
export PS1='[HOME \u@\h \W]\$ '

--- .vimrc ---

" use 4 spaces for tab indent
set expandtab
set tabstop=8
set softtabstop=4
set shiftwidth=4
set background=dark
colors default
syntax on
set hlsearch

=================================
TITLE: GRAPHICS ACCELERATOR
=================================
 
** Not needed to run the fusor instrumentation program. **

To test graphics accelerator:
- need to configure advanced gpu driver using raspi-config
- sudo apt-get install mesa-utils
- glxgears
- should see about 60 FPS and no graphics glitches
- note: I did see a hang with graphics accel enabled, when resising terminal
        window;  so suggest don't use X windows
{'fraction_non_alphanumeric': 0.1600831600831601, 'fraction_numerical': 0.022536382536382536, 'mean_word_length': 3.097444633730835, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, 'https://': 8, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5334129', 'n_tokens_mistral': 4206, 'n_tokens_neox': 3869, 'n_words': 1279}