Skip to content

Instantly share code, notes, and snippets.

View RobThree's full-sized avatar
🤙
Being awesome

Rob Janssen RobThree

🤙
Being awesome
View GitHub Profile
@RobThree
RobThree / SoapClientTimeout.class.php
Created April 25, 2012 14:55
PHP SoapClient with timeout
<?php
//Drop-in replacement for PHP's SoapClient class supporting connect and response/transfer timeout
//Usage: Exactly as PHP's SoapClient class, except that 3 new options are available:
// timeout The response/transfer timeout in milliseconds; 0 == default SoapClient / CURL timeout
// connecttimeout The connection timeout; 0 == default SoapClient / CURL timeout
// sslverifypeer FALSE to stop SoapClient from verifying the peer's certificate
class SoapClientTimeout extends SoapClient
{
private $timeout = 0;
private $connecttimeout = 0;
@RobThree
RobThree / wavefilereader.class.php
Created August 29, 2012 17:22
PHP WAVE file reader / parser
<?php
/**
* WaveFileReader; a simple class to read/parse WAVE file
* (c)2012 Rob Janssen / https://github.com/RobThree
*
* Based on https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
*
* USAGE:
*
* $wav = WaveFileReader::ReadFile('/path/to/test.wav');
@RobThree
RobThree / hotlinkchecker.class.php
Created August 30, 2012 22:15
PHP Hotlink checker
<?php
/*
* Class for checking if images are hotlink-protected
*/
class HotlinkChecker {
// You can set this property to any random domain; this will be sent
// as the referring domain to check the "hotlink protected" version
public $testhost = 'www.somerandomdomain.com';
// You can change (or add/remove) any cURL options through this property
@RobThree
RobThree / SoapClientEx.class.php
Created November 20, 2012 13:23
PHP SoapClient with timeout and authentication
<?php
//**NOTE**: This has *NOT* been tested yet; please provide feedback in the comments
//Drop-in replacement for PHP's SoapClient class supporting connect and response/transfer timeout and authentication
//Usage: Exactly as PHP's SoapClient class, except that some new options are available:
// timeout The response/transfer timeout in milliseconds; 0 == default SoapClient / CURL timeout
// connecttimeout The connection timeout; 0 == default SoapClient / CURL timeout
// sslverifypeer FALSE to stop SoapClient from verifying the peer's certificate
// sslversion The SSL version (2 or 3) to use. By default PHP will try to determine this itself, although in some cases this must be set manually
// sslverifyhost 1 to check the existence of a common name in the SSL peer certificate. 2 to check the existence of a common name and also verify that
@RobThree
RobThree / PhonenumberGrabber.cs
Last active December 13, 2015 16:58
Tries to grab phonenumbers from an active control (selected text) in an active window. Uses a TextSelectionReader internally (see https://gist.github.com/RobThree/4943725).
using System;
using System.Linq;
using System.Text.RegularExpressions;
/// <summary>
/// Tries to grab phonenumbers from an active control (selected text) in an active window. Uses
/// a <see cref="TextSelectionReader"/> internally.
/// </summary>
public class PhonenumberGrabber
{
@RobThree
RobThree / linqhelpers.cs
Last active April 8, 2023 21:39
Linq extensions: Diff, ToChunks and ExecuteChunked
using System;
using System.Linq;
using System.Collections.Generic;
//Sample program demonstrating the linq extensions (below Progam class)
class Program
{
static void Main(string[] args)
{
//Demonstrate Diff
using System;
using System.Linq;
using System.Text;
//Demonstrate usage
class Program
{
static void Main(string[] args)
{
var ww = new WhitespaceWatermarker();
@RobThree
RobThree / exampleclassesandinterfaces.cs
Created November 1, 2013 10:50
An improvement upon http://stackoverflow.com/a/4100126/215042. This factory can be used as a generic factory. Improvements are, amongst others: • Generics • Being able to specify case(in)senstivity when resolving instances • Constructor overloads; the default will assume the Executing Assembly, other assemblies can be passed using an overload of…
public interface IFood
{
bool IsTasty { get; }
}
public class Hamburger : IFood
{
public bool IsTasty { get { return true; } }
}
@RobThree
RobThree / ratelimiter.php
Last active December 16, 2019 21:34
Simple, rude, rate limiter (using memcache).
<?php
/* Very simple, crude, rate limiter */
/*
Assumes _MEMCACHEDSITEPREFIX, _MEMCACHEDHOST and _MEMCACHEDPORT are `defined`:
define('_MEMCACHEDHOST', '127.0.0.1');
define('_MEMCACHEDPORT', 11211);
define('_MEMCACHEDSITEPREFIX', 'mysite');
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Program
{
static void Main(string[] args)
{
var duplicates = new DirectoryInfo(@"G:\sampling")