<?php
class One {
static function echoGetClass() { echo get_class()."\n"; }
private static $it;
# chaining is possible if you return the class name! ...
static function setIt($it) { One::$it = $it; return 'One';}
static function echoIt() { echo One::$it; return 'One';}
<?php | |
$iter = 500000; | |
$start = microtime(true); | |
$n = 0; | |
for ($c=0; $c<7*$iter; $c++) { | |
$i = $c % 16; | |
if ($i===0) $n += 0; |
<?php | |
/** | |
* Node is a smart array object inspired by the Node/Tree data structure and the | |
* UNIX file system's inodes. Just a UNIX directory has a hidden file called | |
* '..' in every directory which is a reference to the parent directory, a Node | |
* object has $node['..'] which is a reference to the parent Node, or itself | |
* if there is no parent Node meaning the Node is 'root', and it's $node['/'] | |
* element which would also be reference to itself if root. | |
* | |
* Basically a Node is an array on steroids but why would you need this? Nodes |
Array are not object in PHP but PHP does give us some ways to make object that act like arrays. First, there is the ArrayObject class which is pretty close to what you have with a normal array (you can iterate it, use [] etc.) If you use it as a parent for your class you can add methods to it.
class ArrObj extends ArrayObject{
// add methods here
Zenity is great to give your Bash scripts a nice, albiet minimal, graphical interface. If you are the type of programmer that likes to stick by the 80 character per line rule you'll likely find using it annoying as it involoves some very long statements. On top of that, the commands and switches are descriptive but not quick to type. A lot of it is unavoidable but some is not.
zenity --file-selection --save --confirm-overwrite --title "Your Title"
The term "Parameters" in the context of a shell command line or shell script differs from what it means for functions and methods in other programming languages. In most programming languages, each parameter is separated from the next with a comma whereas in the shell spaces are typically what delimits the parameters, which can be overridden with double quotes.
In Ruby and in the Shell, once you assign or pass a string with double quotes the double quotes are used to indicate the beginning and end but do not become part of the actual eventual value. Take this Ruby script as an example:
arg1 = "one"
#!/usr/bin/env bash | |
# BAShIC - BASIC interpreter written in Bash | |
# Based on bournebasic by Brandon S. Allbery 1987 | |
# | |
# 10 print "Enter any number and I will double it for you "; | |
# 20 input x | |
# 30 y = 2*x | |
# 40 print "The answer is "; | |
# 50 print y | |
# 60 print "Enter -1 if you want to continue." |
rules https://gist.github.com/radar/996779
apt-get install irssi
Enter irssi, connect to freenode and setup authorization: