Anjanesh

Assignment Statements, Comparisons & Observations
Font: Size: + -
Showing posts with label storage. Show all posts
Showing posts with label storage. Show all posts

How to upload a web-font to Google Cloud Storage and use it in your CSS

Wednesday, December 26, 2012

Replace [bucket] with your bucket name.

  1. Use fontsquirrel's @font-face Generator to download all the font formats required for various browsers.
  2. Upload the fonts to Google Storage :
    gsutil -h "Vary:Accept-Encoding" -h "Cache-Control:public,max-age=31536000" cp -a public-read font-webfont.eot gs://[bucket]/fonts/font-webfont.eot
    gsutil -h "Vary:Accept-Encoding" -h "Cache-Control:public,max-age=31536000" cp -a public-read font-webfont.woff gs://[bucket]/fonts/font-webfont.woff
    gsutil -h "Vary:Accept-Encoding" -h "Cache-Control:public,max-age=31536000" cp -a public-read font-webfont.ttf gs://[bucket]/fonts/font-webfont.ttf
    gsutil -h "Vary:Accept-Encoding" -h "Cache-Control:public,max-age=31536000" cp -a public-read font-webfont.svg gs://[bucket]/fonts/font-webfont.svg

    Now your font is accessible at http://[bucket].commondatastorage.googleapis.com/fonts/font-webfont.eot or http://[bucket].commondatastorage.googleapis.com/fonts/font-webfont.ttf etc.

  3. Apply the code to your CSS.

    @font-face {
        font-family: 'fontFamilyName';
        src: url('http://[bucket].commondatastorage.googleapis.com/fonts/font-webfont.eot');
        src: url('http://[bucket].commondatastorage.googleapis.com/fonts/font-webfont.eot?#iefix') format('embedded-opentype'),
             url('http://[bucket].commondatastorage.googleapis.com/fonts/font-webfont.woff') format('woff'),
             url('http://[bucket].commondatastorage.googleapis.com/fonts/font-webfont.ttf') format('truetype'),
             url('http://[bucket].commondatastorage.googleapis.com/fonts/font-webfont.svg#aller_displayregular') format('svg');    
        font-weight: normal;
        font-style: normal;
    }
  4. Unfortunately the last step is not enough to display the web-font on your website since the fonts need to be on the same domain as the website.

    In order to allow web-fonts to be hosted elsewhere, the location of the web-fonts must have a Access-Control-Allow-Origin header sent.

    For Google Storage, we do this :

    <?xml version="1.0" encoding="UTF-8"?>
    <CorsConfig>
      <Cors>
        <Origins>
          <Origin>http://mydomain.com</Origin>
        </Origins>
        <Methods>
          <Method>GET</Method>
          <Method>HEAD</Method>      
        </Methods>
        <ResponseHeaders>
          <ResponseHeader>x-goog-meta-foo1</ResponseHeader>
        </ResponseHeaders>
        <MaxAgeSec>1800</MaxAgeSec>
      </Cors>
    </CorsConfig>

    Save this as font.xml.
    Hmmm ... Google says :

    gsutil setcors <cors-xml-file> uri

    But using gsutil, we can set CORS to an entire bucket only and not to an object.

    gsutil setcors font.xml gs://[bucket]

    not uri as mentioned

    Similarily, for getcors :

    gsutil getcors gs://[bucket]
    and not
    gsutil getcors gs://cats/mycats.png

Why I bought a Dropbox Pro account ?

Sunday, August 12, 2012

Last weekend was bad. My MacBook Pro's hard-drive crashed and my Ubuntu machine's hard-drive was semi-crashing, booting once in a while and once it booted with the entire file-system as read-only !

While my Ubuntu machine was up and running, I managed to backup all my data to Dropbox. But this time I backed it up in such a way that I don't have to 're-arrange' the folders all over again when my computer crashes.

Here's an example of what I did for my localhost (http://localhost/anjanesh) which, on the physical file system points to /home/anjanesh/www (~/www).

  • I copied all my data from ~/www to ~/Dropbox/www
  • Dropbox synced all the data in ~/Dropbox/www to the server
  • I deleted ~/www and symlinked www to ~/Dropbox/www (ln -s ~/Dropbox/www www)

So now ~/www points to ~/Dropbox/www
Whatever changes I make to ~/www gets stored, indexed and synced to Dropbox's server.

And now on my MacBook, I installed Dropbox and did the same thing with www - except point ~/www to /Users/anjanesh/Dropbox/www
This way, http://localhost/~anjanesh/ physically points to my Dropbox folder.

You can do this with all data folders, like Documents, Pictures and even Desktop. Even /var/lib/mysql to point all the mysql-data to a Dropbox sub-folder itself.

Sony DRX-S70U

Monday, October 29, 2007
Sony DRX-S70U

After several attempts in trying to figure out what went wrong with my 1.5 year old HP DVD Writer, I could come to no other conclusion than a hardware failure.

In a desperate need for a burner, I recently decided to get an external one instead, powered by USB so that I don't have to depend on a single PC incase of internal PC malfunction. Among the very few available to choose from, I got a Sony DRX-S70U external slim DVD Writer for Rs. 7,000 (~$175). Its the notebook type of drive, so it writes at pretty low speeds (HP disks at 2x).

Better off to use the cheapest internal writer to be replaced every one year or two, rather than getting an expensive branded one for this purpose.

There was drive that was really mouth-watering : Sony Blue-Ray BWU-100A. Unfortunately, its costs a whopping Rs 38,000 (~$950) !

Sony DRX-S70U Sony DRX-S70U

Hardware Fortnightmare

Tuesday, June 12, 2007

The last couple of weeks have been hectic.

HP dvd635i
  • MY 1.5yr old HP DVD-Writer is no longer burning CDs/DVDs properly. Nero keeps giving the error message Burn Process Failed at nx. The exact message error is Cannot Perform End-of-Disk-at-once. After wasting almost 15 HP DVDs trying to figure out the damn problem, I called HP service center to resolve the issue as its no longer under warranty. When they took the writer to their office for testing, they reported no such burning issue on their side after writing 6 CDs and 2 DVDs. I am truly running out of luck with this one, unable to find the fault on my PC - reinstalled Nero, updated the firmware etc. Even tried disabling the IMAPI CD-Burning COM Service. Man I wish I knew a hardware geek around. I'm going to keep the writer incase I do come across someone who can really look into it later. I've decided to get Sony's external sleek USB 2.0 driven model DRX-S50U dvd-burner. Sony has always been steady on external media storage.
  • As a result of not being able to burn DVDs plus my current hard-disk being almost full without having it defragmented for last 3yrs, I'm forced to get an additional internal-drive. So I've decided to push in a 250GB 3.0-Gb/s NCQ hard drive.

  • My ISP, Sify, is not pinging through these days. Even though this sprung up just after the rains started 'drizzling' here, its only a coincidence and really has nothing to do with the rains. Rumor has it that there's immense competition between the local cable operators here on connectivity distribution to customers and the result has been vandalism by the new/other party on the existing LAN. Could've written an entire chapter on this - but the last thing I want is some orkut-haters (you know who) banging my head due some political remarks or whatever.
  • Off lately I've been getting myself into Adobe's Flex SDK to create SWF files via their MXML structure. I never got into Flash before as I always felt (the s/w) naked on anything that was almost a 100% authoring solution. ActionScript 2.0 did exist, but with the new Java-like ActionScript 3.0 language and the non-binary format replacement for fla files, there soon would be a lot of developers jumping into Flex 2. But since its Java based and with the new Flash VM, memory has all of a sudden been a heavy requirement. Even though the resulting SWF is supposed to consume far less client-side memory when compared to a SWF created from Flash 8, it demands heavily during development and testing. Adding a 1GB memory-module to support all this and other services hopefully is a problem solver. Moreover I should then be able to enable many of FireFox's extensions.

That's a lot of work for the next couple of months to make up for !

Flickr Pro

Thursday, December 21, 2006
I just signed up for a Flickr Pro 2yr account - and I must say, its totally worth it. Flickr has a developer API that you can use to integrate Flickr services to your website. The only condition when hotlinking your own flickr photo onto your website is your page should have a link back to flickr.com. Interestingly, even for a commercial license, the API is free - unless the usage is very heavy. The reason for buying the pro account, is because they don't have a limit to their space and bandwidth usage, though the maximum upload transfer per month is limited to 2GB. The download transfer is unlimited. This is ideal for amateur photographers who on the practial side, are not going to to be uploading more than 2GB of photos per month - unless the new Canon EOS 1Ds Mark II's price comes down drastically ! For the average person, a 6MP camera is currently affordable. For a 6MP camera, the photo size ranges from 2MB to 2.5MB - which averages to 1000 photos upload per month. This should be just enough for a month for the average user. Here are some free Photo Hosting Sites :
HostMax Server SpaceMax Size per photoMonthly BandwidthDirect Linking
flickrNo LimitAuto-Resized to various sizes100MB
zooomrNo LimitAuto-Resized to various sizes100MB
PicasaWeb250MBAuto-ResizedNo Limit
Y! PhotosNo LimitAuto-ResizedNo Limit -
Photo Bucket1GB1MB10GB
WebshotsNo LimitNo LimitNo Limit
Village Photos12.5MB250KB1GB -
Sony ImagestationNo Limit for the first 12 monthsNo LimitNo Limit
MSN Spaces30MBNo LimitNo Limit