Bestimmter Prozess direkt per PID killen

Und noch etwas, was ich immer wieder vergesse:

PID=`ps aux | grep mysql | awk {'printf($2);exit'}`
kill -9 $PID

Advertisements

Latex package ‚lstlisting‘

Einbinden von dem Package:
\usepackage{listings}

Damit die eigendefinerten Farben erkannt werden:
\usepackage{color}
\definecolor{DarkGrey}{rgb}{0.1,0.1,0.1}

Es können verschiedene Styles definiert werden:
\lstdefinestyle{Bash}
{ language=Bash,
backgroundcolor=\color{DarkGrey},
keywordstyle=\color{BlueViolet}\bfseries,
commentstyle=\color{Grey},
stringstyle=\color{Red},
showstringspaces=false,
basicstyle=\small\color{white},
numbers=none,
captionpos=b,
tabsize=4,
breaklines=true
}


\lstdefinestyle{Java}
{ language=Java
}

Dieser Style wäre z.B für ein Listing von Bashcommandos.

Verwendung:
\begin{lstlisting}[style=Bash]
$ gem install fastercsv
$ gem install mysql --with-path-dir=
\end{lstlisting}

Verzeichnis aller Listings erstellen:
\lstlistoflistings

Export .csv mit Ruby on Rails

Folgendes Plugin ‚fastercsv‘ muss über GEM installiert werden:

gem install fastercsv

Example Code from rubyonrails.org

require 'fastercsv'

class ReportController

  # example action to return the contents
  # of a table in CSV format
  def export_users
    users = User.find(:all)
    stream_csv do |csv|
      csv << ["first","last","id","email"]
      users.each do |u|
        csv << [u.first,u.last,u.id,u.email]
      end
    end
  end

  private
    def stream_csv
       filename = params[:action] + ".csv"    

       #this is required if you want this to work with IE
       if request.env['HTTP_USER_AGENT'] =~ /msie/i
         headers['Pragma'] = 'public'
         headers["Content-type"] = "text/plain"
         headers['Cache-Control'] = 'no-cache, must-revalidate, post-check=0, pre-check=0'
         headers['Content-Disposition'] = "attachment; filename=\"#{filename}\""
         headers['Expires'] = "0"
       else
         headers["Content-Type"] ||= 'text/csv'
         headers["Content-Disposition"] = "attachment; filename=\"#{filename}\""
       end

      render :text => Proc.new { |response, output|
        csv = FasterCSV.new(output, :row_sep => "\r\n")
        yield csv
      }
    end
end