blog

My blog at www.shimmy1996.com

git clone git://git.shimmy1996.com/blog.git

2014.org (4458B)

    1 #+HUGO_BASE_DIR: ../
    2 #+HUGO_SECTION: ./posts
    3 #+OPTIONS: author:nil
    4 
    5 * DONE Linux Only Boots Under Recovery Mode
    6 :PROPERTIES:
    7 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :date 2014-02-09 :slug linux-only-boots-under-recovery-mode
    8 :END:
    9 
   10 ** DONE en
   11 :PROPERTIES:
   12 :EXPORT_TITLE: Linux Only Boots Under Recovery Mode
   13 :EXPORT_FILE_NAME: 2014-02-09-linux-only-boots-under-recovery-mode.en.md
   14 :END:
   15 
   16 This is part of the Plan.
   17 
   18 I tried to install linux for my PC, and tried all sorts of distributions, including the most recent 3-4 versions of Mint and Ubuntu, but all of them (including live CD mode) only runs under recovery mode (with really low resolution and software-only rendering), which makes me MEGA unhappy. When I tried to boot them normally, all I get are black screens, or more precisely, purple screens.
   19 
   20 After consulting online, I found that the only special thing about recovery mode is that it added =nomodeset= and =xforcevesa= into the =GRUB_CMDLINE_LINUX= parameter of grub file located at =/etc/default/grub=.
   21 
   22 So, basically, the problem was solved by finding out which of the two parameters recovery mode added into  =GRUB_CMDLINE_LINUX=  made the system bootable again. It turned out it was the =xforcevesa= that solved the problem, and here is what I did:
   23 - If the live CD mode failed to load, enter the recovery mode of live CD. (Mint by directly selecting the second option, Ubuntu by pressing F6)
   24 - Now you should be able to get into the system no matter what happens to your system before. Install them as usual, and use "logical partition" since this is probably the second system on the PC. Install the boot on the entire hard drive.
   25 - Restart and get into the system in recovery mode (second option in grub, select =continue= when option menu occurs). Open the terminal, and here's the most important part:
   26 #+BEGIN_SRC sh
   27   sudo gedit /etc/default/grub
   28 #+END_SRC
   29 - Edit the grub file, replace the parameter in =GRUB_CMDLINE_LINUX=<PARAMETERS>= to =xforcevesa=, save and close the file. Hold on, we are not done yet, always remember to:
   30 #+BEGIN_SRC sh
   31   sudo update-grub
   32 #+END_SRC
   33 
   34 Then, restart your computer and you should be able to boot the system normally.
   35 
   36 Great, problem solved! Wow, very Mint, so Ubuntu.
   37 
   38 There is still another thing bothering me, though, that is I can only boot into system successfully without any USB devices plugged in, which is superconfusing. I will try to figure this out.
   39 
   40 * DONE The Quest to Hash Table
   41 :PROPERTIES:
   42 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :date 2014-07-11 :slug the-quest-to-hash-table
   43 :END:
   44 
   45 ** DONE en
   46 :PROPERTIES:
   47 :EXPORT_TITLE: The Quest to Hash Table
   48 :EXPORT_FILE_NAME: 2014-07-11-the-quest-to-hash-table.en.md
   49 :END:
   50 
   51 Several mistakes I made when I tried to write a hash program using C.
   52 
   53 1. A pointer that points to a pointer that points to a pointer that points to a pointer that points to a...
   54 
   55   Generating an array of pointers is the core step when creating a hash table, but the malloc function and the pointer part can be a little bit confusing. There are, however, general rules for this:
   56 
   57   - How many =*= s we put before a variable tells us how many dereferences we need to get the original type we want. If we want to make an array of =*node= (or some other pointer/type of variables), then we should add one extra =*= when declaring the array: =node **node=;
   58   - General formula for using malloc to collect an array containing =NSLOT= pointers to node: =array_of_pointers = (node **)malloc(NSLOTS * sizeof(node *))=. The rule still holds if we add more =*= to each node or subtract =*= simultaneously: =array_of_pointers = (node ***)malloc(NSLOTS * sizeof(node **))=.
   59 
   60   Do note that =array_of_pointers = (node **)malloc(NSLOTS * sizeof(node *))= is equivalent to =node **array_of_pointers = malloc(NSLOTS * sizeof(node *))=.  Don't be afraid to use index on objects created this way: it's fine...
   61 
   62 2. Be mindful when you add node to one of the linked lists, more so when you are freeing it. Do note that, when you are checking whether a key is already present in the hash table, if a the key already exists in the hash table, you will have an extra copy of the key. Make sure it is freed. Also do not forget to free the key afterwards.
   63 
   64 Apologies if this seemed unfinished XDD.
   65 
   66 I started writing this stuff five months ago and just did not got a chance to finish it till now... Tried to pull off some points from the original code I had, but this is pretty much all I got now XDD.