Adding a System Call (kernel 3.8.8)

Registering a System Call Prepare the kernel 3.8.8 source code. First, add the name of the system call you want to add to the end of syscalls_32.tbl as shown below. Remember the number at this time (351 here). Next, write the prototype at the end of syscalls.h. $ cd /usr/src/linux-3.8.8 $ sudo vim arch/x86/syscalls/syscall_32.tbl 351 i356 kanako sys_kanako # Add at the end $ sudo vim include/linux/syscalls.h asmlinkage long sys_kanako(void); # Add at the end System Call Implementation Write the system call implementation at the end of sys....

April 26, 2013

Compiling linux kernel 3.8.8 (ubuntu 12.04)

Notes on compiling linux kernel 3.8.8 on Ubuntu 12.04. Installing Dependent Packages If you plan to do ‘make xconfig’, you’ll need qt3-dev-tools and libqt3-mt-dev. If you plan to do ‘make menuconfig’, you’ll need libncurses5 and libncurse5-dev. Here, I’ll install everything for now. sudo apt-get update sudo apt-get install git-core libncurses5 libncurses5-dev libelf-dev asciidoc binutils-dev linux-source qt3-dev-tools libqt3-mt-dev libncurses5 libncurses5-dev fakeroot build-essential crash kexec-tools makedumpfile kernel-wedge kernel-package Obtaining Kernel Source Next, get the kernel source code from https://www....

April 26, 2013

Ubuntu Installation Notes

Notes from installing Ubuntu 12.04 LTS # Restore the gnome panel from Ubuntu 10.10 and earlier. $ sudo apt-get install gnome-panel # mozc $ sudo apt-get install ibus-mozc mozc-server mozc-utils-gui # chrome $ sudo apt-get install google-chrome-stable # vlc $ sudo apt-get install vlc vlc-plugin-pulse mozilla-plugin-vlc # dropbox $ sudo apt-get install nautilus-dropbox # inkscape $ sudo apt-get install inkscape # git $ sudo apt-get install git $ git config --global user....

April 23, 2013

Brainfuck Interpreter in Ruby

Brainfuck Language Specification This is a quote from Wikipedia. The interpreter consists of the following elements: a Brainfuck program, an instruction pointer (pointing to a character in the program), an array of at least 30000 bytes (each element initialized to zero), a data pointer (pointing to one of the elements in the array, initialized to point to the leftmost element), and two byte streams for input and output. A Brainfuck program consists of 8 executable instructions (other characters are ignored and skipped):...

March 21, 2013

Ruby Summary

I had an opportunity to work with ruby(rails), so I studied it by referring to this page: rubylearning.com up to summary 3. I haven’t read beyond that yet. Indentation Tabs are 2 spaces Method Invocation The following method invocations are allowed. foobar foobar() foobar(a, b, c) foobar a, b, c Everything is an Object Integers and strings are all objects. However, some methods like puts and gets can be used anywhere....

March 20, 2013

Installing Ruby and Rails with Specific Versions

What I want to install ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.2.0] Rails 3.2.11 1. Install rbenv and ruby-build $ brew install rbenv $ brew install ruby-build Here, to load rbenv when bash starts, eval "$(rbenv init -)" add this to ~/.bash_profile. 2. Install Ruby $ rbenv install -l # List of installable Ruby versions Available versions: 1.8.6-p383 1.8.6-p420 1.8.7-p249 1.8.7-p302 1.8.7-p334 1.8.7-p352 1.8.7-p357 1.8.7-p358 1.8.7-p370 1.8.7-p371 1.9.1-p378 1.9.2-p180 1.9.2-p290 1.9.2-p318 1....

March 16, 2013

Analyzing Frequently Used Git Commands with a One-Liner

I wrote a one-liner. history | awk '{ print $2,$3 }' | grep '^git' | sort | uniq -c | awk '{com[NR]=$3;a[NR]=$1;sum=sum+$1} END{for(i in com) printf("%6.2f%% %s %s \n" ,(a[i]/sum)*100."%","git",com[i])}' | sort -gr Here are the execution results. $ history | awk '{ print $2,$3 }' | grep '^git' | sort | uniq -c | awk '{com[NR]=$3;a[NR]=$1;sum=sum+$1} END{for(i in com) printf("%6.2f%% %s %s \n" ,(a[i]/sum)*100."%","git",com[i])}' | sort -gr 32.93% git status 14....

March 13, 2013

Decompiling .NET Applications

I found an interesting tool, so I’ll introduce it. It’s dotPeek. Using this, you can decompile applications created with .NET 1.0 to .NET 4.5 into C# code. 1. Preparation As preparation, I created the following .NET application. It’s a simple program that just checks if the user input is “momoclo” and displays a message box. private void button1_Click(object sender, EventArgs e) { // Password if (textBox1.Text == "momoclo") MessageBox.Show("Success"); else MessageBox....

March 13, 2013

[android] Decompiling Android Apps

Android: Getting source code from an APK file Referring to this page, I decompiled an .apk file (Android app) and extracted Java files, .xml files, and resource files. For the app to decompile, I used this app. Since decompiling someone else’s app seems problematic, I tried it with my own app. Pazuway - https://play.google.com/store/apps/details?id=net.bobuhiro11.puzzleroad Below is the procedure. It’s almost or entirely as described on that page. Step 2: Step 3: I was surprised how easily it could be analyzed....

March 12, 2013

GnuPG Notes

These are notes from installing GnuPG for email encryption. The installation was done via Homebrew. When I searched for gpg in Homebrew, “gpg” and “pgp2” came up, but I didn’t understand the difference, so I used “gpg”. $ brew install gpg Key generation can also be done with a single command “gpg –gen-key”. $ gpg --gen-key gpg (GnuPG) 1.4.13; Copyright (C) 2012 Free Software Foundation, Inc. This is free software: you are free to change and redistribute it....

March 9, 2013

[Android] Published Puzzle Game

I had been developing a puzzle game as an Android app, kind of as a break from my graduation research. Since it was about to be shelved, I published it on Google Play the day before yesterday. Let me introduce it here. The basic rule is that the stick figure needs to reach the goal. There are pitfalls along the way, so it’s not straightforward. Please try it out if you’re interested....

February 22, 2013

[Android] How to Handle GC_CONCURRENT freed

...

January 29, 2013

[Mac] Android App Development Environment

You can probably find this easily by searching (sweat I’ve set up Android app development environments several times, but this is the first time on a Mac. However, it’s not much different from Windows. The environment is OS X 10.8.2 mountain lion. This became a somewhat long article. [bash] tar xzvf eclipse-jee-juno-SR1-macosx-cocoa-x86_64.tar.gz mv eclipse /Applications/ [/bash] That’s it (lol) So simple ...

January 8, 2013

I bought a MBA!

I bought a MacBook Air! I’ve been wanting one for a long time, and I finally got my hands on it. A new Mac user is born! I’m planning to set up my environment from now on. I’m quite satisfied with how I can edit text with ctrl-h, ctrl-f, ctrl-b, etc., how I can use Unix commands, and how the trackpad feels amazing - all very different from Windows. However, because of sweaty hands, the trackpad sometimes doesn’t work well, so I need to find a good solution for that....

January 3, 2013

Text Classification with SVM

Happy New Year. Thank you for your continued support this year. I tried out SVM (Support Vector Machine), so I’ll write down the method. Like Naive Bayes, it can classify text. Here, I used svm_light. cd /usr/local/src mkdir svm_light cd svm_light wget http://download.joachims.org/svm_light/current/svm_light_linux.tar.gz gunzip -c svm_light.tar.gz | tar xvf - make all After installation, add /usr/local/src/svm_light to your PATH. 1 i am happy 1 happy happy new year -1 bad year -1 i am bad Next, create a correspondence table between each word and a number....

January 1, 2013

Using mecab with php.

I had to do morphological analysis, so today I installed the morphological analysis engine mecab and made it available from php. Here’s the procedure. I got stuck especially with the php_mecab part. During “make check” =================== 1 of 3 tests failed =================== make[2]: *** [check-TESTS] Error 1 make[2]: Leaving directory `/usr/local/src/mecab-0.98/tests' make[1]: *** [check-am] Error 2 make[1]: Leaving directory `/usr/local/src/mecab-0.98/tests' make: *** [check-recursive] Error 1 I got such an error, but it seems to be okay to not worry about it....

September 26, 2012

Monitoring logs with logwatch.

When you set up your own server, you need to constantly monitor logs to prevent attacks, but checking them one by one is tedious, so I use a software called logwatch. When you install logwatch, it compiles and emails logs every night. This is an actual email I received. (It’s been heavily edited) The installation procedure is as follows. sudo yum install iptables cat /etc/logwatch/conf/logwatch.conf It probably says something like...

September 22, 2012

When scanned past exams are too light

When scanning past exams, older scanners may not allow you to specify density, causing the text to become light. So I wrote a script that can be used when you’ve scanned something but the text is too light to read. It just binarizes PDFs, but it works quite well like this. As preparation, install ImageMagick. wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz tar xvf ImageMagick.tar.gz cd ImageMagick-6.7.9-6/ ./configure make make install Once installed, write the following code to an appropriate file (here called ScanDataConvert....

September 17, 2012