Skip to content

Instantly share code, notes, and snippets.

@thekid
thekid / ThrowableSecurityExtensions.class.php
Created March 23, 2012 08:27
ThrowableSecurityExtensions - alternative to pull request #136
<?php
/* This class is part of the XP framework
*
* $Id$
*/
/**
* Throwable extension methods
*
* @see https://github.com/xp-framework/xp-framework/pull/136
@thekid
thekid / commandline-reflect-comments.diff
Created March 24, 2012 14:03
XP Tools: Command line reflection + "-v" and "-vv"
diff --git a/tools/src/main/php/xp/runtime/Reflect.class.php b/tools/src/main/php/xp/runtime/Reflect.class.php
index 58b2bf4..8941f2f 100644
--- a/tools/src/main/php/xp/runtime/Reflect.class.php
+++ b/tools/src/main/php/xp/runtime/Reflect.class.php
@@ -33,11 +33,13 @@
* Prints methods - static first, rest then
*
* @param lang.reflect.Method[] methods
+ * @param bool methodComments
*/
@thekid
thekid / screenshot.png
Created June 29, 2012 09:15
Continuous unittest runner
inotifywait -r -m src/ | while read line ; do echo -e "\033]0;"`unittest src | tee unittest.tmp | tail -n 3 | head -n 1`"\007"; cat unittest.tmp ; rm unittest.tmp ; done
@thekid
thekid / win7.certs
Created December 18, 2012 16:32
The Windows 7 certificates exported as described by [this tutorial](https://github.com/xp-framework/xp-framework/pull/209#issuecomment-11169316)
Certificate:
Data:
Version: 1 (0x0)
Serial Number:
7d:d9:fe:07:cf:a8:1e:b7:10:79:67:fb:a7:89:34:c6
Signature Algorithm: sha1WithRSAEncryption
Issuer: C=US, O=VeriSign, Inc., OU=Class 3 Public Primary Certification Authority - G2, OU=(c) 1998 VeriSign, Inc. - For authorized use only, OU=VeriSign Trust Network
Validity
Not Before: May 18 00:00:00 1998 GMT
Not After : Aug 1 23:59:59 2028 GMT
diff --git a/core/src/main/php/lang/AbstractClassLoader.class.php b/core/src/main/php/lang/AbstractClassLoader.class.php
index 2b81b01..2992162 100644
--- a/core/src/main/php/lang/AbstractClassLoader.class.php
+++ b/core/src/main/php/lang/AbstractClassLoader.class.php
@@ -19,11 +19,12 @@
* Load the class by the specified name
*
* @param string class fully qualified class name io.File
+ * @param string intent default NULL what kind of class we're looking for
* @return lang.XPClass
@thekid
thekid / String.class.php
Last active December 15, 2015 11:49
The iconv and mbstring implementations of the `String` class used for comparison in xp-framework/xp-framework#63
<?php
/* This class is part of the XP framework
*
* $Id$
*/
uses('lang.types.Character', 'lang.types.Bytes');
if (extension_loaded('mbstring')) {
fputs(STDERR, "String.mbstring.partial.php\n");
@thekid
thekid / rescue.php
Last active December 15, 2015 15:18
Ideas for handling PHP Warnings: * begin ... rescue (inspired by Ruby) * trap
<?php
function rescue($mask, $handle) {
return function($code, $message, $file, $line, $context) use($mask, $handle) {
if ($code & $mask) {
return $handle($code, $message, $file, $line, $context);
}
};
}
function begin($try, $handle) {
<?php
use \util\profiling\Timer;
use \lang\Runtime;
class EndsWithTest extends Object {
public static function main($args) {
foreach (['not-contained', 'contained'] as $needle) {
foreach (['', 'Hello runners', file_get_contents(__FILE__), file_get_contents('README.md')] as $haystack) {
$haystack.= 'contained';
@thekid
thekid / sync.sh
Last active December 21, 2015 09:39
Sync directory with an ID / name combination
#!/bin/sh
dir=${1-test}
mkdir -p $dir
rm -f $dir/updated
while read input ; do
id=${input%=*}
name=${input#*=}
@thekid
thekid / args.c
Created September 15, 2013 15:10
Output UTF-8 to Windows Shell
#include <wchar.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
int wmain(int argc, wchar_t** argv) {
int i;
_setmode(_fileno(stdout), _O_U8TEXT);