Skip to content

Instantly share code, notes, and snippets.

@ChrisMcKee
ChrisMcKee / mini-scrape.php
Created October 10, 2011 10:54
Small part of a php page scraping application
<?php
function get_web_page( $url,$curl_data )
{
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "spider", // who am i
### Have to admit at this point, as "fast" as development with cake is... I hate the bastard.
server {
listen 80;
server_name www.domain.com;
rewrite ^/(.*) http://domain.com/$1 permanent;
}
server {
@ChrisMcKee
ChrisMcKee / GetSiteURLWithProtocol.php
Created October 13, 2011 11:54
Get site url with current protocol
<?php
function siteURL()
{
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$domainName = $_SERVER['HTTP_HOST'].'/';
return $protocol.$domainName;
}
define( 'SITE_URL', siteURL() );
@ChrisMcKee
ChrisMcKee / stopwincrap.bat
Created October 16, 2011 14:11
Services you have to stop on Windows 7 to start Apache / Get Port 80 Back Also make sure skypes closed or you've unticked the option to allow skype to use 80/8080
sc stop IISADMIN
sc stop W3SVC
iisreset /stop
sc stop MsDepSvc
@ChrisMcKee
ChrisMcKee / ScrapeBBC.js
Created October 18, 2011 16:26
Scrape BBC Sports Mobile and Return Headers + Body in JSON
<?php
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
$url = "http://news.bbc.co.uk/sport1/mobile/default.stm";
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => true, // return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
@ChrisMcKee
ChrisMcKee / PGLoadingDialog.java
Created November 3, 2011 15:43
Loading Dialog Phonegap Plugin
package com.phonegap.plugins; /*or just use your own namespace*/
import org.json.JSONArray;
import android.app.ProgressDialog;
import android.util.Log;
import com.phonegap.DroidGap;
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
@ChrisMcKee
ChrisMcKee / selenium.sh
Created February 17, 2012 12:08 — forked from lifeeth/selenium.sh
selenium init.d script for debian
#!/bin/bash
# /etc/init.d/selenium
# debian-compatible selenium-grid startup script.
# Based on jenkins startups
# Praneeth Bodduluri <lifeeth[at]gmail.com>
# update-rc.d -n -f selenium start 90 2 3 4 5 . stop 10 0 1 6 .
### BEGIN INIT INFO
# Provides: selenium-grid
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog $network
@ChrisMcKee
ChrisMcKee / ignorerules.txt
Created March 6, 2012 10:39
Tortoise SVN Visual Studio Ignore Rules
Applied on svn properties (recursively) using svn:ignore .
build.txt
*.resharper
**.ReSharper**
*.suo
*.user
*.pdb
@ChrisMcKee
ChrisMcKee / metachange.xml
Created March 20, 2012 14:56
IIS6 Meta Database Edit
<!-- Replace IISCompressionScheme and Schemes XML With This -->
<!-- Command line IISRESET after this -->
<!-- Its also worth adding a header to the page for ETAG -->
<!-- C:\WINDOWS\SYSTEM32\INETSRV -->
<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/deflate"
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="0"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
@ChrisMcKee
ChrisMcKee / senderror.js
Created April 4, 2012 12:40 — forked from pamelafox/senderror.js
Sending JS errors to server
function sendError(message, url, lineNum) {
var i;
// First check the URL and line number of the error
url = url || window.location.href;
lineNum = lineNum || 'None';
// If the error is from these 3rd party script URLs, we ignore
// We could also just ignore errors from all scripts that aren't our own
var scriptURLs = [