2013-09-05

Facebook Payments Documentation Guide for Lazy Developer

Facebook payment documentation provided just has too much chitchat going on. So here is simple quick rundown.
NOTE: This is for September 12, 2013 breaking changes local currency payments documentation.

Migration

Development

Step 1 - Define your Items


Essentially each item has it's own http/https address and being red via GET request, so you want to have view that could display each item by giving it an id. This link will be used in your frontend js and Facebook will cache the contains on it. https://developers.facebook.com/docs/howtos/payments/definingproducts/#ogproduct_item

If you want to make dynamic prices for things such as flash sales - don't provide the price, but that defeats the purpose of Facebook cached HTML views IMO, probably just a reason to push `og`. In this case on each popup Facebook will ask your backend the exact price. Request/Response after the image:
https://developers.facebook.com/docs/howtos/payments/definingproducts/#pricing_dynamic

List of supported currencieshttps://developers.facebook.com/docs/concepts/payments/currencies/

You can debug your views by pasting your item link to https://developers.facebook.com/tools/debug/

Step 2 - Add JavaScript


In this step you have to create JS method that will be called in the frontend in order to call up the payment popup.
It's easy and nothing much to add here. Just look up this https://developers.facebook.com/docs/howtos/payments/paymentflow/#paydialog

Step 3 - Create Callback


Here is the meat of the callbackhttps://developers.facebook.com/docs/howtos/payments/fulfillment/#jscallback
In the overview you'll see a graph and explanation below it, all you care at this point is what happens on step 8 and after. This is the callback logic. The best thing about it that docs are pretty solid here, also for rather quick rundown on logic video is great too.

So here you have two options (or both): you can confirm purchase via frontend (this is good for notification of payments for the user) and backend and technically you don't need both (technically!), and better one is via real time callback (backend) true graph api since it's more secure and will update in cases where JavaScript might fail (video explains this quite well).

So frontend docs are here: https://developers.facebook.com/docs/howtos/payments/fulfillment/#orderfulfillment
And Real Time docshttps://developers.facebook.com/docs/howtos/payments/fulfillment/#asynchronousconfirmation

Not much else to drop from this.
Have fun.

2013-08-07

Quick Bits #3 - Working in Remote Server via SSH

So I am working in remote server as my primary development platform for half a year or more. Everything via SSH. So my few cents on this.

Nginx dynamic domain proxy

The server it self has a domain and some open ports, besides that I use Nginx to proxy all requests to my development server running locally.

Nginx can use regex in this case quite effectively, besides some of my projects are hostname sensitive so this helps a lot since I get port :80 to listen any domain with single Nginx setting. All it needs is server name:
server_name         ~^dev\.(?P<project>\w+)\.(?P<network>\w+)\.mydomain\.com$;
Also I can use this latter on as variables to use different logs or do other scripting, but for some reason that was failing on me and I never need it that much since I work on single project at the time. So maybe this will be expanded latter on.

SSH keep alive/timeout change

So when you have multiple tabs open they start to disconnect, so usually what people do is to run tmux or screen session and work with that. But event then, you go for a cup of coffee... Well ok this is bad sample since it's also a security risk that way, but the idea is the same - have more time on your hands.

This is solved and explained quite extensively here - http://qr.ae/I5Fnd

Personally I edit ~/.ssh/config or /etc/ssh/ssh_config, this works on server side too for single server, just config is /etc/ssh/sshd_config. So All you need to add is
ServerAliveInterval 10 

Toolbox

Other than Nginx I use daily these tools (in no particular order) that help me to cope with SSH environment:
  • ZSH with Oh-My-Zsh (https://github.com/robbyrussell/oh-my-zsh, zsh installed via apt)
  • Tmux (allows to run multiple terminals on same ssh session)
  • Vim (in Ubuntu Vim-nox, since it comes with all extensions and python interpreter)
  • Git and Tig (Tig is a history viewer for Git)
  • Htop (enhanced version of top)
  • tree (shows hierarchical folder tree)
  • dtrx (allows to extract any compressed archive, I never remember all the flags)

2013-02-07

Heath Points of Hewlett Packard and the Review of HP Envy dv6

Most of my friends are somewhat IT related,  and most of them have horrible opinion when it comes to HP. This is due to the fact that most of them know at least few friends that owned or they owned themselves HP laptop and it broke in horrible ways.
For starters friend of mine had HP laptop that constantly overheated so he had to remove bottom cover for HDD/RAM/WiFi and carry around something to lift the bottom so the laptop would get air to cool itself. His girlfriend had HP laptop and it's graphics card was repaired few times by warranty and died because of the same reason. My other friend had HP laptop, it corpus around the hinges broke in half a year. My mother had laptop for work that was painfully slow. I probably could name few more, but you get the point. Horror stories are all around.
So it happened that I was planing to buy ASUS laptop that I was looking at for a very long time, but on the last moment shit went down and I had to buy anything that works if possible - as cheap as possible. Sure I wanted something that could work with some 3D graphics and wouldn't lag on OS itself, maybe play some games, so bare with me it was not the cheapest laptop. But I got it with discount as well as 3 year warranty.
So in the end I let myself for and adventure buying HP Envy dv6.

The Horror

The unboxing was not pleasant. When I powered on the computer - I've noticed that only English power plug is added. I do believe it's a fault of seller not manufacturer. It was just a step "O.K. Here we go...". Around the screen there was protectors from fingerprints. All around the damn unit including on hinges where it's really hard to remove. There was also one on the grill bellow the monitor (purely decorative I believe). Those are made of plastic and left side is 0.5 mm too long (right side is stuck perfectly) so it just slightly out of the in-cut for it. Also on the left side there was this bit that does not stick and helps you to remove the protector. I've started pulling on that and the whole grill started to come off. At this point I was thinking how/when I'll return the unit.

Surprise, Surprise 

When turned on everything went smoothly. Windows 8 activation (about Windows 8 - it will be another topic), UEFI disabling, Ubuntu installation besides Windows 8... Maybe too smoothly. It was one of the easiest laptop setups I've done. I was especially surprised when I turned on Ubuntu. Everything works. Sure the Laptop comes with nVidia geforce gt 630M - this means Optimus Prime stomping on your dual screen... But to my surprise VGA connector is not bound to the nVidia. Dual screen true VGA works fine. The only downsides are that brightness changing takes big steps so it's not as smooth as in Windows, but hey - in last laptop (emachines) the back-light was completely not working and would light only when direct command would be sent out.
To install Ubuntu along side Windows 8 just follow this guide - http://askubuntu.com/a/228069/8825

What I don't Like

  • The screen. It's same old 1366x768. I do agree with Linus on this topic and I believe 1080p should be the smallest standard. It's one of the better screens on this resolution, but just because it's not 1080p - I hate it.
  • Around the monitor there is a rubber protector that sticks our something like 1 mm. It feels when touched horrible, but to the eye, it is not as bad as it sounds.
  • Indicators. Well more lack of them. There is WiFi indicator on WiFi/F12 button. There is CapsLock indicator on CapsLock. There is power indicator on power button as well on back of the lid (illuminated HP logo). Aaaand thats it. FFS at least they could have put NumLock indicator. Also there is no HDD indicator witch means you will not be able to know if your computer is counting sheep or hard at work with HDD.
  • WiFi and Bluetooth is a combo card, witch means you cannot turn off one without other. This means that I have always running hidden bluetooth.

Things I like

  • Sound. It comes with Beats Audio (tm) and supposedly has subwoofer on the bottom. Hard to say if it contributes that much, but I can listen music without headphones on this one.
  • Insides. Intel i7, nVidia geforce GT 630M, 8 Gigs of RAM, 1TB HDD makes quite a show. The only things that I would like to change is bit faster HDD since this one is 5200 RPM. Also since I already had 16 Gigs of 1600 Mhz CL 10 RAM - I changed those, but the ones that come are decent enough.
  • When changing RAM I've noticed that everything is accessible removing single panel and that panel is hold by single screw. No warranty stickers on it ether, so you can upgrade your laptop without a fuss. 

Things that are "Meh"

  • Keyboard. It's comfortable - old apple style keyboard, but there is small gap between the spacing and the keys so stuff can go under the keys. It might be hard to clean.

Back to HP

So all in all I had quite uncomfortable start, but after that it exceeded my expectations. My brother right now has HP ProBook as well. He's working with quite demanding software and it handles it well. No breaking, not scratches, no heating. Nothing. Also I gave him my stock RAM's (8 Gigs) and holy fuck. This is how you change ProBook RAM:


No screws. Why the hell not every laptop is this way?! Take a note that it also opens up fan for easy cleaning. This is just perfect...
So all in all it went better than expected. Well see how it will last. I'll post updates if something happens.

2013-01-30

Quick Bits #2 - Terminal tutoring

Recently I've commented this on one of the G+ threads, so decided to put it on the paper internet. There is these tools - terminal multiplexers. Most commonly known is Screen. Another, a lot younger one is Tmux, oh there is also wrapper for these called Byobu for Ubuntu, but that's a little bit off topic. They share a lot in common, and have some differences as well. Best comparison is here - https://www.wikivs.com/wiki/Screen_vs_tmux.
In short - these programs allows to run multiple terminals in single session, allows to leave it running and continue latter on. If you're doing a lot of work via ssh, most probably you already use one of such multiplexers.
One of great features is session sharing (both of them have it). Session sharing will allow to multiple users enter text/commands and view same outputs and inputs. At least in screen (not sure on tmux yet) there is a problem - when you share a session, and it contains multiple terminal instances - all connected users needs to switch to that terminal manually. So the easiest solution is to run screen within a screen (no screenception pun intended) or mix screen and tmux, whatever works, personally I like mixing screen and tmux since by default they use different keys ^a and ^b... In such case only the bottom layer  (first screen/tmux) will need to share the session while top layer (second one) will just display output for all users, meaning that if one will switch terminal it will be switched for all. So far it seems to me to be the best way to introduce to code/configs and terminal based tools.

To share screen session (what I personally used) - http://serverfault.com/questions/336594/share-screen-session-with-users-in-the-same-group-linux
For Tmux - http://readystate4.com/2011/01/02/sharing-remote-terminal-session-between-two-users-with-tmux/