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 converts errors into exceptions, but if the error is caused | |
//by an argument being invalid (for example failing a typehint), it gets converted into an InvalidArgumentException | |
function handle($code, $message, $file, $line) { | |
//This test might be naive but it worked in my very very simple test code :) | |
if(strpos($message, 'Argument ') === 0) { | |
throw new InvalidArgumentException($message); | |
} | |
else { | |
throw new ErrorException($message, 0, $code, $file, $line); |
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 plugin automatically converts requests made with GET parameter "dojo_io_iframe" into XMLHttpRequests | |
* | |
* This allows transparent handling of iframe transport requests with code that handles XHR requests, since they're | |
* both essentially the same anyway - only the transport is different. | |
*/ | |
class Wantlet_Controller_Plugin_IframeRequestHandler extends Zend_Controller_Plugin_Abstract { | |
private $isIframe = false; |
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
{-# LANGUAGE ScopedTypeVariables #-} | |
module DynLoad ( | |
loadSourceGhc, | |
execFnGhc | |
) where | |
import Control.Exception (throw) | |
import GHC hiding (loadModule) | |
import GHC.Paths (libdir) | |
import HscTypes (SourceError, srcErrorMessages) |
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
# | |
# This script scrapes your soldier statistics from Battlelog | |
# NOTE: This is just a very quick demonstration, it doesn't really do much as-is, besides | |
# authenticate to Battlelog and get you a dict of your soldier's statistics. | |
# There is no error handling, no anything. It will only work if everything goes well. | |
# | |
# | |
# Input your Origin username and password into the params dict below and it should work. | |
# | |
# In the very bottom, the stats dict will contain the data from the Battlelog JSON response. |
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 | |
use Doctrine\ORM\EntityRepository; | |
class Wantlet_Validate_EmailAvailable extends Zend_Validate_Abstract { | |
const NOT_AVAILABLE = 'notAvailable'; | |
protected $_messageTemplates = array( | |
self::NOT_AVAILABLE => "Email address '%value%' is already in use" | |
); |
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
parallel = (ops) -> | |
results = [] | |
numOps = ops.length | |
errHandler = null | |
hadError = false | |
okHandler = null | |
for op, num in ops | |
do (num) -> |
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
870MCS | |
Death | |
M16A4 | |
DamageArea | |
USAS-12 | |
Model98B | |
Weapons/SCAR-H/SCAR-H | |
Weapons/AK74M/AK74 | |
Weapons/M416/M416 | |
M240 |
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
//following functions would perform some operations, which would either succeed or fail, | |
//which would be indicated by the function returning true or false | |
function a() { | |
//do something which returns true or false | |
} | |
function b() { | |
//do something which returns true or false | |
} |
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 | |
namespace Wantlet\ORM; | |
use Zend_Paginator_Adapter_Interface; | |
use Doctrine\ORM\Query; | |
/** | |
* Zend_Paginator adapter for Doctrine 2 queries | |
*/ | |
class QueryPaginator implements Zend_Paginator_Adapter_Interface { |
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
multiCheckBoxList :: (Eq a, RenderMessage master FormMessage, RenderMessage master msg) => [(msg, a)] -> Field sub master [a] | |
multiCheckBoxList = multiCheckBox . optionsPairs | |
multiCheckBox :: (Eq a, RenderMessage master FormMessage) => GHandler sub master (OptionList a) -> Field sub master [a] | |
multiCheckBox opts' = Field | |
{ fieldParse = \rawVals -> do | |
opts <- opts' | |
let (lefts, rights) = partitionEithers $ map (fieldParser opts) rawVals | |
if (length lefts) > 0 |