Input type=number

<input type="number" step="any"/> Will allow any decimal point. If the current value of the input is “123.456”, for example, then clicking the UP arrow will increase it to “124.456”. Without the ‘step=”any”‘, it would’ve increased to “124”. Note: The ‘step’ attribute, together with ‘min’ and ‘max’, control which values are considered valid.

jQuery Cheatsheet


$('p').find('span') Finds all span elements that are descendants of some ‘p’ elements (not necessarily immediate children). Compare to .children(), that travels only a single level down the DOM tree.
or: $('span', $('p'))
Finds all span elements that are descendants of some ‘p’ elements (not necessarily immediate children). Compare to .children(), that travels only a single level down the DOM tree.


$(this).data('k',123) Use $(this).data('k') to get the associated value (123 in this case), $(this).data() to get all the key-value map, and $(this).removeData('k') to remove a data entry.
$('<div/>',{'class':'c1 c2'}) As of jQuery 1.4, this creates an element on the fly with specified attributes, e.g. <div class="c1 c2"></div> in this case. Note: Usually you’d like to append() or appendTo() this new element. But if you want its string representation, use the element.outerHTML attribute, i.e. $(...)[0].outerHTML.

Which PayPal product should I choose

Many products, many APIs
With their inconsistent information (and user experience) all over their dozens of different domains, PayPal miserably fails to deliver a clear message to developers. Here is a nice attempt (by PayPal) to consolidate some typical use cases so you can decide better which product is suitable for you, but you might get lost without some basic understanding of terms like “Express Checkout”, “Adaptive Payments”, “Classic APIs” etc. And so we try to shed some light on the general usage of PayPal’s products and APIs. Leave a comment and we’ll consider elaborating on other stuff as well. This document is still in the process of writing. Feel free to comment with feedback and suggestions.
PayPal NVP (Name-Value Pair) API
PayPal exist for many years, so they host a few families of APIs you can use. The newest are their REST APIs. In this section however we focus on the NVP API, which is considered as one of their “Classic APIs”. The “Name-Value” simply means that we’re passing information using the format “NAME=value”, for example FIRSTNAME=Robert&MIDDLENAME=Herbert&LASTNAME=Moore. Our page will send such a formatted request to the PayPal API Server, which will return a response: There’s a specific way to build the request. For example, you need to specify the METHOD (the required API operation to perform), and you need to provide some API Credentials: Either a signature or a certificate (but not both). For example, the “signature” option is merely some “USER=...&PWD=...&SIGNATURE=...” (together with the METHOD=... as well as other request-specific details. The response is also formatted in a specified way, and both response and request should be UTF-8-encoded. But it may help to first understand the types of requests (“API operation”s) you can make, so read on! (and later feel free to dwell into the boring details in the original documentation) Note: Some of the features, like Express Checkout, require your process to perform multiple operations in order to complete. For example, first call SetExpressCheckout and then DoExpressCheckoutPayment, as illustrated here:
Classic APIs
The API operations are divided in the documentation into 6 categories:
  • Adaptive Accounts: Create PayPal accounts and handle account management. Example requests: CreateAccount, AddPaymentCard, …
  • Adaptive Payments: Manage payments, payment preapprovals, and refunds. Example requests: Execute Payment, Pay, Refund, SetPaymentOptions, …
  • Button Manager: Manage your buttons! BMCreateButton, BMGetButtonDetails, … See also the image reference here.
  • Invoicing: CreateInvoice, SendInvoice, …
  • Merchant APIs: Some useful operations here! E.g. DoDirectPayment, DoExpressCheckoutPayment, CreateRecurringPaymentsProfile, GetExpressCheckoutDetails, GetRecurringPaymentsProfileDetails, SetExpressCheckout, UpdateRecurringPaymentsProfile, …
  • Permissions: GetPermissions, RequestPermissions, … Handle permissions associated with an access token, e.g. to execute operations on behalf of the buyer.
Express Checkout
The typical use case: When you want to allow one-time payment (as opposed to recurring payments), for example to support shopping carts on your site. The buyer clicks a button at your site, redirected to PayPal to fill in some payment details and confirm, and then redirected back to your site. You must have a PayPal merchant account to allow this. Below is a summary of the getting started guide.
  • The typical checkout flow, without Express Checkout, is the following:
    • The payor (buyer) clicks the checkout button in his shopping cart page,
    • Provide shipping info,
    • Select payment method,
    • Review summary for approval,
    • Sees a confirmation of the transaction.
  • The “Express Checkout” way skips the “shipping info” and “payment method” steps. The image below neatly summarizes the process together with the 3 API calls your applications needs to make:
The relevant API for working with Express Checkout is here. A good and detailed documentation about actually implementing it is here.
Payflow Gateway
For the more serious applications that want full control on the process: To host the checkout pages, manage security for sales and authorizations. You need an “Internet Merchant Account” for that (which is a different thing from being simply a “merchant”, i.e. there’s a special application form you have to fill and it gets processed within a few days). Quoting the documentation:
Payflow is secure, open payment gateway. It is available in two versions: Payflow Link, which requires the use of hosted payment pages, and Payflow Pro, which gives merchants total control over the payment process. Payflow allows merchants to choose any Internet Merchant Account to accept debit or credit card payments and connect to any major processor. It also lets merchants accept PayPal and Bill Me Later payments.
PayPal Payments Pro (Direct Integration), Website Payments Pro
Enables merchants and developers to accept credit cards, debit cards, and PayPal payments directly on their website. PayPal Payments Pro also includes Express Checkout and Virtual Terminal. Add-on services like Recurring Billing are also available.
Recurring Payments recurring payment profile: Every time someone is charged in a recurring manner (subscription), in PayPal terms this means she has a recurring payment profile. This “profile” instance includes all the payments details and is maintained at PayPal’s side.

Social Apps, OAuth


To revoke access of a Google App:,
or if you have a Google+ profile.

For OAuth purposes:
– To create an App:
– Use Client ID (e.g. and Client secret (e.g. FAft3aUW3sdtM1E28XXMimQw).
– Make sure you configure both the “Authorized Javascript origins” as well as the “Authorized redirect URI” fields.


To revoke access of a Facebook App: (Settings -> Apps).

For OAuth purposes:
– To create an App:
– Use App ID and App Secret.
– Make sure you configure the “App Domains”, and add a “Platform”, namely “Website”, where you also configure the “Site URL” cialis 20mg tadalafil.


For OAuth purposes:
– To create an App:

Laravel Cheatsheet

Some useful Laravel 4 commands below.


In app/config/ there are various files (objects) like ‘app’, ‘auth’, ‘database’, and more. Configure them as you like. You can use Config::get($key) to access some configuration in real-time, e.g.Config::get('app.debug').


Redirect::to('') or Redirect::to('/') Redirects to /public/
Redirect::route('someName') Redirects using a Named Route.

Named Routes

Route::get('user/profile', array('as' => 'profile', function() { ... })) or Route::get('user/profile', array('as' => 'profile', 'uses' => 'UserController@showProfile')); Associates the “user/profile” route with some function (or Controller method), and creates a Named Route to “user/profile” (so now when you’ll call Redirect::route('profile'); you’ll redirect to “user/profile”.

Rename a folder when Windows claims it’s shared or open in another program

You’re trying to rename (or delete) a folder on your Windows 7 machine, and you get an annoying message saying that some of its subfolders are shared, or the message: “this action can’t be completed because the folder or a file in it is open in another program”. Possible quick solutions for the sharing error message:
  • Make sure it’s indeed not shared! (go to Properties->Sharing and make sure it says “Not Shared”).
  • Not sure which of the subfolders is being shared? Run net share to view all current shares in your machine (and thank me later). More documentation is here.
  • It’s sometimes the thumbs.db’s fault. It sometimes helps to change the “view” to disable any previews (e.g. use the “Details” or “List” views).
Possible quick solutions for the “open in another program” error message:
  • Delete all contents from “C:\Users\USERNAME\AppData\Local\Temp” (or simply type “%temp%” in your Windows Explorer or “Start” input box and it will get you there). If this doesn’t help, empty the Recycle Bin as well.
  • Restart the explorer.exe service (e.g. go to Windows Task Manager (CTRL+SHIFT+ESC), find explorer.exe and “End Process”, then under “File” click “New Task (Run…)” and type in “explorer.exe”)
  • Delete all thumbs.db files from that folder (search for thumbs.db and delete all results; don’t worry, Windows will generate them the next time you visit the appropriate files/directories). Also from Recycle Bin.
  • Update to the most recent .NET Framework.
  • Try to rename oldDirName newDirName from the Command Console (preferably with Administrator privileges, but doesn’t really matter in this case). If the command fails (“access denied”), run it in Safe Mode or immediately after the computer boots! (if the latter suggestion worked, this means that the culprit was some nasty service you have there running, better get acquainted with your processes, check out the cool Process Explorer by Windows Sysinternals.
Other possible solutions:

Related issue — remove an annoying “lock sign” off a file or a folder:

  • Compare the Properties->Security of that folder with another well-behaved folder. It’s usually the “Authenticated Users” group that would suddenly disappear, so add it (Edit->Add, then type in “Authenticated Users”) again and give it the same permissions as your other, well-behaved folder.
If you still have a problem, write a comment below and we’ll try to help. Please, no links to sites or any other spam.

How to limit the number of revisions in WordPress

WordPress has an interesting Revisions System. Each saved draft or published update is stored as a separate row in the DB, and you can compare any two specific revisions. In addition, there’s also a special “autosave revision” that is kept there from time to time while you edit your thoughts.Movie Rings (2017)

But if you like tidiness and a bounded number of rows in your DB tables, you may limit or disable the number of revisions. The easiest way is to edit wp-config.php, by adding:
define( 'WP_POST_REVISIONS', 3 );
Instead of the 3 above that will limit the number of revisions to 3 + the autosave one, you may choose any other integer > 0. To disable all revisions (except the autosave one) use 0 or false instead. To remove the limit either remove this line or use -1 or true. This is all explained in WordPress Codex as well, but whatever your final choice is, make sure you add this before the line:
/* That's all, stop editing! Happy blogging. */

Hope this helps.

Laravel Blank Page / White Screen

Did you also get an annoying blank page / white screen after your first installation of Laravel? Here are a few troubleshooting directions that may help:

  • Permissions: folders within app/storage require write access by the web server! Make sure you chmod everything appropriately!
    • Note for beginners: If you’re using Apache, the user used by the web server may be “www-data” or “root” by default. You can find the User directive usually in the /etc/apache/apache2.conf file, usually with something like User ${APACHE_RUN_USER} (the environment variable APACHE_RUN_USER is set in /etc/apache2/envvars.
  • Note that Apache 2.2 and 2.4 differ in some Rewrite-related commands. Might be relevant for you, if you’re struggling with some rewrites.
  • Ubuntu users, make sure you sudo apt-get install php5-mcrypt (and then sudo service apache2 restart)
  • In the routes.php file, try a really simple route before going into View rendering etc., for example: Route::get('/', function() { echo 'HERE! (delete me!)'; return 'Returning a simple string without any View rendering.'; }

Still stuck? Leave a comment and we’ll do our best to debug your problem. But it seems like the reasons above solve most of the cases.

Play! Framework, quick tip to overcome weird Eclipse errors

Quick tip to those working with Play! Framework in Eclipse (the following tip worked for Play! version 2.1.1 on Eclipse Helios SR2, but may very well apply for other versions). Sometimes Eclipse will complain about the index.render function, for example, claiming it cannot be resolved or the signature is incompatible, or whatever. While the overall project might not contain errors, the file in question will annoyingly enough display some errors (not warnings! errors!) that will try to drive you crazy. There might also be sudden problems in the build path of the project. Possible solutions that worked for me:
  1. Make sure you have the up-to-date Scale IDE installed (“Help -> Install New Software…” or “Help -> Check for Updates”). See also ScalaIDE’s Getting Started guide.
  2. Run play clean compile again from the console on the same project.
  3. Using “Project -> Clean…” didn’t really work. Instead, “Project -> Close Project” followed by “Project -> Open Project” did get rid of those annoying errors.

Git Quick Tutorial, Cheat Sheet

The following is meant to be a quick cheatsheet to recap some Git commands.

Basic flow

An example basic flow of commands:
git initto create an empty Git repository in a .git folder.
git statusto see which files are not tracked, changes, conflicts etc.
git add .to add all files to the staging area (a.k.a. “index”).
(if you modify a file now and want to commit those changes, don’t forget to git add it again before committing)
git reset file.txtto undo that last add command for file.txt, so now it’s not tracked.
git commit -m "my commit remark" creates a new commit object with the staged changes in the Git repository.

Deleting files

Create some file and commit it: touch deleteme.txt git add . git commit -m "added deleteme.txt" Will commit the deleteme.txt file
Try to delete (will FAIL): rm deleteme.txt git add . git commit -m "will fail" Will get a no changes to commit message, and the deleteme.txt file will still be kept in the repository…
How to delete (alternative 1): git add -A . git commit -m "success" The -A (or equivalently --all) compares changes in the working tree as well as the index, so the file deleteme.txt will now be deleted in the repository as well.
How to delete (alternaive 2): git commit -a -m "success" The -a (or equivalently --all) tells the commit command to automatically stage files that have been modified and deleted, so the file deleteme.txt will now be deleted in the repository as well.
How to delete (alternaive 3): Instead of the rm deleteme.txt above, could instead: git rm deleteme.txt git commit -m "success" The rm command removes the file and records its deletion in Git, so after the commit command the deleteme.txt will be deleted in the repository as well.


git diff shows the changes in the working tree not yet staged for the next commit. git diff --cached shows the changes between the index and your last commit; what you would be committing if you run “git commit” without “-a” option. In any case, it ignores any non-tracked files.
echo "some text" > file.txt git add file.txt git commit -m "remark1" Suppose we add a file.txt and commit it.
Now modify it: echo "more text" >> file.txt Modified, but still didn’t add it to staging, i.e. we didn’t run: git add file.txt
git diff will show us the differences we have in that tracked file! Example diff output: diff --git a/file.txt b/file.txt index 477f637..f8217a9 100644 --- a/file.txt +++ b/file.txt @@ -1 +1,2 @@ "some text" +"more text"
But after adding the changes there will be no diff: git add file.txt git diff So the git diff will not print anything now. If you want to see the changes between the index and the last commit, use git diff --cached (will produce the same diff output as above)

Remotes and more

git remote List the existing remotes whose branches you track.
git remote -v A bit more verbose, show remote url after name.
– Add a remote repository: Use ‘git remote add’ with some remote name (usually “origin” is the name of the main remote) and repository URL: git remote add origin – Now can push local changes remotely to our ‘origin’ repo (on GitHub): The name of our remote is ‘origin’. The default branch name is ‘master’. git push -u origin master (the -u tells Git to remember the parameters, so that next time we can simply run git push and Git will know what to do) – Suppose others worked on our project and committed stuff. We can check for changes on our GitHub repository and pull down any new changes by running: git pull origin master – If we want the diff of our most recent commit, which we can refer to using the HEAD pointer: git diff HEAD – Another great use for diff is looking at changes within files that have already been staged/cached (added, but not committed yet): git diff --cached (--cached is same as --staged) – Other example for git diff: git diff v2.5:Makefile – To unstage files: git reset octofamily/octodog.txt – To revert the working tree to the state of some branch or specific paths: git checkout master (checks out the master branch (switches branch)) git checkout master~2 Makefile (takes a file out of another commit. Reverts the Makefile to two revisions back) – Now suppose we accidentally ran ‘rm -f hello.c‘. Then we could restore it from the index: git checkout hello.c (but in case we have a branch called hello.c, this will be understood as reverting to that branch!!! So better to use the following:) git checkout -- hello.c – Branching out: git branch my_branch – To see the branches: (with “*” at the current branch) git branch – To switch to another branch: (also discussed above) git checkout my_branch – In that branch, suppose we remove some files from both the disk and from the staging/index: git rm '*.txt' – And commit the change: git commit -m "cleaned up stuff" – Now we want to copy (merge) changes from my_branch back into the master branch: git checkout master git merge my_branch – To delete a branch: git branch -d my_branch – Finally, can again push it to the remote repo: git push
git log Shows the recent commits etc.

Other resources