Sunday, January 29, 2012

reference_information.txt file

Get Specific events within date range with icalbuddy
icalbuddy -sc -f eventsFrom:'November 28, 2011' to:'December 2, 2011'

käme es mir gelegen = es wäre gut für mich.


How do I put GRUB into the boot sector of a partition instead of putting it in the MBR via grub-install?
grub-install --root-directory=/boot /dev/hdb
update-grub
MBR:
boot sector = 448 bytes - 2 equal bytes at the end = 446=bs
partition table info = 46 bytes after boot sector
Totaling to bs=512 count=1

tar -jxf for tar.bz2
hdiutil for conversion img and dmg
hdiutil convert source.img/iso -format UDRW -o output.dmg/***
hdiutil convert some.dmg -format UDTO -o some.dd
optional: conv=sync,noerror

The MBR consists of _three_ parts, not two:

1. The first 446 bytes contain the boot loader.
2. The next 64 bytes contain the partition table (4 entries, each 16 bytes).
3. The last 2 bytes contain the identifier 0xAA55 (or 0x55AA, I forgot).

To copy the boot loader only, one *must* use "bs=446". To copy the partition table only, one must use "bs=1 skip=446 count=64".
To exclude the partition table count=1 bs=446
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
The Hackintosh Bootloader (GUID or FDisk partition schemes)
boot0
typically placed in the boot code secion of MBR for a darwin-only system. On some systems, it may not be installed and an alternative primary boot manager (which has its own code) such as LILO may be used.

boot1h
goes in the boot section (first .5KB) of a HFS+ partition, and has enough code to parse an HFS+ volume header, find the extents associated with the "HFS+ Startup File" and load it.

boot
Boot is what is reffered to by the Startup File extents for a HFS+ volume. This is the second-stage loader which is in charge of presenting the list of bootable3 volumes, and if applicatble, loading a kernel + extensions from the filesystem. (cdboot is a modified version of boot for use on CDs)

For a standalone sing-partition HFS install, you would ideally have:
A) boot0 - in the MBR, LILO, or GRUB
B) boot1h - in the first 512-bytes of the HFS+ partition
C) boot - pointed to by the HFS+ Startup File

To install boot0 in the MBR
dd if=/path/to/file/boot0 of=dev/diskX bs=400 count=1

To install boot1h in the bootsector
dd if=/path/to/file/boot1h of=dev/diskXsY bs=512 count=1

To set the HFS+ Startup File
/path/to/file/startupfiletool /dev/rdiskXsY /path/to/file/boot

It is convetional to install boot0, boot1h, and boot to /usr/standalone/i386

In addition, if you are using a FDisk partition scheme, you must set the boot partition of the disk active.
fdisk -e /dev/rdiskX
Ignore the error "fdisk: could not open MBR file..."
p "varifies partition"
f 1 "set partition active"
w "write to partition"
y (yes you are sure)
exit (to quit)

update latex files with sudo mktexlsr

My howto file in ~/howto

#####################################
#this is text file with useful tips##
#####################################
download youtube with command: youtube-dl
get all links on website: get-links.py #optional: > atextfile.txt

download packages and all dependencies
use 'python grabpackages.py -o '
then copy and paste contents of to command line and push enter to initiate download into current directory.

To save the MBR to a file (this contains the partition table too):
dd if=/dev/hda of=hda-mbr-full bs=512 count=1

To save the MBR, without the partition table, to a file:
dd if=/dev/hda of=hda-mbr-nopart bs=446 count=1

To save a boot sector (e.g. partition 3) to a file:
dd if=/dev/hda3 of=hda3-bootsect bs=512 count=1
MBR TOTAL SIZE = 446 + 64 + 2 = 512
446 bytes - Bootstrap.
64 bytes - Partition table.
2 bytes - Signature.

Use 446 bytes to overwrite or restore your /dev/XYZ MBR boot code only with the contents of $mbr.backup.file.
Use 512 bytes to overwrite or restore your /dev/XYZ the full MBR (which contains both boot code and the drive's partition table) with the contents of $mbr.backup.file.

for example, if identically sized partitions on origin and destination,
this command will copy 512 bytes (MBR) from sda to sdb disk.
dd if=/dev/sda of=/dev/sdb bs=512 count=1

different size partitions-two step process
dd if=/dev/sda of=/tmp/mbrsda.bak bs=512 count=1
dd if=/tmp/mbrsda.bak of=/dev/sdb bs=446 count=1

The above commands will preserve the partitioning schema.
####################
####################



edit a file in root mode with textedit
$ gksudo gedit

set vlc as main media player for everything
gksudo gedit the following and do a search & replace of totem and replace with vlc
/usr/share/applications/defaults.list

check size of directory
$ du -h /foldername --human readable
$ du -ah /foldername --all filenames along with the directory
$ du -c /foldername --grand total

usb-creator-gtk

find router address
$ route -n
OR
$ netstat -r

remove empty folders
find . -type d -empty -delete

recursively move files
find . -name '*.flv' -exec mv {} flv \;

how to extract tar.gz
tar xyvf

how to setup various settings, like auto open a mounted drive in nautilus
gconf-editor

python documentation server
pydoc -g
#####BASH WILDCARDS######
Wildcard Matches
* zero or more characters
? exactly one character
[abcde] exactly one character listed
[a-e] exactly one character in the given range
[!abcde] any character that is not listed
[!a-e] any character that is not in the given range
{debian,linux} exactly one entire word in the options given

Great Free and Useful Software for Apple Macs

ProVoc
Purpose: Learning via flashcards.
Details: It is no longer being developed, but works under Lion. Another developer has used the ProVoc code to create iVocabulary and has also created an iOS app for it. You can create an excel document and export it to a text file, which will import to Provoc properly (if using korean characters or similar, eport to UTF-16 txt). Use column A (language 1), B (language 2), and C (for comments).
Location: http://www.arizona-software.ch/provoc/

Saturday, January 28, 2012

Making Microsoft Word 2011 Mac produce (Xe)(La)TeX Style Outlines for Academic Papers with Applscript

(*
Academic Paper Setup

Copyright © 2012 Jonathan Komar

Just kidding there is no copyright. Open Source rules!

You may use this code however you like. It would be nice 
if you made reference to the original code when sharing.

THINGS TO DO:
find a fix for changing font color of headings without hardcoding it.
fix headings 4-9
*)



(*<Properties to be set by the user*)
--number suffix corresponds to heading 1, heading 2, etc.
--NOTE: To change the coloring of headings, it must be hardcoded. must find a fix.
property fontName1 : "CMU Serif Roman"
property fontName2 : "CMU Serif Roman"
property fontName3 : "CMU Serif Roman"
property fontName4 : "CMU Serif Roman"
property fontName5 : "CMU Serif Roman"
property fontName6 : "CMU Serif Roman"
property fontName7 : "CMU Serif Roman"
property fontName8 : "CMU Serif Roman"
property fontName9 : "CMU Serif Roman"
property fontSize1 : 15
property fontSize2 : 14
property fontSize3 : 13
property fontSize4 : 12
property fontSize5 : 12
property fontSize6 : 12
property fontSize7 : 12
property fontSize8 : 12
property fontSize9 : 12
property boldTF : true
property italicTF : false
property highlightTF : false
(*Properties to be set by the user>*)

tell application "Microsoft Word"
    tell active document
        (*<normal code BLOCK*)
        set name of font object of Word style style normal to "CMU Serif Roman"
        set font size of font object of Word style style normal to 12
        set bold of font object of Word style style normal to false
        set italic of font object of Word style style normal to false
        set color index of font object of Word style style normal to black
        (*normal code BLOCK>*)
        
        
        (*<heading 1 code BLOCK*)
        set name of font object of Word style style heading1 to fontName1
        set font size of font object of Word style style heading1 to fontSize1
        set bold of font object of Word style style heading1 to boldTF
        set italic of font object of Word style style heading1 to italicTF
        set color index of font object of Word style style heading1 to black
        --set paragraph format left indent of paragraph format of Word style style heading1 to (centimeters to points centimeters 0) --indent sections relative to margin
        --set tab stop position of tab stop of Word style style heading1 to (centimeters to points centimeters 1)
        --set tab hanging indent of paragraph format of Word style style heading1 to count 1
        (*heading 1 code BLOCK>*)
        (*<heading 2 code BLOCK*)
        set name of font object of Word style style heading2 to fontName1
        set font size of font object of Word style style heading2 to fontSize1
        set bold of font object of Word style style heading2 to boldTF
        set italic of font object of Word style style heading2 to italicTF
        set color index of font object of Word style style heading2 to black
        (*heading 2 code BLOCK>*)
        (*<heading 3 code BLOCK*)
        set name of font object of Word style style heading3 to fontName1
        set font size of font object of Word style style heading3 to fontSize1
        set bold of font object of Word style style heading3 to boldTF
        set italic of font object of Word style style heading3 to italicTF
        set color index of font object of Word style style heading3 to black
        (*heading 3 code BLOCK>*)
        (*<heading 4 code BLOCK*)
        set name of font object of Word style style heading4 to fontName1
        set font size of font object of Word style style heading4 to fontSize1
        set bold of font object of Word style style heading4 to boldTF
        set italic of font object of Word style style heading4 to italicTF
        set color index of font object of Word style style heading4 to black
        (*heading 4 code BLOCK>*)
        (*<heading 5 code BLOCK*)
        set name of font object of Word style style heading5 to fontName1
        set font size of font object of Word style style heading5 to fontSize1
        set bold of font object of Word style style heading5 to boldTF
        set italic of font object of Word style style heading5 to italicTF
        set color index of font object of Word style style heading5 to black
        (*heading 5 code BLOCK>*)
        (*<heading 6 code BLOCK*)
        set name of font object of Word style style heading6 to fontName1
        set font size of font object of Word style style heading6 to fontSize1
        set bold of font object of Word style style heading6 to boldTF
        set italic of font object of Word style style heading6 to italicTF
        set color index of font object of Word style style heading6 to black
        (*heading 6 code BLOCK>*)
        (*<heading 7 code BLOCK*)
        set name of font object of Word style style heading7 to fontName1
        set font size of font object of Word style style heading7 to fontSize1
        set bold of font object of Word style style heading7 to boldTF
        set italic of font object of Word style style heading7 to italicTF
        set color index of font object of Word style style heading7 to black
        (*heading 7 code BLOCK>*)
        (*<heading 8 code BLOCK*)
        set name of font object of Word style style heading8 to fontName1
        set font size of font object of Word style style heading8 to fontSize1
        set bold of font object of Word style style heading8 to boldTF
        set italic of font object of Word style style heading8 to italicTF
        set color index of font object of Word style style heading8 to black
        (*heading 8 code BLOCK>*)
        (*<heading 9 code BLOCK*)
        set name of font object of Word style style heading9 to fontName1
        set font size of font object of Word style style heading9 to fontSize1
        set bold of font object of Word style style heading9 to boldTF
        set italic of font object of Word style style heading9 to italicTF
        set color index of font object of Word style style heading9 to black
        (*heading 9 code BLOCK>*)
        
    end tell
    
    (*<apply numbering to the sections code BLOCK*)
    set selFind to find object of selection --selects text of execute find command
    clear formatting selFind --reset selFind just to make sure
    set style of selFind to style heading1 --set style we are looking for
    execute find selFind find text "" wrap find find continue with find format and match forward
    if found of selFind is true then
        --display dialog (get content of text object of selection) --for debugging only
        (*<code BLOCK word__set paragraph style*)
        --I apply the formatting to the previously found text
        set myLT to list template 5 of list gallery 3 of active document
        apply list format template (list format of text object of selection) ¬
            list template myLT
    end if
    (*Apply numbering to the sections code BLOCK>*)
    
    
    
    
    
    
    
    
    
    
    
    
    (*******************************************
    (*<code BLOCK word_get style.scpt*)
    --i select the header 1 stuff
    set selFind to find object of selection --selects text of execute find command
    clear formatting selFind --reset selFind just to make sure
    set style of selFind to style heading1 --set style we are looking for
    execute find selFind find text "" wrap find find continue with find format and match forward
    if found of selFind is true then
        --display dialog (get content of text object of selection) --for debugging only
        (*<code BLOCK word__set paragraph style*)
        --I apply the formatting to the previously found text
        set theRange to text object of active document --i say where to apply the script
        set myStyle to Word style of object of selection of active document --debug only
        --set myStyle to make new Word style at active document with properties ¬
        {name local:"Section", style type:style type paragraph}
        tell font object of selFind
            set name to fontName1
            set font size to fontSize1
            set bold to true
        end tell
        set myLT to list template 5 of list gallery 3 of active document
        apply list format template (list format of text object of selection) ¬
            list template myLT
        (*code BLOCK word__set paragraph style>*)
        --set style of theRange to myStyle --i actually apply the settings
        update styles active document
    end if
    (*code BLOCK word_get style.scpt>*)
    *********************************)
    
end tell

Friday, January 20, 2012

Applescript: Open multiple websites in tabs with Firefox

#open websites in tabs with firefox
set list_Sites to {"http://www.google.at", "http://www.yahoo.com"}

tell application "Firefox"
activate
repeat with a in list_Sites
do shell script "open -a Firefox" & space & quoted form of a
end repeat
end tell

Thursday, January 19, 2012

Python Script to Open Webpages in Firefox tabs (or any browser supported by the python webbrowser library)

  #python  
import webbrowser  
a = ['http://www.google.com/reader','http://www.yahoo.com/','http://www.facebook.com/']  
  for x in a:  
       webbrowser.get('firefox').open_new_tab(x)  

You just need to copy and paste that code into a text file and save it as something like "opensite.py" (better to use the .py extension)

Make it executable running the following command in terminal:
 sudo chmod a+x opensite.py  

Run it either in the command line with
 python /path/to/opensite.py  

Or create a launcher (you can do this in Ubuntu easily by right clicking on the desktop)

Firefox Download Files to Specific Folders Frequently

Hey firefox users:

Useful tip for firefox (if you use firefox). Ever wish you download files directly to a specific folder without having to move them later. For example, I have a folder structure like this:

~/University/Winter2011/Media Class

I want to download documents for my Media Class into that folder frequently.

You can get an "add-on" for firefox called "save file to" and it will allow you to easily set up such folders as download locations. I am using save file to 2.2"

I find it to be quite useful!

Friday, January 6, 2012

Typing/Typesetting Korean with xelatex (unicode latex)

The following is a link to the PDF file generated by the xelatex source below:
http://www.mediafire.com/?4w382gzlk9kry04">82gzlk9kry04

 Xelatex Source:  
 %XELATEX DOCUMENT  
 \documentclass[12pt]{extreport}  
 \usepackage[top=2.5cm, bottom=2.5cm, left=2.5cm, right=2.5cm]{geometry}  
 %\usepackage[margin=1in, paperwidth=5.5in, paperheight=8.5in]{geometry}  
 \usepackage{fancyhdr}  
 \pagestyle{fancy}  
 \lhead{\textsc{Jonathan Komar}} \chead{\textsc{Koreanisch}} \rhead{\textsc{Seite\hspace{.2cm}-\thepage-}}   
 \lfoot{\textsc{Version 2}} \cfoot{\textsc{}} \rfoot{\textsc{erstellt mit XeLatex am 06. Jänner 2012}}  
 \renewcommand{\headrulewidth}{0.1pt}   
 \renewcommand{\footrulewidth}{0.1pt}  
 \usepackage{xcolor}%add color support for text  
 \usepackage{xltxtra}  
 \usepackage{fontspec}%included in xltxtra allows for switching fonts in document with \fontspec{fontname} command  
 \usepackage{xunicode}%included in xltxtra  
 \setmainfont[Mapping=tex-text]{Linux Libertine O}%set main global font  
 \newfontfamily{\korean}{Batang}%creates custom command to temporarily change to korean font.  
 \definecolor{red}{RGB}{255,0,0}  
 \definecolor{blue}{RGB}{27,0,55}  
 \definecolor{orange}{RGB}{255,68,0}  
 \begin{document}  
 ㅈ  
 %%  
 \begin{table}[htdp]  
 \caption{Selbstlaute \textsc{(Einzellaute)}}  
 \begin{center}  
 \begin{tabular}{|c|c|c|}  
 Vokale & IPA \\\hline  
 \korean{{\Huge ㅇㅏ}} & /a/ or /ɐ/ \\  
 \korean{{\Huge ㅇㅓ}} & /ə/\\  
 \korean{{\Huge ㅇㅗ}} & /o/\\  
 \korean{{\Huge ㅇㅜ}} & /u/\\  
 \korean{{\Huge ㅇㅡ}} & /ɯ/\\  
 \korean{{\Huge ㅇㅣ}} & /i/\\  
 \korean{{\Huge ㅇㅔ}}&/e/\\  
 \korean{{\Huge ㅇᅢ}}&/ɛ/\\  
 \end{tabular}  
 \end{center}  
 \label{default}  
 \end{table}%  
 %%  
 \begin{table}[htdp]  
 \caption{Selbstlaute \textsc{(Doppellaute)}}  
 \begin{center}  
 \begin{tabular}{|c|c|}  
 \korean{{\Huge ㅇㅑ}} & /ja/ or /jɐ/ \\  
 \korean{{\Huge ㅇㅕ}} & /jə/\\  
 \korean{{\Huge ㅇㅛ}} & /jo/\\  
 \korean{{\Huge ㅇㅠ}} & /ju/\\  
 \korean{{\Huge ㅇㅖ}}&/je/ \\   
 \korean{{\Huge ㅇㅒ}}& /jɛ/\\   
 \korean{{\Huge ㅇㅟ}}&/wi/ \\   
 \korean{{\Huge ㅇㅞ}}&/we/\\   
 \korean{{\Huge ㅇㅙ}}&/wɛ/\\  
 \korean{{\Huge ㅇㅘ}}&/wa/\\  
 \korean{{\Huge ㅇㅢ}}&/ɰi/\\  
 \korean{{\Huge ㅇㅝ}}&/wʌ/\\  
 \end{tabular}  
 \end{center}  
 \label{default}  
 \end{table}%  
 %%  
 \begin{table}[htdp]  
 \caption{Konsonanten}  
 \begin{center}  
 \begin{tabular}{|c|c|c|c|}  
 Phonem&IPA\\\hline  
 \korean{{\Huge ㅂ}}&/b/ or /p/\tiny{or /m/ (vor \korean{ㅁ,ㄴ,ㄹ})}\\  
 \korean{{\Huge ㅃ}}&/p͈ʰ/\\  
 \korean{{\Huge ㅍ}}&/pʰ/\\  
 \korean{{\Huge ㅁ}}&/m/\\  
 \korean{{\Huge ㄷ}}&/d/ or /t/\\  
 \korean{{\Huge ㄸ}}&/t͈ʰ/\\  
 \korean{{\Huge ㅌ}}&/tʰ/\\  
 \korean{{\Huge ㄴ}}&/n/\\  
 \korean{{\Huge ㅈ = [  ]}}&/ʤ/ or /ʧ/\\%problem here prints like a diff character  
 \korean{{\Huge ㅉ}}&/ʤ͈ʰ/\\  
 \korean{{\Huge ㅊ = [  ]}}&/ʧʰ/\\%problem here prints like a diff character  
 \korean{{\Huge ㄱ}}&/g/ or /k/\\  
 \korean{{\Huge ㄲ}}&/k͈ʰ/\\  
 \korean{{\Huge ㅋ}}&/kʰ/\\  
 \korean{{\Huge ㅇ}}&/ŋ/{\tiny (Endsilbe)}\\  
 \korean{{\Huge ㅅ}}&/s/ or /ʃ/\\  
 \korean{{\Huge ㅆ}}&/s͈ʰ/\\  
 \korean{{\Huge ㄹ}}&/l/ oder /ɾ/\\  
 \korean{{\Huge ㅎ}}&/h/\\  
 \end{tabular}  
 \end{center}  
 \label{default}  
 \end{table}%  
 See footnotes for ⟨◌͈⟩\footnote{The IPA symbol ⟨◌͈⟩ (a subscript double straight quotation mark, shown here with a placeholder circle) is used to denote the tensed consonants /p͈/, /t͈/, /k͈/, /t͈ɕ/, /s͈/. Its official use in the Extensions to the IPA is for 'strong' articulation, but is used in the literature for faucalized voice.}  
 \footnote{Faucalized voice, also called hollow or yawny voice, is the production of speech sounds with an expanded laryngeal cavity. It contrasts with harsh voice, in which the larynx is compressed.  
 There is no symbol for faucalized voice in the standard IPA. Diacritics seen in the literature include the strong articulation diacritic ([a͈]) of the Extensions to the IPA. I}  
 %%  
 \begin{table}[htdp]  
 \caption{Ich studiere Sprachwissenschaft.}  
 \begin{center}  
 \begin{tabular}{|c|c|c|}  
 Sprachwissenschaft & studieren & Höfflichkeitsform\\  
 \korean{{\Huge 언어학}} & \korean{{\Huge 공부}} & \korean{{\Huge 합니다}}\\  
 /ɛn ɛ hak & go bu & hap ni da/\\  
 \end{tabular}  
 \end{center}  
 \label{default}  
 \end{table}%  
 %%  
 \begin{table}[htdp]  
 \caption{Am Morgen esse ich Reis.}  
 \begin{center}  
 \begin{tabular}{|c|c|c|c|c|c|}  
 Morgen&am&Reis&Objmarke&esse&Höfflichkeitsform\\  
 \korean{{\Huge 아침}}&\korean{{\Huge 에}}&\korean{{\Huge 밥}}&\korean{{\Huge {\color{red}{을}}}}&\korean{{\Huge 먹}}&\korean{{\Huge {\color{red}{습}}니다}}\\  
 /a tʃim & e & bap & ɯl & mɯk & ʃɯm ni da/\\  
 &&&&& sɯm ni da/\\  
 \end{tabular}  
 \end{center}  
 \label{default}  
 \end{table}%  
 %%  
 \begin{table}[htdp]  
 \caption{Am Wochenende kaufe ich Alkohol.}  
 \begin{center}  
 \begin{tabular}{|c|c|c|c|c|c|}  
 Wochenende&am&Alkohol&Objmarke&kaufe&Höfflichkeitsform\\  
 \korean{{\Huge 주말}}&\korean{{\Huge ㅇㅔ}}&\korean{{\Huge 술}}&\korean{{\Huge {\color{red}{을}}}}&\korean{{\Huge 사}}&\korean{{\Huge {\color{red}{ㅂ}}니다}}\\  
 &&&&\korean{{\Huge(삽)}}&\korean{{\Huge(니다)}}\\  
 /tʃu mal & e & sul & ɯl & ʃa & m ni da/\\  
 &immer mit Objekt&&&\\  
 & eines anderes Wortes  
 \end{tabular}  
 \end{center}  
 \label{default}  
 \end{table}%  
 %%  
 \begin{table}[htdp]  
 \caption{Am Abend esse ich Schinkenbrot.}  
 \begin{center}  
 \begin{tabular}{|c|c|c|c|c|c|}  
 Abend&am&Schinkenbrot&Objmarke&esse&Höfflichkeitsform\\  
 \korean{{\Huge 저녁}}&\korean{{\Huge 에}}&\korean{{\Huge 햄뻥}}&\korean{{\Huge {\color{red}{을}}}}&\korean{{\Huge 먹}}&\korean{{\Huge {\color{red}{슴}}니다}}\\  
 /ʤə njəg & e & hɛm p͈ʰɯɳ & ɯl & mək & ʃɯm ni da/\\  
 &&&&&sɯm ni da\\  
 \end{tabular}  
 \end{center}  
 \label{default}  
 \end{table}%  
 %%  
 \begin{table}[htdp]  
 \caption{Im Sommer treffe ich am Mittag normalerweise einen Freund.}  
 \begin{center}  
 \begin{tabular}{|c|c|c|c|c|c|c|c|c|}  
 Sommer&im&Mittag&am&normalerweise&einen Freund&Objmarke&treffe&Höfflichkeitsform\\  
 \korean{여름}&\korean{에}&\korean{점심}&\korean{에}&\korean{보통}&\korean{친구}&\korean{ {\color{red}{를}}}&\korean{만 나}&\korean{ {\color{red}{ㅂ}}니다}\\  
 &&&&&&&\korean{(만남)}&\korean{(니다)}\\  
 /jə rɯm & e & ʤɛm sim & e & bo to & ʧʰin gul & rɯl & man na & m ni da/\\  
 \end{tabular}  
 \end{center}  
 \label{default}  
 \end{table}%  
 %%  
 \begin{table}[htdp]  
 \caption{Ich bin ein Mann}  
 \begin{center}  
 \begin{tabular}{|c|c|c|c|c|c|c}  
 ich&ein Mann&bin&Höfflichkeitsform\\  
 \korean{{\Huge 저는}}&\korean{{\Huge 남자}}&\korean{{\Huge 이}}&\korean{{\Huge {\color{red}{ㅂ}}니다}}\\  
 &&\korean{{\Huge {(입)}}}&\korean{{\Huge (니다)}}\\  
 /ʤə nɯn & nam ʤa & i & m ni da/\\  
 \end{tabular}  
 \end{center}  
 \label{default}  
 \end{table}%  
 %%  
 \section*{Haben + \korean{{\Huge 이 가}}}  
 %%  
 \begin{table}[htdp]  
 \caption{Ich habe ein Handy.}  
 \begin{center}  
 \begin{tabular}{|c|c|c|c|c|c|c}  
 Handy&habe ich&Objmarke&Höfflichkeitsform\\  
 \korean{{\Huge (학디)?}}&\korean{{\Huge {\color{red}{가}}}}&\korean{{\Huge 이}}&\korean{{\Huge {\color{red}{릅}}니다}}\\  
 &&\korean{{\Huge {}}}&\korean{{\Huge }}\\  
 /? & da & i & sɯm ni da/\\  
 \end{tabular}  
 \end{center}  
 \label{default}  
 \end{table}%  
 %%  
 \begin{table}[htdp]  
 \caption{Ich habe Wasser.}  
 \begin{center}  
 \begin{tabular}{|c|c|c|c|c|c|c}  
 Wasser&habe ich&Objmarke&Höfflichkeitsform\\  
 \korean{{\Huge 물}}&\korean{{\Huge {\color{red}{이}}}}&\korean{{\Huge 이}}&\korean{{\Huge {\color{red}{릅}}니다}}\\  
 &&\korean{{\Huge {}}}&\korean{{\Huge }}\\  
 /mul & i & i & sɯm ni da/\\  
 \end{tabular}  
 \end{center}  
 \label{default}  
 \end{table}%  
 \end{document}  

Thursday, January 5, 2012

BASH Script Download Programs and ALL dependencies for offline installation

This is useful for linux users who may not always have an internet connection for apt-get and wish to create a database of offline installable deb files.
Note to basic users:

You can install *.deb files with the following command (ignore the $, just means its on the command line)
 $ sudo dpkg -i *.deb  

I have written and tested this script in Ubuntu 11.04 Desktop. FYI It is a work in progress. What I am trying to say is that it is not idiot-proof.

HOW DOES IT WORK?

You make a plain text file, typing each program you wish to install. Put spaces in between programs but no carriage return. Example: python2.6 alarm easyshutdown gimp
Another example:
Command line example of program list (although you could use a text editor):
1:  $ echo "vlc alarm-clock apache2 conky curl ffmpeg" > programs.txt  

Copy this script to a text editor, save as installsource-generator.sh
Before you can run a new script, you have to make it executable with the command:

1:  $ sudo chmod a+x installsource-generator.sh  
Before running the script, open the script and edit the variable where you would like to set up an installsource directory. (you can find it in between all of the pound signs towards the beginning)

Ensure stable internet connection (the command wget -c will be used to download files, which will attempt to reconnect if link is lost)
Make sure you download grabpackages.py and move it to the /usr/local/bin folder with the command
1:  $ sudo mv /folder/of/grabpackages.py /usr/local/bin  
2:  $ sudo chmod a+x grabpackages.py /usr/local/bin/grabpackages.py #(to make it executable)  


You are now ready to download programs with ALL dependencies
To run, simple invoke the following command (you may need to type 'sudo -s' without quotes first)
1:  $ sudo sh installsource-generator.sh nameoftextfile.txt  


HERE IS THE CODE:

 #!/bin/sh  
 #this program generates an installsource of packages + all dependencies from an array of files. use the spaces  
 #installsource-generator  
 #version 2.0  
 #requires grabpackages.py in /usr/local/bin (must make it executable ie sudo chmod a+x grabpackages.py)  
 #SUMMARY OF ACTIONS  
 #get list of package names (programs)  
 #mkdir in installsource for each package  
 #run grabpackages.py on each package and output to the corresponding list of dependencies (sh file) to folder (auto appropriately name for each program)  
 #chmod a+x on each sh file from grabpackages.py  
 #ask user whether to install the deb files  
 ##################################################  
 ##################################################  
 ##################################################  
 ##################################################  
 ############VARIABLES TO BE SET BY USER###########  
 ##################################################  
 #i set installLoc  
 installLoc="$HOME/installsource-ubuntu/generated"  
 ##################################################  
 ##################################################  
 #create installsource directory if its not there already  
 mkdir -p "$installLoc"  
 #array=( one two three )#i am an example of an array  
 #testfor$1input  
 if test ! -s "$1"  
 then  
  echo 'syntax> installsource-generator listofprograms.txt'  
 fi  
 #i assign array to variable  
 #declare -a arrayFile  
 #array=`cat "$1"`  
 #declare -a arrayFile=($array)  
 ##################################################  
 ##################################################  
 for i in `cat "$1"`  
 do  
   # do whatever on $i  
  echo "creating folder $i"  
  mkdir "$installLoc/$i"  
  echo "downloading packages with grabpackages.py and saving to folder "$i""  
  grabpackages.py -o "$installLoc/$i/$i.sh" "$i"  
  #make files executable  
  sudo chmod a+x "$installLoc/$i/$i.sh"  
  fullPath="$installLoc/$i/"  
  sed -i "s|wget -c|wget -c -P $fullPath|g" "$installLoc/$i/$i.sh"  
  sh "$installLoc/$i/$i.sh"  
 done  
 ##################################################  
 echo "COMPLETED ALL DOWNLOADS AND PREPARING TO INSTALL"  
 echo "WOULD YOU LIKE TO INSTALL ALL DOWNLOADED PACKAGES?"  
 read installAnswer  
 if [ $installAnswer = "y" ]; then  
 echo 'STARTING INSTALL'  
 for i in `cat "$1"`  
 do  
   # do whatever on $i  
  echo "installing package $1.sh"  
  sudo dpkg -i "$installLoc/$i/*.sh"  
 done  
  sudo dpkg -i $mediaDrive/$installsource/*.deb  
  echo 'install complete, script complete'  
 else  
  echo 'no install, script complete'  
 fi  

BASH script quotations review.







I often write Bourne Scripts using variables of file locations. Here are several examples of text inputs with results for reference:

#!/bin/sh
folder1="~/Desktop/scriptexp/subfolder 1"
echo $folder1
#RESULT>~/Desktop/scriptexp/subfolder 1<
echo "$folder1"
#RESULT>~/Desktop/scriptexp/subfolder 1<
echo '$folder1'
#RESULT>$folder1<
#########################################
folder2='~/Desktop/scriptexp/subfolder 1'
echo $folder1
#RESULT>~/Desktop/scriptexp/subfolder 1"<
echo "$folder1"
#RESULT>~/Desktop/scriptexp/subfolder 1<
echo '$folder1'
#RESULT>$folder1<
#########################################
folder3="~/Desktop/scriptexp"
folder4="subfolder 1"
echo "$folder3/$folder4"
#RESULT>~/Desktop/scriptexp/subfolder 1<
echo "$folder3/$folder4"
#RESULT>~/Desktop/scriptexp/subfolder 1<
echo '$folder3/$folder4'
#RESULT>$folder3/$folder4<
#****************************************
echo "$folder3/"folder4""
#RESULT>~/Desktop/scriptexp/folder4<
#****************************************
#****************************************
echo "$folder3/'folder4'"
#RESULT>~/Desktop/scriptexp/'folder4'<
#########################################
text1="I like to "go" running."
echo $text1
#RESULT>I like to go running.<
echo "$text1"
#RESULT>I like to go running.<
echo '$text1'
#RESULT>$text1<
text2="I like to 'go' running."
echo $text2
#RESULT>I like to 'go' running.<
echo "$text2"
#########################################
text3='I like to "go" running.'
echo $text3
echo "here"
#RESULT>I like to "go" running.<
echo "$text3"
#RESULT>I like to "go" running.<
echo '$text3'