NerdHerdPH Notes/Snippets
Monday, March 24, 2014
Install Phalcon on Ubuntu 12.04
1. We need some packages previously installed:
> sudo apt-get install php5-dev php5-mysql gcc libpcre3-dev
2. create the extension from C source
> git clone --depth=1 git://github.com/phalcon/cphalcon.git
> cd cphalcon/build
> sudo ./install
3. Add the extension to your php.ini:
extension=phalcon.so
4. Finally, restart the webserver
> sudo service apache2 restart
Sunday, March 23, 2014
My config new Ubuntu instance
sudo a2enmod rewrite
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/example.com
sudo a2ensite example.com
Tuesday, March 11, 2014
PHP RegEx for ISO date
$subject = '1985-12-31';
$pattern = '/^[0-9]{4}[-\/](0[1-9]|1[12])[-\/](0[1-9]|[12][0-9]|3[01])$/';
preg_match($pattern, $subject, $matches);
print_r($matches);
Tuesday, March 4, 2014
Capture RFID Scanner on webpage without input
$(document).ready(function(){
var arr = [];
$(this).bind('keypress', function(e){
var code = e.keyCode || e.which;
if(code == 13) { //Enter keycode
console.log(arr.join('',','));
console.log('Press Enter');
arr = [];
} else {
// convert each kepress to character and add to array
arr.push(String.fromCharCode(e.keyCode));
}
});
});
Access Heroku Remote Terminal
How to access heroku's remote terminal for desired app/repo
1. Clone Heroku Repo
e.g: git clone git@heroku.com:sample-app.git
Note: make sure to download the Heroku Toolbelt and login with you credentials.
2. locate on app directory
e.g: cd sample-app
3. run this
heroku run bash
type "exit" to go back to local terminal
1. Clone Heroku Repo
e.g: git clone git@heroku.com:sample-app.git
Note: make sure to download the Heroku Toolbelt and login with you credentials.
2. locate on app directory
e.g: cd sample-app
3. run this
heroku run bash
type "exit" to go back to local terminal
Subscribe to:
Posts (Atom)