Allow Facebook to test your Open Graph meta tags ( og debugger ) with htpasswd password

If you are developing new site, you have probably locked it through htpasswd. When you are done with og meta data, you might want to check it with https://developers.facebook.com/tools/debug/sharing/ – but facebook won’t be able to access your content, because you can’t give it your password.

You need to update your htaccess, from

AuthUserFile /.htpasswd
AuthName Disbait
AuthType Basic
Require valid-user
satisfy any
deny from all
allow from 127.0.0.1

to

SetEnvIfNoCase User-Agent "^facebookexternalhit" facebook
SetEnvIfNoCase User-Agent "Facebot" facebook
SetEnvIfNoCase User-Agent "Twitterbot" twitter

AuthUserFile /.htpasswd
AuthName "Restricted Access"
AuthType Basic
Require valid-user
satisfy any
deny from all
allow from 127.0.0.1
allow from env=facebook
allow from env=twitter

Credit coderwall.com/p/8y7t1q/whitelist-facebook-twitter-to-test-your-open-graph-and-twitter-card-implementations

How to change the webview background color on PhoneGap iOS

Usually when you slide down your app screen, you will see gray, or white color background underneath your application.
You can change it by editing /platforms/ios/CoinWorth/Classes/MainViewController.m file.
Look for – (void)viewDidLoad and edit it like this:

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.webView.backgroundColor = [UIColor colorWithRed:34/255.0 green:37/255.0 blue:43/255.0 alpha:1];
}

This will make the background dark-ish. 34, 37, 43 are rgb values, you need to divide them by 255.0 for UIColor.

To use black color( or any of the basic colors – just google UIColor ), simply do

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.webView.backgroundColor = [UIColor blackColor];
}

Laravel strip all cookies and session data from JSON output

Hi,

If you are doing a small API library in Laravel you may find the output json a little bit – especially with a small response this is caused due to cookies and headers sent together with the response.
For a small 400B response JSON laravel adds additional 500B ( more than 100% ) of cookie information.

To strip all this from response headers, you need to go to /app/Http/Kernel.php and update $middlewareGroups section
1/ add \App\Http\Middleware\ApiSession::class,
2/ comment out \App\Http\Middleware\VerifyCsrfToken::class,

Final section may look like this

protected $middlewareGroups = [
    'web' => [
        \App\Http\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \App\Http\Middleware\ApiSession::class,
        \Illuminate\Session\Middleware\StartSession::class,
        // \Illuminate\Session\Middleware\AuthenticateSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
//            \App\Http\Middleware\VerifyCsrfToken::class,
        \Illuminate\Routing\Middleware\SubstituteBindings::class,
    ],

    'api' => [
        'throttle:60,1',
        'bindings',
    ],
];

Now create a file called ApiSession at /app/Http/Middleware/ApiSession.php with following content

<?php
namespace App\Http\Middleware;
use Closure;

class ApiSession {
    public function handle($request, Closure $next){
        \Config::set('session.driver', 'array');
        \Config::set('cookie.driver', 'array');
        return $next($request);
    }
}

That’s it!
In ApiSession.php you can check current api and only disable cookie for specific folder or url. You may do the same in VerifyCsrfToken class.

But if you project is strictly for API, this is the changes you have to make.

file_get_contents always returns false

Make sure you have allow_url_fopen enabled in your php.ini
By default this is enabled in PHP, but some hosting providers may disable it due to “security reasons” ( e.g. they want to look cool )

Create empty file only with code

<?php
phpinfo();
?>

And open it in browser. Then search for allow_url_fopen
If it says Off, you need to change this setting in your hosting.

http://php.net/manual/en/filesystem.configuration.php

WordPress – adjust maximum memory limit

Open wp-config.php and somewhere under database settings add

define('WP_MAX_MEMORY_LIMIT', '256M');
define('WP_MEMORY_LIMIT', '256M');

This will definitely adjust WordPress memory limit to 256MBs. You can use higher number if needed – e.g. 512M for 512 MBs of Ram.

Make sure to adjust PHP limit as well, either in php

ini_set('memory_limit', '256M');

.htaccess

php_value memory_limit 256M

or php.ini directly ( it will already be in php.ini file, just look it up and change the value )

memory_limit = 256M