How to implement this substring replacement rule?
- %% is replaced with % and %x is replaced with #
which would do, for example,
abc %x def => abc # def
abc %%x def => abc %x def
abc %%%x def => abc %# def
abc %%%%x def => abc %%x def
| <?php | |
| // Some people object to this use of the ternary. I think it's fine so long as each | |
| // condition-value pair fits nicely on one line. If so then the structure is highly | |
| // expressive. The value $var takes is very obvious. The logic that | |
| // this condition => that value, this condition => that value, etc. is plain to see. | |
| $var = | |
| condition1 ? 'value1' : ( | |
| condition2 ? 'value2' : ( | |
| condition3 ? 'value3' : ( |
How to implement this substring replacement rule?
which would do, for example,
abc %x def => abc # def
abc %%x def => abc %x def
abc %%%x def => abc %# def
abc %%%%x def => abc %%x def
| #!/bin/sh | |
| # What it does: | |
| # - Start tmux | |
| # - Divide the term window into two panes: | |
| # * small lower pane that runs "sleep 60; sudo ipfw disable firewall", | |
| # * large upper pane with a shell in it. | |
| # | |
| # Do your dangerous IPFW work in the upper pane. | |
| # When done, switch to lower pane (Crtl-B, down arrow) and kill it with Ctrl-C |
| (function ($) { | |
| 'use strict'; | |
| /** | |
| * Makes contenteditable elements within a container generate change events. | |
| * | |
| * When you do, e.g. $obj.editable(), all the DOM elements with attribute contenteditable | |
| * that are children of the DOM element $obj will trigger a change event when their | |
| * contents is edited and changed. | |
| * | |
| * See: http://html5demos.com/contenteditable |
| <?php | |
| public function rules() { | |
| return array( | |
| array('a', 'needOneOf', 'or' => array('b', 'c', 'd')), | |
| ); | |
| } | |
| public function needOneOf($attr, $params) { | |
| array_unshift($params['or'], $attr); |
| <html> | |
| <head></head> | |
| <body> | |
| <p><a id="theajaxlink" href="xhrhandler.php?p=1&q=2">text</a></p> | |
| <script type="text/javascript"> | |
| (function () { | |
| 'use strict'; | |
| var clickhandler = function (e) { | |
| var $that = $(this); | |
| e.preventDefault(); |
| <?php | |
| ... | |
| 'clientScript' => array( | |
| 'class' => 'CClientScript', | |
| 'packages' => array( | |
| 'jquery.ui' => array( | |
| 'basePath' => 'ext.jquery-ui-custom', | |
| 'js' => array( | |
| 'js/jquery-ui-1.8.18.custom' . (YII_DEBUG ? '' : '.min') . '.js' |
| #!/usr/local/bin/php | |
| <?php | |
| $error = false; | |
| $errno = 0; | |
| try { | |
| $db = new PDO('mysql:dbname=stations;host=localhost', 'root', 'password'); | |
| $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
| /** @var $slave_status StdClass */ |
| <?php | |
| // On my mac, cmd-opt-L reformats my php files according to the code style in effect. | |
| // The following is how PhpStorm auto-formats this statement. | |
| // What do I have to set in the code style so it comes out right? | |
| if (isset( | |
| $_SESSION['one'], | |
| $_SESSION['two'], | |
| $_SESSION['three'], |
| <?php | |
| preg_match( | |
| '%' | |
| . preg_quote($marker, '%') | |
| . '\{ | |
| (?:[^{}]*\{ | |
| (?:[^{}]*\{ | |
| (?:[^{}]*\{ | |
| (?:[^{}]*\{ |