Samstag, 12. Dezember 2015

Copying files with socat



  1. Start to listen on one node. The following command will pipe everything it gets into the file out.txt. It blocks until it read EOF. So we're listening on tcp port 9999.
    sudo socat tcp-listen:9999 OPEN:out.txt,creat
  2. After you startet the receiver, you might read from a file and pipe into a socket to your receiver. Now we're sending to localhost (127.0.0.1) at port 9999, our unnamed0.graphml.
    socat file:unnamed0.graphml tcp:127.0.0.1:9999

Sonntag, 29. November 2015

Youtube - How do i buffer a complete video?

Most people know now, that youtube videos do not fully buffer anymore. You're buffering about ~15sec. In many cases, this isn't enough.

So, how do i buffer from now on?
Actually, you only need to change the URI. An other player opens, which is able to buffer your video. In general your URI looks like this:

    https://www.youtube.com/watch?v={ID}

You need to change the URI to:

    https://www.youtube.com/v/{ID}?version=2

For instance:

    https://www.youtube.com/watch?v=zeT_5VvGNlM

To:

   https://www.youtube.com/v/zeT_5VvGNlM?version=2

Enjoy your videos in HD!

Cheers,
Ellks

Montag, 19. Oktober 2015

ArchLinux - Maude


  1. Download the latest version of maude:
    http://maude.cs.illinois.edu/w/index.php?title=Maude_download_and_installation
  2. Export the *.zip by typing unzip ~/Downloads/Maude*
  3. Go into the exported directory.
  4. Run the file maude.linux64

Troubleshooting:
  • Programm does not start and does not find libtinfo.so.5. Note we're referencing a lib which might has a similar name. Show yourself all similar libs with ls /lib64 | grep libncurs.
    cd /lib64
    sudo ln -s libncursesw.so.6.0 libtinfo.so.5

Mittwoch, 7. Oktober 2015

From Java to C# - A few notes


  • You might instantiate a generic class like a normal array:
    List<T> mylist = new List<T>() { t1, t2, t3, ..., tn};
  • LINQ - Language Integrated Query
    • Queries for different DBs, XML, Generics
  • Properties
    • These are easy written accessors
    • Futhermore an easy possiblity to convert information
      • e.g. we store seconds in our time class
      • you might write a property which allows you to simulate an other variable, like hours
        which still relays on the seconds.
      • public string Name
        {
          get { return ...; }
          set { ... = value;}
        }
  • Only functions noted with the keyword virtual might be overwritten.
  • Override is a keyword, not an annotation
  • Javas super is C#s base
  • You must to append an f to your float
    • float f = 3.141f
  • There is a special keyword var
    • var is a type which is determined at compile-time. So it can't change on run-time!
    • var v = (new List<int>() {1,2,3})[0];
      • v has the type int now
    • You might use var in foreach
  • foreach (Type t in Collection) is javas for (T t : Collection)
  • All types are objects!
    • There are two subtypes:
      • Valuetypes
      • Referencetypes
  • There is not multiple inheritance.
  • You implement interfaces and super classes in the same way:
    • class sub : super
      {
        // ...
      }
    • class implementation : interface
      {
        // ...
      }
  • There a different types of lambdas:
    • Action<T1, ..., Tn>(...) which maps on void
    • Func<T1, ..., Tn, Tresult>(...) which maps on given type Tresult
  • Futhermore there are two keywords for easy threading:
    • await
    • async




Dienstag, 6. Oktober 2015

Edit Markdown with vim like a king!

When i did start writing Markdown files, it was for my projects on github. After editing on githubs webpage, i was using vim at local repositories.

After a short time, i figured out that chromium has a Markdown interpreter. It's called MarkDown Preview Plus. I installed it because of the following features:

  • It can read local files.
  • On the fly refresh - When you edit your markdown file and store it, the interpreter upgrades the view automatically. 

After i installed the file, i was wondering if i couldn't bind chromium to a vim hotkey.

So i added this line to my .vimrc:
autocmd BufEnter *.md exe 'noremap <F5> :! chromium %:p<CR>'

This line binds the key F5, on files ending with .md to chromium. So, when you press F5 chromium opens and the Markdown Preview Plus interprets the file.


Dienstag, 15. September 2015

C# - Mono with MySql Connector under Linux



  • I assume you already installed the mono runtime.
  • Your logged in on your Linux machine.
  • You did open a terminal.

  1. Download the .NET/mono assembly, provided by oracle.com.
    http://lmgtfy.com/?q=c%23+mysql+connector
  2. Unzip the files.
  3. Enter the v2.0 folder.
  4. Open a terminal.
    I'm not sure what the different versions are. When you know it, fell free to leave a comment.
  5. Now you add the "MySql.Data.dll" assembly to the runtime assemblies.
    sudo gacutils -i MySql.Data.dll
That's it usually. Well, i had some permission trouble. You might go to the directory /urs/lib/mono/gac/MySql.Data/ and look in the subfolder for your added assembly MySql.Data.dll. Here you might type ls -l to show your permission on the file. Type chmod +rx MySql.Data.dll. With this you granted yourself and all other users of your computer the permission to read the file and execute it.

Make sure to add the references System and System.Data to your project.

Freitag, 28. August 2015

Running tasks in command background

When you're connected to a server via. ssh, you might have trouble running processes asynchronous. Following i wan't to show a few commands, which allow you to pause a process, move it to background, continue the process in back or foreground and let it even continue, when the shell closes.

All commands listed below:
  • jobs - shows all current processes.
  • bg %jobid - continue job in background.
  • fg %jobid - bring background process into foreground.
  • ctrl+z - in terminal shown as ^Z; pauses current process and moves it to background.
  • disown %jobid - removes the process from table of active processes. 
First of all i show you how to start a process in background. It runs until it needs input from command line. To do so, you might type cp extremelargefile ../ &.

[1]  + suspended (tty input)  cp extremelargefile ../ &.

When the process suspended and you wan't to continue it in foreground, on terminal, you might type fg %jobid. To figure out the jobid you might type jobs. All current gets listed then.

A process is running, e.g. cp. There might be a situation that you copy a large file and forgot to add & to the command. So you're running the process in foreground. To suspend the process and bring it to background you might press ctrl+z. When you wan't the process to ran further, type bg %jobid. As already told, you can bring this process back to the front by typing fg %jobid.

For example:
> cp extremelargefile ../
^Z
zsh: suspended  cp extermelargefile ../
> jobs
[1]  - suspended (tty output)  cp extremelargefile ../
> bg %1
[1]  - continued (tty output)  cp extremelargefile ../
> fg %1
[1]  + continued (tty output)  cp extremelargefile ../