Skip to content

Instantly share code, notes, and snippets.

View mrsize's full-sized avatar

Thomas Dufranne mrsize

View GitHub Profile
@mathiasbynens
mathiasbynens / jquery.email-antispam.js
Created January 26, 2010 13:10
Simple spam protection for email addresses using jQuery
/* Simple spam protection for email addresses using jQuery.
* Well, the protection isn’t jQuery-based, but you get the idea.
* This snippet allows you to slightly ‘obfuscate’ email addresses to make it harder for spambots to harvest them, while still offering a readable address to your visitors.
* E.g.
* <a href="mailto:foo(at)example(dot)com">foo at example dot com</a>
* →
* <a href="mailto:foo@example.com">foo@example.com</a>
*/
$(function() {
@idea34
idea34 / htacess_bot_blocker
Created November 18, 2011 20:53
Add to .htaccess to block common bad bots
#Block comment spammers, bad bots and some proxies
RewriteCond %{REMOTE_HOST} 24.117.121.113 [OR]
RewriteCond %{REMOTE_HOST} ^211.138.198.* [OR]
RewriteCond %{REMOTE_HOST} 216.246.60.183 [OR]
RewriteCond %{REMOTE_HOST} 203.94.229.227 [OR]
RewriteCond %{REMOTE_HOST} 91.121.3.29 [OR]
RewriteCond %{REMOTE_HOST} 210.0.141.247 [OR]
RewriteCond %{REMOTE_HOST} 210.197.97.67 [OR]
RewriteCond %{REMOTE_HOST} 74.95.182.57 [OR]
RewriteCond %{REMOTE_HOST} 222.36.12.42 [OR]
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@Darksoulsong
Darksoulsong / html5 Code Snippets - Microdata Version
Last active June 20, 2018 09:05
Html5 Code snippet with microdata included
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Html 5 Template with Microdata included</title>
<link rel="icon" type="image/png" href="http://example.com/myicon.png">
<link rel="stylesheet" type="text/css" media="all" href="css/style.css" />
<!--link rel="stylesheet/less" type="text/css" href="public/css/home.less">
<script src="public/js/less-1.3.0.min.js" type="text/javascript"></script-->
<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
@idea34
idea34 / useful.php
Created December 10, 2012 16:10
useful php items
<?php // Collection of useful php snippets
// html readable print_r for arrays
echo '<pre>';
print_r($myarray);
echo '</pre>';
?>
@idev247
idev247 / php-tricks.php
Created February 28, 2013 23:18
Various PHP tricks: - Array - Find previous array element
<?php
/**
* Array: Find previous element (method 1)
* @source http://stackoverflow.com/questions/4792673/php-get-previous-array-element-knowing-current-array-key
*/
$array = array(
12 => array('a','b'),
34 => array('c','d'),
56 => array('e','f')
@mburst
mburst / rss_reader.php
Created March 24, 2013 03:58
RSS Feed Reader in PHP
<html>
<head>
<title>RSS Feed Reader</title>
</head>
<body>
<?php
//Feed URLs
$feeds = array(
"http://maxburstein.com/rss",
"http://www.engadget.com/rss.xml",
@luckyshot
luckyshot / response.php
Last active December 30, 2019 16:02
Web scraping done right (with cUrl and user agent)
<?php return array (
'url' => 'https://xaviesteve.com/',
'content' => '<!doctype html><html>...</html>',
'cookies' => '__cfduid=d3fa669e1069e72c2e47d127ab9b8e11f1465390629',
'http_code' => 200,
'content_type' => 'text/html; charset=UTF-8',
'header_size' => 578,
'request_size' => 229,
'filetime' => -1,
'ssl_verify_result' => 0,
@luckyshot
luckyshot / simpletemplatingengine.php
Last active May 8, 2017 19:54
Simple Templating Engine
<?php
public function view($filename = 'home') {
// Default values for every View
$data = array(
"app_title" => $this->app_title,
"app_tagline" => $this->app_tagline,
"app_url" => $this->app_url,
"app_version" => $this->app_version,
"user_name" => $this->user_name,
);
@luckyshot
luckyshot / gist:5395607
Last active May 8, 2017 19:54
Array to CSV spreadsheet
<?php
function encodecsv($string) {
if(strpos($string, ',') !== false || strpos($string, '"') !== false || strpos($string, "\n") !== false) {
$string = '"' . str_replace('"', '""', $string) . '"';
}
return $string;
}