Skip to content

Instantly share code, notes, and snippets.

View panique's full-sized avatar
🍒
Jetset lifestyle

Chris panique

🍒
Jetset lifestyle
  • Kyiv (Ukraine)
View GitHub Profile
@50dollarblogs
50dollarblogs / functions.php
Created December 29, 2011 17:10
Add social proof to your WordPress site in plain text (see 50dollarblogs.net/social-proof for more info)
<?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>
@nickfloyd
nickfloyd / gist:4444709
Created January 3, 2013 16:27
Windows 8 execute all things as admin
#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
@lornajane
lornajane / benchmarks
Last active December 18, 2015 01:38
PHP benchmarks and version adoption, May 2013
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
@phpdistiller
phpdistiller / detect_browser_language.php
Last active January 1, 2016 00:29
This snippet detects the browser language and provides $available_languages as an array('en', 'fr', 'es').
<?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)){
@phpdistiller
phpdistiller / get_tweets_by_hashtag.php
Last active January 1, 2016 00:29
This snippet gets all tweets of a specific hashtag.
<?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);
@phpdistiller
phpdistiller / detect_location_by_ip.php
Last active January 1, 2016 00:29
This snippet detects the location of a specific IP. If the location isn't found, UNKNOWN is returned.
<?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';
@phpdistiller
phpdistiller / sanitize_database_inputs.php
Last active January 1, 2016 00:38
This snippet sanitizes database inputs.
<?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
@nijikokun
nijikokun / Retinafy.md
Created July 24, 2012 01:42
Retinafy your site, a free book

Retinafy Your Site / Device

By Nijiko Yonskai

=====

I made a book, its one page.

Table Of Contents

@levelsio
levelsio / Is it now Ramadan.php
Last active June 6, 2018 01:58
"Is it now Ramadan?" function in PHP
# 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
@markuspoerschke
markuspoerschke / ModelAdmin.php
Created September 7, 2012 17:30
SonataAdminBundle: Validate Unique
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)) {