Tuesday, April 14, 2015

Cheryl's Birthday Quiz




So here is the question I copied from the Internet:
Albert and Bernard just met Cheryl. 
“When’s your birthday?” Albert asked Cheryl. 
Cheryl thought a second and said, “I’m not going to tell you, but I’ll give you some clues.” She wrote down a list of 10 dates: 
May 15 — May 16 — May 19
June 17 — June 18
July 14 — July 16
August 14 — August 15 — August 17 
“My birthday is one of these,” she said. 
Then Cheryl whispered in Albert’s ear the month — and only the month — of her birthday. To Bernard, she whispered the day, and only the day. 
“Can you figure it out now?” she asked Albert. 
Albert: I don’t know when your birthday is, but I know Bernard doesn’t know, either. 
Bernard: I didn’t know originally, but now I do. 
Albert: Well, now I know, too! 
When is Cheryl’s birthday?

At the first glance the question is very difficult. 
How can Bernard get the answer by Albert's seemingly irrelevant clue? 

After a little bit thought, and observing the dates more carefully, we found that Albert actually gave out a very important clue that was clearly enough to eliminate quite a few dates. Then Bernard's clue, combined with what Albert already knew, led to the right answer.

What is the logic?

Keep reading, on the next page,














Observe the days first, there were two 14s, 15s, 16s, 17s, but only one 18 and one 19. Therefore, if Albert was told the month and he was SURE Bernard did not know the answer, the month would not be May nor June. Because if he heard May or June, then it was POSSIBLE that the birthday was May 19th or June 18th, in which case Bernard would know the birthday immediately by hearing the day. Albert was sure Bernard did not know the birthday. So, the month Albert heard could not be May or June. It must be July, or August.

Now Bernard knew the month could be either July or August. Let's look at the dates: 
July 14 — July 16
August 14 — August 15 — August 17 

Since Bernard knew the birthday, the day could not be 14 because it occurs twice. Until now, my dear reader, if you think "Oh, then it can be 15, 16, or 17, how can we know which one? ", then you are falling to the same trap I have. You missed the fact that Albert KNEW the month! 

The question we should answer is: how come Albert knew the birthday after Bernard knew!? 

Because he heard July! 

If he had heard August, he would not say "Now I know"! 

Therefore, the birthday is July 16th.

Saturday, April 04, 2015

Jackie's Blog About Random Stuff: Saturday, April 4

Jackie's Blog About Random Stuff: Saturday, April 4: On Thursday, I went to a trampoline park called Launching Pad. I went with my friend Ruiyang. It was very fun. There were many trampolines t...



Jackie came back complaining about a super stiff neck. He seemed can not move his arms or turn his necks. He was very reluctant to go to the swimming practice that evening. We went there anyway. To our surprise, the swimming class was canceled because of Good Friday! He was relieved.

Wednesday, April 01, 2015

Jackie's Blog About Random Stuff: Wednesday, April 1

Jackie's Blog About Random Stuff: Wednesday, April 1: Today, I got a thousand dollars! Just kidding, April fools! So today's conversations went kind of like this: 1: Hey! 2: What. *i...



This blog is one of the better blog Jackie wrote. It is amusing to see the chaos during his lunch time, because it reminds me of my high school.



At that time, lunch was a chaos. During lunch time, there were about 250 and more students released exactly at 11:55. It started with a race from the classroom, crossing a small woods to the cafeteria. (Yes, my school was one of the largest in the city). Everyone wanted to be the first one in the line, because there was no line after the first few. All the students will crowded in front of four windows serving foods and formed a dense body pack. Everyone forced into the pack, squeezed along with it until he could hold on the frame of the window with one hand, and used the other hand to buy food. Then he would use both hands to hold the bowl of food above the head in the air, and squeeze out of the big crowd of hungry students.



It was fun!


Friday, March 06, 2015

Mobile

Installed blogger for iPhone. Nice. 
Will resume my writing practice now 

Friday, November 26, 2010

Chinese in FreeBSD revisit

I have some experience on setting up a Chinese desktop with FreeBSD 4.3. Now with 8.1, seems need some enhancement and modification to make it work again.


  1. Chinese Environment. It is really not necessary to change the .login_conf. Read the login_conf man page, all it does is to setup the environment variables. So one just need to add the following three lines into .cshrc. (if csh is used):

    setenv XMODIFIERS "@im=scim"
    setenv LANG zh_CN.UTF-8
    setenv LC_ALL zh_CN.UTF-8
    

  2. Notice above two things. First, I use scim as chinese input method. Second, I use zh_CN.UTF-8 as encoding
  3. The most important part is the display of fonts. 
    1. Chinese font. First thing I did is to install WenQuanYi true type fonts. It provided some good fonts. WenQuanYi Micro Hei, and WenQuanYi Bitmap Song are the two I used.
    2. Create .fonts.conf in home directory:
    3. <?xml version='1.0'?>
      <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
      <fontconfig>
          <!--
            install ==> print/freetype2 [WITH_LCD_FILTERING=yes and assumes BCI not disabled]
            install ==> x11-fonts/dejavu
            install ==> x11-fonts/webfonts
            install ==> x11-fonts/terminus-font
        -->
          <!-- preferred aliases -->
          <alias>
              <family>serif
              <prefer>
                  <family>DejaVu Serif
           <family>WenQuanYi Micro Hei
           <family>WenQuanYi Bitmap Song
              </prefer>
          </alias>
          <!-- preferred aliases -->
          <alias>
              <family>sans-serif
              <prefer>
                  <family>DejaVu Sans
           <family>WenQuanYi Micro Hei
           <family>WenQuanYi Bitmap Song
              </prefer>
          </alias>
          <!-- preferred aliases -->
          <alias>
              <family>monospace
              <prefer>
                  <family>DejaVu Sans Mono
                  <family>Terminus
           <family>WenQuanYi Micro Hei
           <family>WenQuanYi Bitmap Song
              </prefer>
          </alias>
          <!-- default quality settings -->
          <match target="font">
              <edit mode="assign" name="rgba">
                  <const>none
              </edit>
              <edit mode="assign" name="antialias">
                  <bool>true
              </edit>
              <edit mode="assign" name="autohint">
                  <bool>true
              </edit>
              <edit mode="assign" name="hinting">
                  <bool>true
              </edit>
              <edit mode="assign" name="hintstyle">
                  <const>hintfull
              </edit>
          </match>
          <!-- reduce ringing ==> requires freetype2 'WITH_LCD_FILTERING=yes' -->
          <match target="font">
              <edit mode="assign" name="lcdfilter">
                  <const>lcdlight
              </edit>
          </match>
          <!-- disable autohinting for bold fonts -->
          <match target="font">
              <test compare="more" name="weight">
                  <const>medium
              </test>
              <edit mode="assign" name="autohint">
                  <bool>false
              </edit>
          </match>
          <!-- disable autohinting for fonts that don't need it -->
          <match target="pattern" name="family">
              <test name="family" qual="any">
                  <string>Andale Mono
                  <string>Arial
                  <string>Arial Black
                  <string>Comic Sans MS
                  <string>Courier New
                  <string>Georgia
                  <string>Impact
                  <string>Trebuchet MS
                  <string>Tahoma
                  <string>Times New Roman
                  <string>Verdana
                  <string>Webdings
              </test>
              <edit mode="assign" name="hinting">
                  <bool>true
              </edit>
              <edit mode="assign" name="autohint">
                  <bool>false
              </edit>
          </match>
      </fontconfig>
      
    4. Terminal, use urxvt and set the font as:
      urxvt -fn 'xft:dejavu sans mono:size=9,xft:wenquanyi bitmap song:size=9'

Friday, November 12, 2010

Setup Xorg Intel DVI 1920x1200 on Sceptre Monitor

    The FreeBSD box I have is very nice. Except one thing: I cannot get native 1920x1080 resolution with a DVI connection to the 24" display I have (Sceptre X24WG). On VGA, it works but the screen looks very blur.

    When I connect the monitor through DVI, if I do not set the Modes to 1920, it automatically configures 800x600. If I set the mode to 1920x1200, it blacks out.

    Then I found this link from mythtv: http://www.mythtv.org/wiki/Modeline_Database that has a section on the mode line for Scepre X37SV-Naga.


## (37" 1920x1080 60Mhz native resolution LCD)
## Using Nvidia FX5200 DVI->HDMI cable connected to the LCD
## I had to use the following options for any modes greater than 1280x1024 to work when using the DVI->HDMI 
## output, I didn't need these options for VGA output to the LCD.
#   Option "ModeValidation" "NoMaxPClkCheck, NoEdidMaxPClkCheck"
#   Option "UseDisplayDevice" "DFP"
#
#   Modeline for the LCD's native resolution
#   ModeLine "1920x1080p" 148.500 1920 2024 2072 2200 1080 1084 1094 1124 -hsync -vsync


I give it a try and bang! It works!

Actually, the problem appeared again. I think it is because I am using a Mini-ITX motherboard that has an LVDS interface. That seems like a main interface. The DVI interface, seems like an external interface. 8 out 10 times when I startx, monitor became blank. I found a word around is to Ctrl-Alt-<F1> to switch to text mode, then Alt-<F9> to switch back to video mode. That worked around the problem.

Also, if the monitor ran into sleep mode, I also need to do the same thing to make it work. Or, I can turn off the monitor then turn it back on, which also bring back the video display.

Really hope Xorg or FreeBSD or Intel driver, which ever will have this issue fixed.

Tuesday, November 09, 2010

Setup Netgear Printer Server WGPS606 with FreeBSD

Here is the steps to configure FreeBSD to use an HP LaserJet printer on Netgear WGPS606.


  1. Add lpd_enable="YES" in /etc/rc.conf
  2. Add these lines to /etc/printcap
    lp|hp|laserjet|HP LaserJet 3015 on WGPS606:\
        :sh:\
        :rm=192.168.1.110:rp=L1:sd=/var/spool/lpd/hp:lf=/var/log/lpd-errs:\
        :if=/usr/local/libexec/ifhp:
    

    In my setup, the IP address of WGPS606 is 192.168.1.110 and the printer is connected to the first USB port. Therefore, the rm in the printcap is 192.168.1.110 and the rp is L1. If a printer is connected to the second USB port, then rp should be L2.
  3. Now let's copy the hp filter:
    cp /usr/local/share/examples/printing/ifhp /usr/local/libexec/ifhp
  4. We need to make the filter executable by all:
    chmod 0555 /usr/local/libexec/ifhp
  5. Now create the printer spool folder.
    mkdir /var/spool/lpd/hp
  6. Don't forget to start lpd by:
    /etc/rc.d/ldp start
  7. Print a test page: lpr -P hp test.txt
  8. If printing does not happen at all, tail -f /var/log/lpd-errs to see what is going on.