This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class Demo extends ParentClass | |
| { | |
| function demoParent(...$arguments) | |
| { | |
| // some overrided logic | |
| return (new \ReflectionClass(get_class($this))) | |
| ->getParentClass() | |
| ->getMethod(__METHOD__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE DATABASE dbname DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; | |
| GRANT ALL PRIVILEGES ON dbname>.* TO 'new_user'@'localhost' | |
| IDENTIFIED BY 'pswd' WITH GRANT OPTION; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function cleanInput($input) { | |
| $search = array( | |
| '@<script[^>]*?>.*?</script>@si', // Strip out javascript | |
| '@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags | |
| '@<style[^>]*?>.*?</style>@siU', // Strip style tags properly | |
| '@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments | |
| ); | |
| $output = preg_replace($search, '', $input); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function getDistanceBetweenPointsNew($latitude1, $longitude1, $latitude2, $longitude2) { | |
| $theta = $longitude1 - $longitude2; | |
| $miles = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta))); | |
| $miles = acos($miles); | |
| $miles = rad2deg($miles); | |
| $miles = $miles * 60 * 1.1515; | |
| $feet = $miles * 5280; | |
| $yards = $feet / 3; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getTweets($hash_tag) { | |
| $url = 'http://search.twitter.com/search.atom?q='.urlencode($hash_tag) ; | |
| echo "<p>Connecting to <strong>$url</strong> ...</p>"; | |
| $ch = curl_init($url); | |
| curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE); | |
| $xml = curl_exec ($ch); | |
| curl_close ($ch); | |
| //If you want to see the response from Twitter, uncomment this next part out: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Our custom error handler | |
| function nettuts_error_handler($number, $message, $file, $line, $vars){ | |
| $email = " | |
| <p>An error ($number) occurred on line | |
| <strong>$line</strong> and in the <strong>file: $file.</strong> | |
| <p> $message </p>"; | |
| $email .= "<pre>" . print_r($vars, 1) . "</pre>"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function ordinal($cdnl){ | |
| $test_c = abs($cdnl) % 10; | |
| $ext = ((abs($cdnl) %100 < 21 && abs($cdnl) %100 > 4) ? 'th' | |
| : (($test_c < 4) ? ($test_c < 3) ? ($test_c < 2) ? ($test_c < 1) | |
| ? 'th' : 'st' : 'nd' : 'rd' : 'th')); | |
| return $cdnl.$ext; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo mkdir /etc/nginx/ssl && cd /etc/nginx/ssl | |
| sudo openssl genrsa -des3 -out server.key 1024 | |
| sudo openssl req -new -key server.key -out server.csr | |
| sudo cp server.key server.key.org | |
| sudo openssl rsa -in server.key.org -out server.key | |
| sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt | |
| echo "add these lines into your nginx host config" | |
| echo " ssl on;" | |
| echo " ssl_certificate /etc/nginx/ssl/server.crt;" | |
| echo " ssl_certificate_key /etc/nginx/ssl/server.key;" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Article: | |
| manyToMany: | |
| tags: | |
| targetEntity: Tag | |
| inversedBy: articles | |
| joinTable: | |
| name: tags_for_articles | |
| joinColumns: | |
| article_id: | |
| referencedColumnName: id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| alias l='ls -alF' | |
| alias la='ls -A' | |
| alias ll='ls -CF' | |
| alias gittree='git log --pretty=format:"%h - %an, %ar : %s" --graph' |