INBOX: invalid remote specification (errflg=2) Got following error when use imap_open() in PHP? Notice: Unknown: Can’t open mailbox {imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX: invalid remote specification (errflg=2) in Unknown on line 0 Check imap enabled SSL support like screenshot If cannot see SSL Support configuration, then need re-compile imap.so with enabling SSL support. PHP…
Category: Frameworks
PTV Timetable API sample code for PHP
API Page: https://www.ptv.vic.gov.au/about-ptv/ptv-data-and-reports/digital-products/ptv-timetable-api/ptv-timetable-api-reference/ 1. Request API key by sending email How to register for a key and developer ID > Send an email to APIKeyRequest@ptv.vic.gov.au with the following information in the subject line of the email: • “PTV Timetable API – request for key” > Once we’ve got your email request, we’ll send you a…
Vagrant Scalable Web Application Architecture
Deploying scalable web application using Vagrant, Consul, Consul Template, nginx and HAProxy Source Repo: https://github.com/chrisleekr/vagrant-scalable-web-application-architecture This is proof-of-concept project to spin up scalable web application architecture with Vagrant. The project involves: Vagrant for launching multiple VM instances and persistent storage Consul for health checking and service discovery Consul Template for automated load balancer management nginx for…
Vagrant MySQL Master-Slave Replication
Vagrant MySQL Master-Slave Replication Source Repo: https://github.com/chrisleekr/vagrant-mysql-master-slave-replication Vagrantfile to spin up MySQL Master-Slave replication with persistent data storage Note: This project is created for just practice. Not suitable for production use. Prerequisites Vagrant 1.8.1+: http://www.vagrantup.com/ VirtualBox: https://www.virtualbox.org/ Usage $ git clone https://github.com/chrisleekr/vagrant-mysql-master-slave-replication.git $ cd vagrant-mysql-master-slave-replication $ vagrant up After vagrant machines are running, you can connect…
WebSocket Sample
The sample process Send event to Web Socket for getting order id Web Socket connects MySQL orders table and get next order id Send event back to client with message and next order id Sample Environment Node.js Modules: mysql, socket.io PHP MySQL Filename: serverfile.js // Open port 3000 var io = require(‘socket.io’).listen(3000); // Load mysql…
Configure Aptana to support PHP 5.4
I am using Aptana Studio 3 in Mac. When I try to set PHP 5.4 environment in project settings, it does not save the changes. And found this article – http://stackoverflow.com/questions/24633995/aptana-php-version-doesnt-stick-in-project-properties 1. Open project folder 2. Create folder .settings 3. Create file com.aptana.editor.php.prefs and Put below content into created file eclipse.preferences.version=1 phpVersion=php5.4 4. Close project and re-open
Sample XAMPP MySql my.ini Fast Performance
Only use in local test MySQL. # Example MySQL config file for large systems. # # This is for a large system with memory = 512M where the system runs mainly # MySQL. # # MySQL programs look for option files in a set of # locations which depend on the deployment platform. # You…
SmartOptimizer with CS-Cart optimization
Reference: http://forum.cs-cart.com/topic/29499-speed-up-and-optimise-cs-cart-version-3/ In store root .htaccess DirectoryIndex index.html index.php <IfModule mod_rewrite.c> RewriteEngine on # Pleas note that RewriteBase setting is obsolete use it only in case you experience some problems with SEO addon. # Some hostings require RewriteBase to be uncommented # Example: # Your store url is http://www.yourcompany.com/store/cart # So “RewriteBase” should be: #…
Javascript Skill Test
Found this test from the internet (Download: JavaScript_Skill_Test-blank) Tried to solve without using Google. FAILED. With help from Google, solved questions. There was someone’s solution for exact same questions; I resisted a lot to not see his solution. Some questions are referred to understand what question was. If I get this test in the interview without…
Run Internet Explorer in Mac using VirtualBox
Reference: http://osxdaily.com/2011/09/04/internet-explorer-for-mac-ie7-ie8-ie-9-free/ curl -s https://raw.githubusercontent.com/xdissent/ievms/master/ievms.sh | bash Or just download https://raw.githubusercontent.com/xdissent/ievms/master/ievms.sh and execute downloaded shell program.
Set a variable in Django template
Summary 1. Create “templatetags” folder at the same level as models.py, views.py. 2. Create “__init__.py” file in “templatetags” folder. The content will be empty. 3. Create “set_var.py” file in “templatetags” folder. And copy and paste below code from django import template register = template.Library() class SetVarNode(template.Node): def __init__(self, var_name, var_value): self.var_name = var_name self.var_value =…
money_format_alt
Alternative code snippet for money_format function money_format_alt($amount, $decimal, $symbol = ‘$’, $symbol_right = ”, $symbol_thousands = ‘,’, $symbol_decimal = ‘.’) { if ($amount < 0) return ‘-‘.$symbol . (number_format(abs($amount), $decimal, $symbol_decimal, $symbol_thousands)) . $symbol_right; return $symbol.number_format($amount, $decimal, $symbol_decimal, $symbol_thousands).$symbol_right; }
EnvironmentError: mysql_config not found
I am using Mac OS X 10.9, MAMP 1.9 (MySQL 5.1.44), Python 2.7.5. Got this error when I change database configuration in settings.py. I felt this issue can make me painful, so I start logging what happened and how I fixed. Do not follow below steps. Just go straightly bottom of article and read last…
VPS – Apache & MySQL Performance Tuning
Apache 1. Open/Create /var/www/vhosts/{hostname}/conf/vhosts.conf 2. Add oradjust below code KeepAlive On MaxKeepAliveRequests 29 KeepAliveTimeout 15 3. Copy to make backup of apache configuration # cp -p /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.YYYY-MM-DD.bak 4. Execute below shell script one by one # ramCount=`awk ‘match($0,/vmguar/) {print $4}’ /proc/user_beancounters` # ramBase=-16 && for ((;ramCount>1;ramBase++)); do ramCount=$((ramCount/2)); done # perl -0 -p -i…
.htaccess GZIP Compression & Enable Keep-alive
To make faster webpage loading, use Gzip compress and Enable keep-alive in htaccess <ifModule mod_deflate.c> AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript </ifModule> <ifModule mod_headers.c> Header set Connection keep-alive </ifModule> In Plesk Control Panel, follow below steps Access SSH as root user Go to /var/www/vhosts/{domain}/conf Create or Modify vhosts.conf Add following code…
Test website speed in various server location 웹사이트 속도 체크
Test website speed in various server location 웹사이트 속도 체크 http://www.webpagetest.org/
Detect when scroll is reached end of scroll
Using jQuery, determine that user has been scrolled until the end of element. Reference: http://stackoverflow.com/questions/6271237/detecting-when-user-scrolls-to-bottom-of-div-with-jquery $(‘.scrollable’).bind(‘scroll’, function(){ if($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight) { alert(‘end reached’); } });
Codeigniter CRUD Model Code Generator
DNS Prefetching to reduce DNS resolution time
<!DOCTYPE HTML> <html> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ /> <link rel=”dns-prefetch” href=”//www.robgravelle.com/”> … “The recommended best practice is to have your prefetch requests queued to the client OS as early as possible. It is also preferred to have them received in the first packet of the HTML. Therefore, explicit prefetch links should be placed…
Make Retina display ready for input submit button with image
When use input[type=image] for form submission, the image is stretched when use Retina Display mobile. Since you cannot change ‘src’ attribute using CSS, I had to find another way to accomplish this. Someone said to use ‘content’ in CSS can do, but I failed. And this method is not browser compatible. Anyway, you can make…
Media Query Reporter CSS Injection
Ref: http://webdesigntutsplus.s3.amazonaws.com/tuts/221_responsive_widget/Media-Query-Files-DEMO/index.html <link rel=”stylesheet” type=”text/css” media=”screen” href=”http://webdesigntutsplus.s3.amazonaws.com/tuts/221_responsive_widget/Media-Query-Files-DEMO/styles-mediaquery-reporter.css” /> Code Only: /* ====================================== MediaQuery-Reporter Styles ========================================= */ body:after { content: “less than 320px”; font-size: 300%; font-weight: bold; position: fixed; bottom: 60px; width: 100%; text-align: center; background-color: hsla(1,60%,40%,0.7); color: #fff; } @media only screen and (min-width: 320px) { body:after { content: “320 to 480px”; background-color: hsla(90,60%,40%,0.7);…
WordPress JSON API – Support since(from) date/time
WordPress JSON API (http://wordpress.org/plugins/json-api/) is a powerful plugin that allows RESTful API for WordPress. However, I needed specific post query such as “Get posts since 1999/01/01 11:00:00”, which JSON API did not support. After doing hours research to do so, I couldn’t find relavant answers. Since JSON API uses WP_Query in WordPress, I thought I…
Aptana Increase Memory Size & Excluding unnecessary files
Mac Application -> Aptana Studio 3 -> Click “AptanaStudio3.app” -> Right Click “Show Package Contents” -> Contents -> MacOS -> Open “AptanaStudio3.ini” with any text editor 1. –launcher.XXMaxPermSize 512m 2. -Xms512m 3. -Xmx1024m -startup ../../../plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar –launcher.library ../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx_1.1.101.v20120109-1504 –launcher.XXMaxPermSize 512m –launcher.defaultAction openFile -vmargs -Xms512m -Xmx1024m -Declipse.p2.unsignedPolicy=allow -Declipse.log.size.max=10000 -Declipse.log.backup.max=5 -Xdock:icon=../Resources/aptana.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts Windows Go to C:\Users\Chris\AppData\Local\Aptana Studio…
To re-size images with keeping aspect ratio and fitting to certain dimensions
To re-size images with keeping aspect ratio and fitting to certain dimensions function _create_thumbnail($actual_filepath, $folder_path, $target_filename, $width, $height) { // $this->load->library(‘image_lib’); // $image_lib_config = array( // ‘image_library’ => ‘gd2’ // , ‘source_image’ => $actual_filepath // , ‘new_image’ => $folder_path.$target_filename // , ‘maintain_ratio’ => true // , ‘width’ => $width // , ‘height’ => $height //…
SQLite – could not prepare statement (1 too many SQL variables)
During development for SQLite, I have got this error could not prepare statement (1 too many SQL variables) Accroding to this article, this error is because of SQLite limitation, which cannot put variables more than 999 variables. After I reduce the amount of variables, it worked very well.