Dependent Origination

Archive for the ‘电脑’ Category

It was my first time solving a programming related problem yesterday, in over six years since I retired 🙂

The problem is how to get all the comments of this post. It is a post about a sick monk who has been in ICU for over a week. The post is asking for prayers and messages for him. And it got 800+ comments. So we want all the comments out of Facebook so that they can be read to the monk.

First things first, we did it, and for free. Below you can find some main steps about how.

  1. Graph API Explorer is a very good tool.  Use it. Explore its functions. I got all the comments by using it.
  2. This Reddit post from two years ago helped me get started greatly. At least, it tells me that this is a task that can be finished with a single HTTP GET.  And it has an example link (https://graph.facebook.com/244944385603396_1599585250139296/Comments) that I can directly copy in the API explorer. Hope!
  3. Bummer! It didn’t work. However, by checking out the explorer interface, the focus was soon on access token.
  4. Now, the entire game is about how do you generate an access token that the API is happy to accept and then give you all the comments.
  5. Use the account that is the Page admin. Three blue dots, you can play with their contents to get the desired access token. Don’t forget to “generate a token” again any time you change something.
  6. The final selection: “Page Comments” (app name), “get_app_token” (token type), “pages_read_user_content” (permission)
  7. Now we got comments!
  8. But not all of them? Change the “limit” parameter (in the top left window of the API explorer).
  9. And you can even select fields that you want in the JSON results.

Other helpful notes.

  1. If I use the “user token” to get comments, I can only get comments made by me. It will tell me how many comments are out there, but it will only return those comments made by me. The debug message reads it is a privacy issue.
  2. Cannot get the commenters’ names or user_id’s. “from” field is grayed out. I figure it must be the design of the api only to return aggregate information, with no identifying power.
  3. How to get your post id? Click on the published time under the post in your feed. It will go to another page. The url has the post id. You can safely ignore those Google analytics fields after the post id.
  4. Use filter (stream) can return comments in chronological order. “summary” in chronological order probably won’t work as you want.
  5. limit = 1000 then we got all 800+ comments in one go. No need to do pagination.
  6. Huge amount of thanks to two error messages. One tells me that I need an app token to continue. This (and looking at the interface for a long time) made me realize that I can change app name and token type, so the game could keep on going. Another error message tells me that manage_pages is deprecated and leaves me a link in documentation to read about it. Reading the documentation (and looking at the error message and interface, back and forth, for a long time) made me realize I don’t need to change the token type from app token to page token, I only need to change the permission type. Two significant steps in figuring out the final parameters. Hooray for those who write error messages with a compassionate heart 🙂
  7. It is ok to feel frustrated along the way. But press on. I can do it. Just need to calm down and think. Or look at it, for a long time 🙂
  8. later command used to get the comments from JSON result: grep “message” comments_raw.txt | cut -d: -f2 > comments.txt
  9. user friendlier way: JSON -> CSV

Ever feel the despair that it is the last day to submit the application but the website requires you to scroll to the bottom of an agreement before you can click “agree”, and you cannot seem to make the scroll work because the agreement is a text area embedded on a web page and you seem can only scroll the entire page?

Remember: Select, then Shift + up/down to scroll the text area

1. send yourself an email (through gmail)

2. go to the gmail mobile site (not the gmail app, there is no way opening the file in any other way inside the app), but on the mobile site, you can long hold onto the file, and open it in another safari window, and then at the top of the window, there is “Open In…” option

3. choose wechat from the list of options and then you can choose which contact to send it to

RC (raidcall) is YY/GoToMeeting of Taiwan. Unfortunately I need to use it and its only versions are for Windows/Android. The solution is to use a Windows VM on Mac and install RC onto the VM.

1. Install VirtualBox on Mac

2. Find a copy of Windows XP. It would be a lot harder to find a copy of Windows 7 without a product key.

3. Create a VM in VirtualBox, Windows XP 64 bit for example. You need to pick the correct network interface card in the settings. The default ‘Intel’ one doesn’t really work. Pick the ‘AMD’ one. Otherwise your VM will not be able to access the internet.

4. Install Windows XP. The installation can read from an iso file since the installation is controlled by VirtualBox/Mac and Mac has native support of treating iso file as cd drive.

5. However, we can still download a copy of RC from the MAC and share the executable with the VM. To achieve this, you need to install Guest Additions first inside the VM. Then create the folder on the Mac and then in the settings of VM create a shared folder. If your network is set up correctly, which you can test by trying to ping the host machine from the VM, you should be able to see a Network Drive in the VM and that is the shared folder from the host.

6. Download RC and move it to the said shared folder on the host.

7. Download a small mount tool from Microsoft so that you can mount the iso file of Windows XP as a drive, so when you install the east asian language pack, you can tell the installer to read from that drive.

8. From Windows VM, install multi-language package (east asian language package).

9. Bingo, now you can install RC. The copy from rc’s website works fine. I heard sometimes you have to check whether the copy of RC you are installing are talking to Taiwan’s servers or America’s servers. Luckily the copy I installed worked right off bat and I can get into the group I want.

10. Pat yourself on the back and you deserve a break. I figured all these out in two days’, about five to six hours of googling mostly, with practically zero real knowledge on how VMs work. Another few hours if you count the download time of all software involved.

this page explains it well

basically, you need a small tool (unofficial software from microsoft) so that you can mount an ‘iso’ file as a drive and then you can install things from it when xp asks for a cd.

it copies a driver file (.sys) into system directory and then a small executable to mount and unmount for you.

easy.

Greetings from Windows XP inside VirtualBox!

When you create the virtual machine, you have to be careful of the network settings. For me, I choose ‘Bridged Adapter’ (this means the VM will be another computer on the same LAN as the host). *And* choose ‘PCnet-FAST III’ in the advanced settings part. The default ‘Intel’ option won’t work.

Now at least the vm can ping the host. Running ‘ipconfig’ on the vm will list some network interface information too. The shared folder finally shows up in ‘My Computer’ as ‘Shared Network Drive’. The world can go on now.

$ tar -cvf test.tar.gz directory_name

$ split -b 5M test.tar.gz prefix

you can use -d option to name the pieces with numbers. default this will name the components aa ab…az ba… etc

to join this file, we can use cat command.

$ cat prefix* > test.tar.gz


May 2020
M T W T F S S
 123
45678910
11121314151617
18192021222324
25262728293031

Twitter

  • is loving shelter-in-place, in fact 2 days ago
  • is sleeping much better during shelter-in-place 2 weeks ago
  • is emotionally ready for the next chapter of life 7 months ago
  • is memorizing Himalaya keyboards and learning to type Tibetan. So exciting. Chinese, English, Spanish, now my fourth language Tibetan! 8 months ago
  • this is a special summer 11 months ago

Flickr Photos