(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| <?php | |
| /** | |
| * Turn all URLs in clickable links. | |
| * | |
| * @param string $value | |
| * @param array $protocols http/https, ftp, mail, twitter | |
| * @param array $attributes | |
| * @return string | |
| */ | |
| public function linkify($value, $protocols = array('http', 'mail'), array $attributes = array()) |
| #!/usr/bin/env bash | |
| echo ">>> Starting Install Script" | |
| # Update | |
| sudo apt-get update | |
| # Install MySQL without prompt | |
| sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root' | |
| sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root' |
| <?php | |
| /** | |
| * 1. create project at https://console.developers.google.com/project | |
| * 2. enable 'Analytics API' under 'APIs & auth' / APIs | |
| * 3. create 'NEW CLIENT ID' (OAuth client) under 'APIs & auth' / Credentials | |
| * i. select 'Service account' | |
| * ii. save generated key file to 'key.p12' | |
| * iii. remember CLIENT ID | |
| * 4. under GA account add 'Read & Analyze' access to newly generated email (access to GA Account not Property nor View) |
| <?php defined('BASEPATH') OR exit('No direct script access allowed'); | |
| class GoogleGeocoder | |
| { | |
| public function __construct() | |
| { | |
| $this->baseURL = "https://maps.google.com/maps/api/geocode/json?sensor=false"; | |
| } | |
| public function geocode($address) |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| // Add / Update a key-value pair in the URL query parameters | |
| function updateUrlParameter(uri, key, value) { | |
| // remove the hash part before operating on the uri | |
| var i = uri.indexOf('#'); | |
| var hash = i === -1 ? '' : uri.substr(i); | |
| uri = i === -1 ? uri : uri.substr(0, i); | |
| var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i"); | |
| var separator = uri.indexOf('?') !== -1 ? "&" : "?"; | |
| if (uri.match(re)) { |
| <?php | |
| /** | |
| * This exemple shows how to parse base64 encoded images (submitted using Summernote), save them locally | |
| * and replace the 'src' attribute in the submited HTML content | |
| * | |
| **/ | |
| use Intervention\Image\ImageManagerStatic as Image; | |
| class PostController { | |
| public function edit(){ |
| # | |
| # Verify captcha | |
| $post_data = http_build_query( | |
| array( | |
| 'secret' => CAPTCHA_SECRET, | |
| 'response' => $_POST['g-recaptcha-response'], | |
| 'remoteip' => $_SERVER['REMOTE_ADDR'] | |
| ) | |
| ); | |
| $opts = array('http' => |
| """ | |
| Copies all keys from the source Redis host to the destination Redis host. | |
| Useful to migrate Redis instances where commands like SLAVEOF and MIGRATE are | |
| restricted (e.g. on Amazon ElastiCache). | |
| The script scans through the keyspace of the given database number and uses | |
| a pipeline of DUMP and RESTORE commands to migrate the keys. | |
| Requires Redis 2.8.0 or higher. |
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.
elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent