Untitled Ruby (23-May @ 08:00)
Syntax Highlighted Code
- def say_hello subj
- puts "Hello, subj"
- end
Plain Code
def say_hello subj
puts "Hello, subj"
end
Untitled C++ (15-Feb @ 19:26)
Syntax Highlighted Code
- #ifndef JUI_VARS1234
- #define JUI_VARS1234
- #include <string>
- [74 more lines...]
Plain Code
#ifndef JUI_VARS1234
#define JUI_VARS1234
#include <string>
#include <QObject>
class QTextEdit;
class QSpinBox;
class ViewManager;
class UiVariables : public QObject
{
Q_OBJECT
public:
QSpinBox* sizeDial;
QSpinBox* widthDial;
QSpinBox* startDial;
QSpinBox* scaleDial;
QSpinBox* zoomDial;
QSpinBox* offsetDial;
QTextEdit* textArea;
UiVariables(ViewManager* vm = NULL);
UiVariables(QTextEdit*,ViewManager* vm = NULL);
UiVariables(const UiVariables& copy,ViewManager* vm = NULL);
UiVariables operator= (const UiVariables& copy);
void setViewManager(ViewManager* vm = NULL);
ViewManager* getViewManager();
class QInterface : public QObject {
QInterface(UiVariables parent){ ui = parent; }
public slots:
inline void print(const char* message) {ui.print(message); }
inline void print(std::string s) {ui.print(message); }
inline void printHtml(std::string) {ui.print(message); }
inline void print(const char* s, int num) {ui.print(message); }
inline void printNum(int num) {ui.print(message); }
inline void print(QString) {ui.print(message); }
inline void setSize(int num) { ui.setSize(num); }
inline void setWidth(int num) { ui.setWidth(num); }
inline void setStart(int num) { ui.setStart(num); }
inline void setScale(int num) { ui.setScale(num); }
inline void setZoom(int num) { ui.setZoom(num); }
inline void setOffset(int num) { ui.setOffset; }
private:
UiVariables ui;
};
public:
void print(const char*);
void print(std::string s);
void printHtml(std::string);
void print(const char* s, int num);
void printNum(int num);
void print(QString);
void setSize(int num);
void setWidth(int num);
void setStart(int num);
void setScale(int num);
void setZoom(int num);
void setOffset(int num);
//void print(int num1, int num2);
signals:
void editingFinished();
private:
void createConnections();
ViewManager* view;
};
#endif
Untitled JavaScript (8-Feb @ 22:52)
Syntax Highlighted Code
- (function($){
- $(document).ready(function(){
- //jQuery code here
- [2 more lines...]
Plain Code
(function($){
$(document).ready(function(){
//jQuery code here
})
})(jQuery)
Untitled PHP (26-Nov @ 07:37)
Syntax Highlighted Code
- <?php
- class AbstractPostType{
- [20 more lines...]
Plain Code
<?php
class AbstractPostType{
protected $_typeObj;
protected $_metaObj;
protected $_taxonomyObj;
private names = array('label','singular_label',YADDA_YADDA);
private $label = __('Portfolio');
private $singular_label =
private function __construct(){
}
protected constructionHelper(){
$args = array();
foreach ($names as $name) {
$args[$name] = $this->$name;
}
$this->typeObj = new customPostType($this->typeName,$args);
}
}
Untitled C++ (2-Nov @ 15:16)
Syntax Highlighted Code
- #include <QString>
- namespace annotation {
- #ifndef RANGE
- [47 more lines...]
Plain Code
#include <QString>
namespace annotation {
#ifndef RANGE
#define RANGE
class Range {
public:
int start;
int end;
int file;
Range(int start_value, int end_value, int file_id = 0){ start = start_value, end = end_value, file = file_id; }
QString toString() { return QString("%3: %1 - %2").arg(start).arg(end).arg(file); }
};
#endif
#ifndef SCALAR_VALUE
#define SCALAR_VALUE
class Scalar {
private:
int value;
public:
Scalar(int val) { value = val; }
operator int(){ return value; }
};
#endif
#ifndef INDEX_IDENTIFIER
#define INDEX_IDENTIFIER
class IndexIdentifier {
private:
int id;
IndexIdentifier operator=(const &IndexIdentifier index) { id = index; return this; }
public:
IndexIdentifier(int index) { id = index; }
operator int(){ return id; }
};
#endif
#ifndef OBJECT_REFERENCE
#define OBJECT_REFERENCE
class ORef {
private:
int id;
public:
ORef(int index) { id = index;}
Operator int() { return id; }
};
#endif
}
Segfaults (9-Sep @ 17:39)
Syntax Highlighted Code
- #ifndef Q_ANNOTATION_DATA_MANAGER
- #define Q_ANNOTATION_DATA_MANAGER
- #include <QtCore>
- [79 more lines...]
Plain Code
#ifndef Q_ANNOTATION_DATA_MANAGER
#define Q_ANNOTATION_DATA_MANAGER
#include <QtCore>
class QAnnotationDataManager : public QObject {
Q_OBJECT
public:
QAnnotationDataManager();
QList<QUrl>* directoryHistory();
QList<QUrl>* directoryHistory(QList<QUrl>*);
QList<QUrl>* directoryHistory(QUrl, bool remove = false );
QUrl* directoryHistory(int, bool remove = false );
QUrl* getCurrentDirectory();
QList<QUrl>* repositoryHistory();
QList<QUrl>* repositoryHistory(QList<QUrl>*);
QList<QUrl>* repositoryHistory(QUrl, bool remove = false );
QUrl* repositoryHistory(int, bool remove = false );
private:
QSettings annotationConfiguration;
QUrl* directory;
QUrl* repository;
QString username;
QString password;
bool authenticated;
};
#endif
QAnnotationDataManager::QAnnotationDataManager(){
QSettings* annotationConfiguration = new QSettings("Skittle","AnnotationSettings");
directory = new QUrl("http://annotations.dnaskittle.org/directory");
}
QList<QUrl>* QAnnotationDataManager::directoryHistory(){
QList<QUrl>* history = new QList<QUrl>();
{// start(rough in)
history->append(QUrl("http://google.com"));
history->append(QUrl("http://dnaskittle.com"));
history->append(QUrl("http://sourceforge.net/projects/skittle"));
history->append(QUrl("http://yahoo.com"));
history->append(QUrl("http://msn.com"));
history->append(QUrl("http://launchpad.net"));
// end(rough in)
}
return history;
}
QList<QUrl>* QAnnotationDataManager::directoryHistory(QList<QUrl>* merge){
return new QList<QUrl>();
}
QList<QUrl>* QAnnotationDataManager::directoryHistory(QUrl, bool remove){
return new QList<QUrl>();
}
QUrl* QAnnotationDataManager::directoryHistory(int index, bool remove){
return new QUrl();
}
QList<QUrl>* QAnnotationDataManager::repositoryHistory(){
return new QList<QUrl>();
}
QList<QUrl>* QAnnotationDataManager::repositoryHistory(QList<QUrl>* merge){
return new QList<QUrl>();
}
QList<QUrl>* QAnnotationDataManager::repositoryHistory(QUrl, bool remove){
return new QList<QUrl>();
}
QUrl* QAnnotationDataManager::repositoryHistory(int index, bool remove){
return new QUrl();
}
QUrl* QAnnotationDataManager::getCurrentDirectory(){
return directory;
}
PsuedoCode (24-Aug @ 17:51)
Syntax Highlighted Code
- QFrame master:
- QLabels [browse level (from stack 'ants')] Ants
- QFrame [from current level] 'body'
- QButton 'close'
- [148 more lines...]
Plain Code
QFrame master:
QLabels [browse level (from stack 'ants')] Ants
QFrame [from current level] 'body'
QButton 'close'
QProgress [global operation status] 'curOp'
{
default QFrame: directory
qframeSwitch(frame)
{
body->emptyframe
reset curOp 0/0
while (!ready(frame)) ;;
body->frame
}
fileSum(fileId)
{
return stored filesum for CurrentFile
}
fileSumByName (fileURI)
{
return stored filesum for fileURI
}
fileIDfromName(fileURI)
{
return fileID for fileURI
}
}
QFrame directory
QLabel [access Errors] 'dirError'
QLabel [constant text] 'directory'
QUrlInput [defaults to most recent or dnaskittle.org/master.dir] 'directoryUrl'
QListBox [directories from settings] 'directoryHistory'
QButton 'read directory'
QButton 'load from history'
QButton 'operate locally'
{
initialize curFileID
read directory (loading)
update curOp from reply-status
read directory:
if success:
initialize directoryID, repoList, repoHist
qframeSwitch(repositories)
else: error -> dirError
load from history
initialize repoHist
qframeSwitch(repositories)
operatelocally
local -> true
qframeSwitch(repositoryDashboard)
}
QFrame repositories
QLabel [access Errors] 'repoError'
QLabel [constant text] 'repository'
QUrlInput [defaults to most recent or repository.dnaskittle.org] 'repositoryUrl'
QListBox [repositories from directory, history (two sections)] 'repositoryHistory'
QButton 'read repository'
{
read repository
initialize repositoryID, repositoryName
if autheticated
qframeSwitch(repositoryDashboard)
else
qframeSwitch(authenticate)
read repository (loading)
update curOp from reply-status
}
QFrame authenticate
QLabel [authentication Errors] 'authError'
QLabel 'username' QInput 'username'
QLabel 'password' QInput 'password'
QButton 'sign in'
{
'sign in':
if valid('username','password')
initialize userID
authenticated -> true
qframeSwitch(repositoryDashboard)
else
authError->"Invalid username/password"
}
QFrame repositoryDashboard
QLabel [operation errors] 'opError'
QGroup 'file maintenance'
QButton 'synchronize with server'
QButton 'edit file metaData' QCombo 'filename'
QGroup 'annotation maintenance'
QButton 'download by group'
QButton 'upload annotations'
QButton 'update annotations'
QButton 'remove annotations'
QButton 'log off'
{
'download by group':
qframeSwitch(groups)
'log off'
authenticated -> false
uninitialize userID
qframeSwich(repositories)
}
QFrame groups
QLabel [annotation Fetch Errors] 'groupError'
QLabel [constant text] 'groups'
QInput [defaults to 'all'(0) (tokenize on ',')] 'groupID'
QListBox [list repository groups(by userid)] 'groupList'
QButton 'get annotations'
{
'get annotations':
initialize groups from groupID
get annotations by fileSum(curFileID), groups
if success, count > 1
initialize annotList
qframeSwitch(annotations)
else
groupError -> "Unable to Fetch Annotations, network Error or no Annotations Found"
(loading)
update curOp from reply-status
}
QFrame annotations
QLabel [annotation Fetch Errors] 'annotError'
QLabel [constant text] 'groups'
QInput [defaults to 'all'(0) (tokenize on ',')] 'groupID'
QListBox [list repository groups(by userid)] 'groupList'
QButton 'get annotations'
{
'get annotations':
get annotations by curFileID, groups
if success, count > 1
initialize annotList
qframeSwitch(annotations)
else
groupError -> "Unable to Fetch Annotations, network Error or no Annotations Found"
(loading)
update curOp from reply-status
}
Untitled C++ (31-Jul @ 16:22)
Syntax Highlighted Code
- typedef map<const char*, const char*> param_map;
- param_map parseNamedParams(string params,char encoding[2] = "=;") {
- param_map parsed;
- [26 more lines...]
Plain Code
typedef map<const char*, const char*> param_map;
param_map parseNamedParams(string params,char encoding[2] = "=;") {
param_map parsed;
string key;
string temp;
int part = 0;
for(int i=0;i<params.size();i++) {
if(params[i] == encoding[0])
{
key = temp;
temp.clear();
}
else if (params[i] == encoding[1]) {
if (! temp.empty()) parsed[key] = temp;
else parsed[key] = key;
temp.clear();
key.clear();
}
else {
temp += params[i];
}
}
if (! temp.empty()) parsed[key] = temp;
else parsed[key] = key;
return parsed;
}
groups of 3 or 4 (27-May @ 23:16)
Syntax Highlighted Code
- <?php
- for ($i = 1; $i < 50; $i++){
- if ($total != 5 && $total > 2) {
- [59 more lines...]
Plain Code
<?php
for ($i = 1; $i < 50; $i++){
if ($total != 5 && $total > 2) {
$fours = ceil($total / 4) - ($threes = ($total % 4) ? (4 - ($total % 4)) : 0);
echo "$i = (4 x $fours) + (3 x $threes); check: " . ((3* $threes) + (4 * $fours)) . "\n";
}
else
{
$fours = floor($i / 4); $threes = floor( ($remainder = ($i - (4 * $fours))) / 3);
echo "$i: (4x$fours) + (3x$threes) + $remainder = " . (($i == (4 * $fours + 3 * $threes + $remainer )) ? $i : 'invalid') . " : remainer invalid\n";
}
}
?>
output:
1: (4x0) + (3x0) + 1 = invalid : remainer invalid
2: (4x0) + (3x0) + 2 = invalid : remainer invalid
3: (4x0) + (3x1) + 0 = 3 : number is divisible by 3 plus 0 fours
4: (4x1) + (3x0) + 0 = 4 : number is divisible by 4 plus 0 threes
5: (4x1) + (3x0) + 1 = invalid : remainer invalid
6: (4x0) + (3x2) + 0 = 6 : number is divisible by 3 plus 0 fours
7: (4x1) + (3x1) + 0 = 7 : number is divisible by 3 plus 1 fours
8: (4x2) + (3x0) + 0 = 8 : number is divisible by 4 plus 0 threes
9: (4x0) + (3x3) + 0 = 9 : number is divisible by 3 plus 0 fours
10: (4x1) + (3x2) + 0 = 10 : number is divisible by 3 plus 1 fours
11: (4x2) + (3x1) + 0 = 11 : number is divisible by 3 plus 2 fours
12: (4x3) + (3x0) + 0 = 12 : number is divisible by 4 plus 0 threes
13: (4x1) + (3x3) + 0 = 13 : number is divisible by 3 plus 1 fours
14: (4x2) + (3x2) + 0 = 14 : number is divisible by 3 plus 2 fours
15: (4x0) + (3x5) + 0 = 15 : number is divisible by 3 plus 0 fours
16: (4x4) + (3x0) + 0 = 16 : number is divisible by 4 plus 0 threes
17: (4x2) + (3x3) + 0 = 17 : number is divisible by 3 plus 2 fours
18: (4x0) + (3x6) + 0 = 18 : number is divisible by 3 plus 0 fours
19: (4x1) + (3x5) + 0 = 19 : number is divisible by 3 plus 1 fours
20: (4x5) + (3x0) + 0 = 20 : number is divisible by 4 plus 0 threes
21: (4x0) + (3x7) + 0 = 21 : number is divisible by 3 plus 0 fours
22: (4x1) + (3x6) + 0 = 22 : number is divisible by 3 plus 1 fours
23: (4x2) + (3x5) + 0 = 23 : number is divisible by 3 plus 2 fours
24: (4x6) + (3x0) + 0 = 24 : number is divisible by 4 plus 0 threes
25: (4x1) + (3x7) + 0 = 25 : number is divisible by 3 plus 1 fours
26: (4x2) + (3x6) + 0 = 26 : number is divisible by 3 plus 2 fours
27: (4x0) + (3x9) + 0 = 27 : number is divisible by 3 plus 0 fours
28: (4x7) + (3x0) + 0 = 28 : number is divisible by 4 plus 0 threes
29: (4x2) + (3x7) + 0 = 29 : number is divisible by 3 plus 2 fours
30: (4x0) + (3x10) + 0 = 30 : number is divisible by 3 plus 0 fours
31: (4x1) + (3x9) + 0 = 31 : number is divisible by 3 plus 1 fours
32: (4x8) + (3x0) + 0 = 32 : number is divisible by 4 plus 0 threes
33: (4x0) + (3x11) + 0 = 33 : number is divisible by 3 plus 0 fours
34: (4x1) + (3x10) + 0 = 34 : number is divisible by 3 plus 1 fours
35: (4x2) + (3x9) + 0 = 35 : number is divisible by 3 plus 2 fours
36: (4x9) + (3x0) + 0 = 36 : number is divisible by 4 plus 0 threes
37: (4x1) + (3x11) + 0 = 37 : number is divisible by 3 plus 1 fours
38: (4x2) + (3x10) + 0 = 38 : number is divisible by 3 plus 2 fours
39: (4x0) + (3x13) + 0 = 39 : number is divisible by 3 plus 0 fours
40: (4x10) + (3x0) + 0 = 40 : number is divisible by 4 plus 0 threes
41: (4x2) + (3x11) + 0 = 41 : number is divisible by 3 plus 2 fours
42: (4x0) + (3x14) + 0 = 42 : number is divisible by 3 plus 0 fours
43: (4x1) + (3x13) + 0 = 43 : number is divisible by 3 plus 1 fours
44: (4x11) + (3x0) + 0 = 44 : number is divisible by 4 plus 0 threes
45: (4x0) + (3x15) + 0 = 45 : number is divisible by 3 plus 0 fours
46: (4x1) + (3x14) + 0 = 46 : number is divisible by 3 plus 1 fours
47: (4x2) + (3x13) + 0 = 47 : number is divisible by 3 plus 2 fours
48: (4x12) + (3x0) + 0 = 48 : number is divisible by 4 plus 0 threes
49: (4x1) + (3x15) + 0 = 49 : number is divisible by 3 plus 1 fours
Untitled PHP (17-May @ 23:14)
Syntax Highlighted Code
- <?php if(is_front_page() and is_page()):
- $thisPage = $post
- ?>
- <h2>Recent Posts</h2>
- [6 more lines...]
Plain Code
<?php if(is_front_page() and is_page()):
$thisPage = $post
?>
<h2>Recent Posts</h2>
<ul>
<?php foreach(wp_get_recent_posts('numberposts=5') as $post):
setup_postdata($post); ?>
<li><a href="' . . '" title="Look ' <?php the_title_attribute(); ?>'" > <?php the_title(); ?></a> </li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Untitled XML (13-May @ 17:08)
Syntax Highlighted Code
- <?xml version="1.0" ?>
- <?xml-stylesheet type="text/xsl" href="howto.xsl" ?>
- <document title="Wordpress Themes">
- <section title="Step-by-Step">
- [19 more lines...]
Plain Code
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="howto.xsl" ?>
<document title="Wordpress Themes">
<section title="Step-by-Step">
<section title="Comment header">
<code>
/*
Theme Name: Rose
Theme URI: the-theme's-homepage
Description: a-brief-description
Author: your-name
Author URI: your-URI
Template: use-this-to-define-a-parent-theme--optional
Version: a-number--optional
.
General comments/License Statement if any.
.
*/
</code>
</section>
</section>
<section title="See Also">
</section>
</document>
Untitled HTML (6-May @ 05:08)
Syntax Highlighted Code
Plain Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Your title here</title>
</head>
<body>
<div id="header" class="container_12">
<div id="" class="grid_12 ">
</div>
</div>
<div id="content" class="container_12">
<div id="" class="grid_3 ">
</div>
<div id="" class="grid_6">
</div>
<div id="" class="grid_3">
</div>
</div>
<div id="footer" class="container_12">
<div id="" class="grid_3 ">
</div>
<div id="" class="grid_3 ">
</div>
<div id="" class="grid_3 ">
</div>
<div id="" class="grid_3 ">
</div>
</div>
</body>
</html>
Untitled PHP (30-Apr @ 05:09)
Syntax Highlighted Code
- <?php
- function debug_this($value)
- {
- [206 more lines...]
Plain Code
<?php
$STATES = array("WAIT","SCOPE","CRITERIA","ITEM","QUOTE");
function debug_this($value)
{
echo $value;
}
function is_escaped($escape_index,$current_index)
{
return ($escape_index != -1 && $escape_index == ($current_index - 1));
}
function add_and_reset_scope(&$context, &$scope,&$criteria = array())
{
if (isset($context[$scope]) && is_array($context[$scope])) $criteria = array_merge($criteria,$context[$scope]);
$context[$scope] = $criteria;
$criteria = array();
$scope = "";
}
function add_new_criteria(&$criteria,$initial_character)
{
$criteria[] = $initial_character;
debug_this( "\10\tNEW CRITERIA BEGINS: " . $criteria[count($criteria) - 1] . "\n");
}
function add_to_current_criteria(&$criteria,$value){
$last = count($criteria) - 1;
$criteria[$last] .= $value;
debug_this("\10\tCURRENT: " . $criteria[$last] . "\n");
}
function setState(&$state,$newState,$line = -1) {
global $STATES; $out = "[$line]: STATE ";
if(isset($state)) if (isset($STATES[($index = log($state,2))])) $out .= $STATES[$index]. "($state)";
else $out .= "\"$state\"";
else $out .= "NULL";
$out .= ", CHANGING TO " . $STATES[log($newState,2)] . "($newState)\n";
debug_this($out);
$state = $newState;
}
function BBranch($branch,$state,$value,$line = -1)
{
global $STATES;
debug_this("[$line] BRANCH {$branch} [" . $STATES[log($state,2)] . "]: $value \n" );
}
function parse($str,$default_scope = 'group'){
//states
global $STATES;
foreach ($STATES as $INDEX => $STATENAME) {
$$STATENAME = pow(2,$INDEX);
debug_this($STATENAME . " = " . $$STATENAME . "\n");
}
debug_this("\$WAIT = $WAIT\n");
$ERRORS = array();
$escape = -1;
$context = array();
$criteria = array();
$quote = $item = $scope = "";
setState($state,($pre_quote_state = $WAIT),__LINE__);
$str .= " ";
foreach (str_split($str) as $index => $value)
{
if ($state > $QUOTE) setState($state,$WAIT,__LINE__);
if(preg_match("/\s/",$value)){
BBranch('WHITESPACE',$state,$value,__LINE__);
if($state == $ITEM)
{
if (is_escaped($escape,$index)) $item .= $value;
else {
add_to_current_criteria($criteria,"",__LINE__);
if(count($scope)) add_and_reset_scope($context,$scope,$criteria);
setState($state,$WAIT,__LINE__);
}
}
elseif($state == $QUOTE)
{
add_to_current_criteria($criteria,$value);
}
elseif($state == $SCOPE)
{
if($default_scope != ""){
add_new_criteria($criteria,$scope);
add_and_reset_scope($context,$default_scope,$criteria);
setState($state,$WAIT,__LINE__);
}
else add_and_reset_scope($context,$scope);
setState($state,$WAIT,__LINE__);
}
}
elseif(preg_match("/[\:\=]/",$value)) {
BBranch('EQUIV',$state,$value,__LINE__);
if($state == $SCOPE && strlen($scope)) {
//add_and_reset_scope($context,$scope);
setState($state,$CRITERIA,__LINE__);
}
elseif($state & ( $ITEM | $QUOTE )) add_to_current_criteria($criteria,$value);
}
elseif(strstr("\\",$value)){
BBranch('ESCAPE',$state,$value,__LINE__);
if (! is_escaped($escape,$index)) $escape = $index;
else {
if($state & ( $ITEM | $QUOTE )) {
add_to_current_criteria($criteria,$value);
}
if($state & $CRITERIA)
{
add_new_criteria($criteria,$value);
setState($state,$ITEM);
}
}
}
elseif(strstr(",",$value)){
BBranch('COMMA',$state,$value,__LINE__);
if($state == $ITEM)
{
setState($state,$CRITERIA,__LINE__);
}
elseif($state == $SCOPE)
{
add_new_criteria($criteria,$scope);
if($default_scope != ""){
$scope = $default_scope;
setState($state,$CRITERIA,__LINE__);
}
else {
add_and_reset_scope($context,$scope = null,$criteria);
$ERRORS[] = "UNEXPECTED T_COMMA ENCOUNTERED <INDEX: $Index>";
setState($state,$WAIT,__LINE__);
}
}
elseif($state & ( $CRITERIA | $WAIT)) $ERRORS[] = "UNEXPECTED T_COMMA ENCOUNTERED <INDEX: $Index>";
}
elseif(preg_match("/[\"']/",$value)){
BBranch('QUOTE',$state,$value,__LINE__);
if($state == $QUOTE){
debug_this("IS QUOTE ESCAPED: " . ((is_escaped($escape,$index)) ? "YES" : "NO") . "\n");
if ($value == $quote && !is_escaped($escape,$index))
{
setState($state,$pre_quote_state,__LINE__);
$quote = "";
}
elseif($pre_quote_state & ( $CRITERIA | $ITEM))
{
add_to_current_criteria($criteria,$value);
}
elseif($pre_quote_state & ( $WAIT | $SCOPE ))
{
$scope .= $value;
}
}
elseif($state & ( $WAIT | $CRITERIA ))
{
$pre_quote_state = $state;
$quote = $value;
setState($state,$QUOTE,__LINE__);
}
}
else {
BBranch('WORD',$state,$value,__LINE__);
if($state == $WAIT) {
setState($state,$SCOPE,__LINE__);
$scope = $value;
}
elseif($state == $SCOPE) $scope .= $value;
elseif ($state == $CRITERIA)
{
setState($state,$ITEM,__LINE__);
add_new_criteria($criteria,$value);
}
elseif ($state == $ITEM) add_to_current_criteria($criteria,$value);
elseif($state == $QUOTE){
if($pre_quote_state == $WAIT){
$pre_quote_state = $SCOPE;
$scope = $value;
}
elseif($pre_quote_state == $CRITERIA) {
$pre_quote_state = $ITEM;
add_new_criteria($criteria,$value);
}
else
{
add_to_current_criteria($criteria,$value);
}
}
}
}
return $context;
}
function interpret($arr){
$str = "";
$str = print_r($arr,true);
return $str;
}
$strs = array(
"file:hello.fa start:0 end:1322251",
"file:hello.fa group:\"wild dogs\"",
"file:hello.fa group:\"12 angry men\" group:\"11 'angry' men\"",
"file:hello.fa group:\"12 angry men\",\"11 \\\"angry\\\" men\""
);
foreach ($strs as $search){
echo $search . ":\n " . str_replace("\n", "\n\t", interpret(parse($search))). "\n";
}
Untitled PHP (29-Apr @ 04:07)
Syntax Highlighted Code
- <?php
- function myTestFunction($hasDefaultParamters = true)
- {
- [47 more lines...]
Plain Code
<?php
function myTestFunction($hasDefaultParamters = true)
{
echo "Start\n";
echo "num args: " . ($num = func_num_args()). "\n";
if($num)
{
print_r(func_get_args());
}
echo "End\n";
}
myTestFunction("hello","world");
myTestFunction();
/*
output:
Start
num args: 2
Array
(
[0] => hello
[1] => world
)
End
Start
num args: 0
End
*/
function authenticate($u = null,$p = null,$redirect = 0){
if ($numArgs = func_num_args() > 0){
if($numArgs >= 2) {
if($authID = User::__validCredentials($u,$p) {
$this->session->set_userdata(array('user_id'=>$authID));
return $authID;
}
else if ($redirect) {
redirect('/login');
die("Redirecting...");
}
}
}
return 0;
}