Actually, philosophers call that the Oenophile's Quandary! Presented with something that, over time, increases in quality (like wine) or in value (like money in a savings account), when's the right time to use it?
Tuesday, August 02, 2016
Sunday, July 10, 2016
emacs and installing packages over TLS
I find this article very useful. It walks you through setting up Emacs to download ELPA/MELPA packages over TLS, and also verifying the certificates.
various configs
I might as well put them in one place.
Emacs (from trunk):
./configure --without-pop --with-x-toolkit=lucid \ --prefix=/usr/local/src --without-toolkit-scroll-bars \ --without-compress-install --with-file-notification=yes \ --with-wide-int --with-modules
XScreenSaver:
./configure --with-gl --with-gle --with-xft --with-xshm-ext \ --with-pixbuf --with-xdbe-ext --with-readdisplay \ --with-browser=/usr/bin/firefox
SBCL (1.3.x):
sh ./make.sh --fancy --with-sb-fasteval --without-sb-eval
nvi:
export EXINIT="set noeb sm verbose ruler showmode"
GTK:
~/.gtkrc-2.0:
gtk-key-theme-name = "Emacs" include "/usr/share/themes/Emacs/gtk-2.0-key/gtkrc" gtk-entry-select-on-focus = 0
~/.gtkrc-3.0:
gtk-key-theme-name = "Emacs" include "/usr/share/themes/Emacs/gtk-3.0/gtk-keys.css"
~/.config/gtk-3.0/settings.ini:
[Settings] gtk-key-theme-name = Emacs
lein:
~/.lein/profiles.clj:
{:user {:plugins [[cider/cider-nrepl "0.12.0"] [lein-pprint "1.1.2"] [lein-droid "0.4.4"] [venantius/ultra "0.4.1"] [lein-ancient "0.6.10"]]} :repl {:dependencies [^:displace [org.clojure/clojure "1.8.0"]]} :android-common {:android {:sdk-path "/home/fn/android-sdk"}}}
Sunday, January 10, 2016
Monday, November 16, 2015
Monday, April 13, 2015
Taxpayers in Pakistan
Pakistan's FBR, the tax collectors, recently published a PDF file with a list of all tax payers, both corporate and individual. (There's also a third category of "AOPs" -- whatever that is.) The file is linked off of the front page of the website.
I downloaded a copy of the file and used pdftotext (from xpdf) to convert it to a more pliable format, and then went to town. The conversion process wasn't perfect (tabular data doesn't always convert to one PDF row to one text row; see also the disclaimer at the bottom), but it's very easy to figure out the format by visually comparing it with the source.
(Side note: if I'd tried to import it into Google Sheets or Excel, maybe the conversion would've been better.)
Read the file from the string "COMPANY Taxpayer" until you see "332024095867"at the beginning of the line. That's the CNIC for the first individual listed in the file (listed as "#OHD ,NAWAZ"-- what does that say about their data validation procedures?).
Extract all strings in the format <digits>-<digit>. Those are company NTNs.
There are 64,960 companies in the file.
Extract all strings that are 13 digits long. Those are CNICs.
There are 779,077 taxpayers in the file. That's an average of 11.993 taxpayers per company.
How about taxes paid? (There are so many Rs 0 entries!) This is a little harder to extract. For companies: find a line that has NTNs in it, skip the next blank line, then read the taxes lines until you reach another blank line. Unfortunately, there's a problem with this approach: I should read 64,960 entries, but I read 64,886. Close enough!
Companies paid a total of Rs 376,174,769,305. 25,464 paid nothing.
People next, using a similar approach. I found 766,791 entries.
Individuals paid Rs 113,663,076,659 and 294,475 paid nothing.
DISCLAIMER: Because the conversion process isn't completely accurate my numbers are off by a bit. Also there's a lot of garbage in the file -- name fields with numbers before the names; CNIC fields that are empty or are six or seven digits long, etc.
I downloaded a copy of the file and used pdftotext (from xpdf) to convert it to a more pliable format, and then went to town. The conversion process wasn't perfect (tabular data doesn't always convert to one PDF row to one text row; see also the disclaimer at the bottom), but it's very easy to figure out the format by visually comparing it with the source.
(Side note: if I'd tried to import it into Google Sheets or Excel, maybe the conversion would've been better.)
Read the file from the string "COMPANY Taxpayer" until you see "332024095867"at the beginning of the line. That's the CNIC for the first individual listed in the file (listed as "#OHD ,NAWAZ"-- what does that say about their data validation procedures?).
Extract all strings in the format <digits>-<digit>. Those are company NTNs.
There are 64,960 companies in the file.
Extract all strings that are 13 digits long. Those are CNICs.
There are 779,077 taxpayers in the file. That's an average of 11.993 taxpayers per company.
How about taxes paid? (There are so many Rs 0 entries!) This is a little harder to extract. For companies: find a line that has NTNs in it, skip the next blank line, then read the taxes lines until you reach another blank line. Unfortunately, there's a problem with this approach: I should read 64,960 entries, but I read 64,886. Close enough!
Companies paid a total of Rs 376,174,769,305. 25,464 paid nothing.
People next, using a similar approach. I found 766,791 entries.
Individuals paid Rs 113,663,076,659 and 294,475 paid nothing.
DISCLAIMER: Because the conversion process isn't completely accurate my numbers are off by a bit. Also there's a lot of garbage in the file -- name fields with numbers before the names; CNIC fields that are empty or are six or seven digits long, etc.
Monday, February 16, 2015
apt-cache
The other day I was helping a co-worker set up Ubuntu in VirtualBox, to simulate the production servers. At one point, I told him to search for a package by typing "apt dash cache space search space dash n space ..."
He types it in and says, it didn't work. I walk over to check his display. He's written "apt-gash search -n ..."
I say "You didn't take pre-med in college, you studied CS! It's apt-cache, not apt-gash!" He didn't understand what I meant.
So he corrects it, and types in "apt-cash search -n ..."
He types it in and says, it didn't work. I walk over to check his display. He's written "apt-gash search -n ..."
I say "You didn't take pre-med in college, you studied CS! It's apt-cache, not apt-gash!" He didn't understand what I meant.
So he corrects it, and types in "apt-cash search -n ..."
Sunday, January 18, 2015
change in brent crude and lahore gasoline prices in 2014
Oil prices have fallen worldwide. I wanted to see how much of that drop is reflected in the price I pay for gasoline at the pump. Is the cost of filling my tank dropping at the same rate as crude oil?
Summary: calculated against January 1, 2014's prices, on January 2, 2015 the drop in crude is 49.08% and the drop in my local prices 30.48%.
I downloaded the Brent crude prices for Jan 1 2014 to Jan 2 2015, and grabbed the fields I wanted:
$ awk -F, 'BEGIN { OFS="," } { print $1, $5}' ~/Downloads/CHRIS-ICE_B1.csv | tail -r > crude.csv
$ head crude.csv
2014-01-01,110.8
2014-01-02,107.78
2014-01-03,106.89
2014-01-06,106.73
2014-01-07,107.35
2014-01-08,107.15
2014-01-09,106.39
2014-01-10,107.25
2014-01-13,106.75
2014-01-14,106.39
$
There are several gas stations on my way to work, but only two Shell stations that I can get to without making a U-turn. For the local gasoline prices, I visited the regulator (OGRA)'s site and grabbed the prices for Shell. I saved the PDF files and did
for i in *.pdf; do
pdftops $i - 2>/dev/null | ps2ascii - ${i%pdf}txt
echo done with $i
done
pdftops ships with xpdf and ps2ascii with Ghostscript. It's not a perfect process, but close enough:
$ grep 'LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD' *.txt
1388983409-201401.txt:386 LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 113.25 117.24 na
1391506062-201402.txt:383 LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 113.25 117.24 na
1393998747-201403.txt:383 LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 110.52 117.24 na
1396419125-201404.txt:384 LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 108.80 114.34 na
1399270867-201405.txt:385 LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 108.45 109.82 na
1401789424-201406.txt:385 LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 108.44 109.81 na
1404290583-201407.txt:385 LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 108.44 109.81 na
1407392347-201408.txt:386 LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 108.44 109.81 na
1409731282-201409.txt:LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 107.03 108.81 naLOKARI FILLING STATION BHALWAL 9 BHALWAL KOT MOMIN ROAD 107.34 109.12 na
1412235166-201410.txt:386 LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 104.09 107.86 n/a
1415185107-201411.txt:387 LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 94.66 101.68 n/a
1417519204-201412.txt:LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 84.99 94.55 n/a
1420218912-201501.txt:LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 78.73 86.68 n/a
$
The first column of figures is what I want.
Combining the local prices with the crude oil prices, I get a simple spreadsheet, and voila:
The figures seem to show a large gap between changes to local prices and Brent crude (no surprise there). Calculated against January 1, 2014's prices, on January 2, 2015 the drop in crude is 49.08% and the drop in local prices 30.48%.
Disclaimer:
Summary: calculated against January 1, 2014's prices, on January 2, 2015 the drop in crude is 49.08% and the drop in my local prices 30.48%.
I downloaded the Brent crude prices for Jan 1 2014 to Jan 2 2015, and grabbed the fields I wanted:
$ awk -F, 'BEGIN { OFS="," } { print $1, $5}' ~/Downloads/CHRIS-ICE_B1.csv | tail -r > crude.csv
$ head crude.csv
2014-01-01,110.8
2014-01-02,107.78
2014-01-03,106.89
2014-01-06,106.73
2014-01-07,107.35
2014-01-08,107.15
2014-01-09,106.39
2014-01-10,107.25
2014-01-13,106.75
2014-01-14,106.39
$
There are several gas stations on my way to work, but only two Shell stations that I can get to without making a U-turn. For the local gasoline prices, I visited the regulator (OGRA)'s site and grabbed the prices for Shell. I saved the PDF files and did
for i in *.pdf; do
pdftops $i - 2>/dev/null | ps2ascii - ${i%pdf}txt
echo done with $i
done
pdftops ships with xpdf and ps2ascii with Ghostscript. It's not a perfect process, but close enough:
$ grep 'LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD' *.txt
1388983409-201401.txt:386 LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 113.25 117.24 na
1391506062-201402.txt:383 LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 113.25 117.24 na
1393998747-201403.txt:383 LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 110.52 117.24 na
1396419125-201404.txt:384 LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 108.80 114.34 na
1399270867-201405.txt:385 LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 108.45 109.82 na
1401789424-201406.txt:385 LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 108.44 109.81 na
1404290583-201407.txt:385 LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 108.44 109.81 na
1407392347-201408.txt:386 LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 108.44 109.81 na
1409731282-201409.txt:LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 107.03 108.81 naLOKARI FILLING STATION BHALWAL 9 BHALWAL KOT MOMIN ROAD 107.34 109.12 na
1412235166-201410.txt:386 LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 104.09 107.86 n/a
1415185107-201411.txt:387 LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 94.66 101.68 n/a
1417519204-201412.txt:LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 84.99 94.55 n/a
1420218912-201501.txt:LINK FILLING STATION LAHORE MODEL TOWN LINK ROAD 78.73 86.68 n/a
$
The first column of figures is what I want.
Combining the local prices with the crude oil prices, I get a simple spreadsheet, and voila:
The figures seem to show a large gap between changes to local prices and Brent crude (no surprise there). Calculated against January 1, 2014's prices, on January 2, 2015 the drop in crude is 49.08% and the drop in local prices 30.48%.
Disclaimer:
- While crude oil is priced in dollars and gasoline in rupees, I'm looking at the daily change in percentage terms, with the base set to January 1, 2014's prices. I don't think the exchange rate has changed much in the past year.
- Since OGRA's PDF files don't tell me when the gasoline prices went into effect, I'm going to assume the first working day of each month.
- I don't know the exact cost of importing crude (or refined) oil to Pakistan. The Brent crude price might not be all that relevant here. However, this post is about investigating my perception of how much the price has dropped, based on what I see in the news and what I see at the gas pump.
- This looks at the prices for just one company's gas station -- the one I frequent. Other gas stations, located closer to the port of Karachi or local refineries, might show a larger drop.
(edited on January 25, 2015 to add a summary and fix a typo)
Monday, January 12, 2015
Saturday, January 10, 2015
manarat jeddah, january 2015
One of my brothers went to Saudi Arabia with his family for umrah a couple of weeks ago. He was able to spend a few days visiting places in Jeddah -- places he hadn't seen since his last visit in 1995.
One of them was his (and my) old school, Manarat Jeddah. I'm re-sharing his pictures below, with a guide to where they were taken. You can find the campus on Google Maps, at the corner of Jabal Kudai and Jabal Dallah. The school itself has moved to a different location.
One of them was his (and my) old school, Manarat Jeddah. I'm re-sharing his pictures below, with a guide to where they were taken. You can find the campus on Google Maps, at the corner of Jabal Kudai and Jabal Dallah. The school itself has moved to a different location.
Wednesday, December 03, 2014
chibi-scheme and native client
Getting chibi-scheme to work with Native Client was easier than I expected. I used
- chibi-scheme 0.7
- pepper-37
- Chrome 40
- on OS X 10.9.5
I unpacked the chibi-scheme tarball and the Native Client SDK into ~/Source, and ran naclsdk update to grab the latest stable toolchain. Then,
export NACL_SDK_ROOT=$HOME/Source/nacl_sdk/pepper_37
export CHIBI_ROOT=$HOME/Source/chibi-scheme-0.7
cd $CHIBI_ROOT
make SEXP_USE_DL=0 \
CC=$NACL_SDK_ROOT/toolchain/mac_pnacl/bin/pnacl-clang++ \
CFLAGS="-I$NACL_SDK_ROOT/include -I$NACL_SDK_ROOT/include/pnacl" \
LDFLAGS="-L$NACL_SDK_ROOT/lib/pnacl/Release -lnacl_io -lppapi -lpthread" \
STATICFLAGS=-DSEXP_USE_DL=0 \
EXE=.pexe \
chibi-scheme-static.pexe
You don't need chibi-scheme-static.pexe, but you do need the .o files. Don't run make clean in this directory!
Next up, integrating chibi-scheme into a pnacl module, and then accessing that from a web page. Here, I simply copied and adapted $NACL_SDK_ROOT/getting_started/part1: Makefile and code. It shouldn't be too hard to adapt the example's index.html to use the new module; at minimum, modify the example's page to say
<div id="listener">
<script type="text/javascript">
var listener = document.getElementById('listener');
listener.addEventListener('load', moduleDidLoad, true);
listener.addEventListener('message', handleMessage, true);
</script>
<embed id="pn1"
width=0 height=0
src="pn1.nmf"
type="application/x-pnacl" />
</div>
Run make serve, and visit http://localhost:5103/ in Chrome to load the page and module. Pop open a console and type
HelloTutorialModule.postMessage('(+ 2 3)');
You'll probably want to modify the page to add an input field for your input and a p tag or textarea for the result of your evaluated form. Here's what I started with: index.html.
<div id="listener">
<script type="text/javascript">
var listener = document.getElementById('listener');
listener.addEventListener('load', moduleDidLoad, true);
listener.addEventListener('message', handleMessage, true);
</script>
<embed id="pn1"
width=0 height=0
src="pn1.nmf"
type="application/x-pnacl" />
</div>
Run make serve, and visit http://localhost:5103/ in Chrome to load the page and module. Pop open a console and type
HelloTutorialModule.postMessage('(+ 2 3)');
You'll probably want to modify the page to add an input field for your input and a p tag or textarea for the result of your evaluated form. Here's what I started with: index.html.
Thursday, September 04, 2014
trying stumpwm
I've tried tiling window managers before, and I haven't been happy with them (especially with how they fail to deal with transient modal boxes), but I'm going to give them another shot. I followed the Ubuntu 12.04 + Gnome instructions, and set up stumpwm a couple of days ago. I've changed the control key from C-t to F12. It's still a little confusing, and I keep clicking on windows to focus on them (maybe there's a switch for that?), but the experience isn't terrible this time.
Maybe my feelings will change the next time I fire up Gimp, though I see someone's posted an example config for that on the wiki.
Maybe my feelings will change the next time I fire up Gimp, though I see someone's posted an example config for that on the wiki.
Wednesday, September 03, 2014
satellite images of earth.
For a while now, I've wanted a desktop background like xearth, but with updated (near-live) imagery. I've found a bunch of services that won't give me exactly that, but something I can live with.
Near Real-Time Data: Rapid Response has imagery from a bunch of instruments in satellites. I've had good experience with the Aqua MODIS images. Two tools on that site that I've tried are LANCE and Worldview.
Worldview shows the entire (mapped) planet with a short delay (they say 2.5-3 hours after a satellite pass). You can select base layers from the Aqua or Terra MODIS sources, and overlays from OpenStreetMap for borders, coastlines, and place names. You can also select a date to see what the world looked like in the past, going as far back as May 8, 2012. The best thing about it is that you can click on the camera icon, select an area, and it'll give you a link to an image. The image resolution goes down to 250 meters per pixel.
The Worldview image links appear to be stable, and look like
http://map2.vis.earthdata.nasa.gov/imagegen/index.php?TIME=2014246&extent=32.481445312501,23.405273437501,33.116455078126,24.152343750001&epsg=4326&layers=MODIS_Terra_CorrectedReflectance_TrueColor,Reference_Features,Reference_Labels&format=image/jpeg&width=289&height=340
The TIME field is the current year followed by the day of the year (September 3 is the 246th day). Incrementing this field should get you the next day's image; you can easily write a script to generate a desktop background once a day, or fetch a bunch of files and generate an animation.
Image subsets are also available of the MODIS data for certain areas of the world. Selecting South America brings up a page where I can select, say, True Color images of La Paz and the surrounding area. It's the same data as Worldview, but with a different interface. It gives you a JPEG download link that, again, appears to be stable; it looks like
Another way to grab imagery is with GDAL. The subset image page has a link that describes how to download the data using GDAL. In summary, you create a file that looks like
Install the gdal tools (Ubuntu: apt-get install gdal-bin), and type
Change MODIS_Terra_CorrectedReflectance_TrueColor to MODIS_Aqua_CorrectedReflectance_TrueColor for the Aqua images. I used Worldview to figure out a bounding box for my city, and modified the -projwin parameter to match (and also -outsize to match my display resolution), and voila! a desktop background!
Near Real-Time Data: Rapid Response has imagery from a bunch of instruments in satellites. I've had good experience with the Aqua MODIS images. Two tools on that site that I've tried are LANCE and Worldview.
Worldview shows the entire (mapped) planet with a short delay (they say 2.5-3 hours after a satellite pass). You can select base layers from the Aqua or Terra MODIS sources, and overlays from OpenStreetMap for borders, coastlines, and place names. You can also select a date to see what the world looked like in the past, going as far back as May 8, 2012. The best thing about it is that you can click on the camera icon, select an area, and it'll give you a link to an image. The image resolution goes down to 250 meters per pixel.
The Worldview image links appear to be stable, and look like
http://map2.vis.earthdata.nasa.gov/imagegen/index.php?TIME=2014246&extent=32.481445312501,23.405273437501,33.116455078126,24.152343750001&epsg=4326&layers=MODIS_Terra_CorrectedReflectance_TrueColor,Reference_Features,Reference_Labels&format=image/jpeg&width=289&height=340
The TIME field is the current year followed by the day of the year (September 3 is the 246th day). Incrementing this field should get you the next day's image; you can easily write a script to generate a desktop background once a day, or fetch a bunch of files and generate an animation.
Image subsets are also available of the MODIS data for certain areas of the world. Selecting South America brings up a page where I can select, say, True Color images of La Paz and the surrounding area. It's the same data as Worldview, but with a different interface. It gives you a JPEG download link that, again, appears to be stable; it looks like
http://lance-modis.eosdis.nasa.gov/imagery/subsets/?subset=AERONET_La_Paz.2014246.terra.250m.zip
Another way to grab imagery is with GDAL. The subset image page has a link that describes how to download the data using GDAL. In summary, you create a file that looks like
<gdal_wms> <service name="TMS"> <serverurl>http://map1.vis.earthdata.nasa.gov/wmts-geo/MODIS_Terra_CorrectedReflectance_TrueColor/default/2014-09-03/EPSG4326_250m/${z}/${y}/${x}.jpg</serverurl> </service> <datawindow> <upperleftx>-180.0</upperleftx> <upperlefty>90</upperlefty> <lowerrightx>396.0</lowerrightx> <lowerrighty>-198</lowerrighty> <tilelevel>8</tilelevel> <tilecountx>2</tilecountx> <tilecounty>1</tilecounty> <yorigin>top</yorigin> </datawindow> <projection>EPSG:4326</projection> <blocksizex>512</blocksizex> <blocksizey>512</blocksizey> <bandscount>3</bandscount> </gdal_wms>
Install the gdal tools (Ubuntu: apt-get install gdal-bin), and type
gdal_translate -of GTiff -outsize 3840 2880 \ -projwin -72.44865700501 -13.302075710262 -63.681994009835 -19.777183974533 \ your-gdal-filename.xml AERONET_La_Paz.tif gdal_translate -of JPEG AERONET_La_Paz.tif AERONET_La_Paz.jpg
Change MODIS_Terra_CorrectedReflectance_TrueColor to MODIS_Aqua_CorrectedReflectance_TrueColor for the Aqua images. I used Worldview to figure out a bounding box for my city, and modified the -projwin parameter to match (and also -outsize to match my display resolution), and voila! a desktop background!
Friday, June 27, 2014
95.
My grandmother turned 95 on Monday. She has trouble walking without help, and her short-term memory's not as good as it used to be, but she's still here.
Friday, June 20, 2014
read: Stonemouth, by Iain Banks
I liked how the story built up slowly, and I enjoyed the "crime fiction" angle of the Event that led to the narrator leaving the town before the events of the novel. I was afraid that if I didn't read carefully I'd lose track of the characters, but that didn't happen. 5/5.
Saturday, June 14, 2014
read: The Dig, by Alan Dean Foster
I bought the game a while ago (some Steam sale of LucasArts games), but I never got around to finishing it. The book was enjoyable.
Subscribe to:
Posts (Atom)