Sublime Text 2 – Useful Shortcuts (Mac OS X)
General
⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
<?php | |
function roundToBase($value, $base = 2) | |
{ | |
$result = log($value, $base); | |
$result = ceil($result); | |
$result = pow($base, $result); | |
return $result; | |
} |
'use strict'; | |
var sr = {}; | |
sr.Validator = function(){ | |
this.errors = []; | |
this.messages = { | |
required: 'The :input: is required', | |
email: 'The :input: is not a valid email address', |
<?php | |
return array( | |
/* | |
|-------------------------------------------------------------------------- | |
| Application Debug Mode | |
|-------------------------------------------------------------------------- | |
| | |
| When your application is in debug mode, detailed error messages with |
<snippet> | |
<content><![CDATA[ | |
// ${1} Resource | |
Route::get('${1}s', array('as' => '${1}s', 'uses' => '${1}s@index')); | |
Route::get('${1}s/(:any)', array('as' => '${1}', 'uses' => '${1}s@show')); | |
Route::get('${1}s/new', array('as' => 'new_${1}', 'uses' => '${1}s@new')); | |
Route::get('${1}s/(:any)edit', array('as' => 'edit_${1}', 'uses' => '${1}s@edit')); | |
Route::post('${1}s', '${1}s@create'); | |
Route::put('${1}s/(:any)', '${1}s@update'); | |
Route::delete('${1}s/(:any)', '${1}s@destroy'); |
<?php | |
return array( | |
/* | |
|-------------------------------------------------------------------------- | |
| Application URL | |
|-------------------------------------------------------------------------- | |
| | |
| The URL used to access your application without a trailing slash. The URL |
<?php | |
class Database { | |
public static $conn; | |
public static function connect(){ | |
try { | |
$conn = new PDO(DB_DRIVER.':host='.DB_HOST.';dbname='.DB_NAME.';', DB_USER, DB_PASSWORD); | |
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
self::$conn = $conn; |
⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
./configure \ | |
--prefix=/usr \ | |
--mandir=/usr/share/man \ | |
--infodir=/usr/share/info \ | |
--sysconfdir=/private/etc \ | |
--with-apxs2=/usr/sbin/apxs \ | |
--enable-cli \ | |
--with-config-file-path=/etc \ | |
--with-libxml-dir=/usr \ | |
--with-openssl=/usr \ |
<?php | |
function check_valid_email($email) { | |
$regex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/'; | |
if (preg_match($regex, $email)) { | |
return true; | |
} else { | |
return false; | |
} | |
} |
<?php | |
function convert_timestamp($timestamp, $format) { | |
$exp = explode(" ", $timestamp); | |
$date = explode("-", $exp[0]); | |
$year = $date[0]; | |
$month = $date[1]; | |
$day = $date[2]; | |
$time = explode(":", $exp[1]); | |
$hour = $time[0]; |