=====
I made a book, its one page.
<?php | |
// Add social proof numbers to footer (repositioned to top of page via CSS) | |
function add_social_proof() { ?> | |
<div id="social-proof"> | |
<ul> | |
<li class="facebook"><a href="YOUR_FACEBOOK_PAGE_URL" target="_blank" title="Disrupting the Rabblement on Facebook"><?php facebook_fan_count() ?> Fans</a></li> | |
<li class="twitter"><a href="YOUR_TWITTER_PROFILE_URL" target="_blank" title="Follow Niall on Twitter"><?php twitter_follower_count() ?> Followers</a></li> | |
<li class="email"><a href="YOUR_SUBSCRIBER_FORM_URL" target="_blank" title="Subscribe to email updates"><?php subscriber_count() ?> Subscribers</a></li> | |
</ul> | |
</div> |
#To disable the UAC prompt and run everything by default as admin | |
#Is set to 1 by default | |
Set-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableLUA" -Value "0" | |
shutdown -r -t 0 #reboot | |
#-------------------------------------------------- | |
#If the above breaks your ability as an Admin to install apps from the Microsoft store | |
#run the following in an elevated Powershell console |
Average time to run bench.php on my laptop, by PHP version | |
• 5.2.17: 3.77 seconds | |
• 5.3.23: 2.63 seconds | |
• 5.4.15: 1.98 seconds | |
• 5.5RC1: 2.11 seconds |
<?php | |
// Source : http://snipplr.com/view/12631/detect-browser-language/ | |
function get_client_language($available_languages, $default='en'){ | |
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { | |
$langs=explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']); | |
foreach ($langs as $value){ | |
$choice=substr($value,0,2); | |
if(in_array($choice, $available_languages)){ |
<?php | |
// Source : http://www.inkplant.com/code/get-twitter-posts-by-hashtag.php | |
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); |
<?php | |
// Source : http://www.catswhocode.com/blog/snippets/detect-location-by-ip | |
function detect_city($ip) { | |
$default = 'UNKNOWN'; | |
if (!is_string($ip) || strlen($ip) < 1 || $ip == '127.0.0.1' || $ip == 'localhost') | |
$ip = '8.8.8.8'; |
<?php | |
// Source : http://css-tricks.com/snippets/php/sanitize-database-inputs/ | |
// Function for stripping out malicious bits | |
function cleanInput($input) { | |
$search = array( | |
'@<script[^>]*?>.*?</script>@si', // Strip out javascript | |
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags | |
'@<style[^>]*?>.*?</style>@siU', // Strip style tags properly |
=====
I made a book, its one page.
# by @levelsio | |
# | |
# MIT licensed | |
# | |
# make sure you enable php_intl on PHP | |
# you can do by uncommenting ;extension=intl or ;extension=php_intl | |
# and installing php-intl, e.g. sudo apt-get install php-intl | |
# | |
# made for Nomad List to give people a notice if they go to a place | |
# where it is currently Ramadan |
class ModelAdmin extend Admin | |
{ | |
// ... | |
public function validate(ErrorElement $errorElement, $object) | |
{ | |
// find object with the same uniqueField-value | |
$other = $this->modelManager->findOneBy($this->getClass(), array('uniqueField' => $object->getUniqueSlug())); | |
if (null !== $other && !$other->equals($object)) { |