This file contains 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 viewSource() { | |
var httpRequest; | |
try { | |
httpRequest = new XMLHttpRequest(); | |
}catch(trymicrosoft) { | |
try { | |
httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); | |
} catch(oldermicrosoft) { | |
try { | |
httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); |
This file contains 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 trim_text_in_sentences($intLength, $strText) { | |
$intLastPeriodPos = strpos(strrev(substr($strText, 0, $intLength)), '.'); | |
if ($intLastPeriodPos === false) { | |
$strReturn = substr($strText, 0, $intLength); | |
} else { | |
$strReturn = substr($strText, 0, ($intLength - $intLastPeriodPos)); | |
} | |
return $strReturn; |
This file contains 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 generate_url_from_text($strText) { | |
$strText = preg_replace('/[^A-Za-z0-9-]/', ' ', $strText); | |
$strText = preg_replace('/ +/', ' ', $strText); | |
$strText = trim($strText); | |
$strText = str_replace(' ', '-', $strText); | |
$strText = preg_replace('/-+/', '-', $strText); | |
$strText = strtolower($strText); | |
return $strText; |
This file contains 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
RewriteCond %{REQUEST_METHOD} ^(GET|HEAD) [NC] # Only rewrite GET requests | |
RewriteCond %{HTTP_HOST} olddomain\.com [NC] | |
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301] | |
RewriteCond %{HTTP_HOST} olddomain\.com [NC] # Otherwise block | |
RewriteRule ^(.*)$ - [F] |
This file contains 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 | |
/* | |
This function will add soft hyphens after every 3rd character in words of over 10 characters. | |
*/ | |
public static function SoftHyphens($text) { | |
$return = ''; | |
// Add spaces around HTML tag delimiters, to process them as individual words (to be removed later) | |
$text = str_replace('>', '> ', $text); | |
$text = str_replace('<', ' <', $text); |
This file contains 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 | |
/* | |
Add and remove querystring variables from URLs. | |
*/ | |
function addQuerystringVar($url, $key, $value) { | |
$url = preg_replace('/(.*)(\?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&'); | |
$url = substr($url, 0, -1); | |
if (strpos($url, '?') === false) { | |
return ($url . '?' . $key . '=' . $value); | |
} else { |
This file contains 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 | |
/* | |
0346745008178 | |
Should fail - checksum should be 9 | |
5060096384137 | |
Should pass | |
5020650002112 |
This file contains 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
'===================================================================== | |
' Readable.io REST Post Test | |
' -------------------------- | |
' Basic asp.net (VB.Net) 4 page with textbox, label and submit button | |
' Created: 25 May 2018 | |
' Author: humanotics.co.uk | |
'===================================================================== | |
Imports System.Net | |
Imports System.Security.Cryptography |
This file contains 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
import hashlib | |
import time | |
import requests | |
class ReadableAPIClient: | |
""" | |
API Client for Readable.io, written for Python 3 | |
See API documentation: https://readable.io/api/docs/ |