private static function derivePrice(...)
{
$price = self::derivePriceUnchecked($vars);
if (isset($price)) {
// CODE HERE
}
if (isset($price)) {
// CODE HERE
}
if (isset($price)) {
// CODE HERE
}
if (isset($price)) {
// CODE HERE
}
if (isset($price)) {
// CODE HERE
}
if (isset($price)) {
// CODE HERE
}
if (isset($price)) {
// CODE HERE
}
if (isset($price)) {
// CODE HERE
}
return $price;
}
if(computedDate != null){
myObject.setDueDate(computedDate);
}
else{
myObject.setDueDate(null);
}
$orderDateTS = strtotime($data['ordertime']);
$nowTS = strtotime('now');
$diff = $nowTS - $orderDateTS;
$diff = $diff / 86400;
$dayDiff = floor($diff);
found in a shopware plugin
StartCoroutine(Patrol());
public IEnumerator Patrol() {
while(true) {
dt.Walk();
yield return new WaitForSeconds(reactionTime);
}
}
func runAnsible(c *cli.Context) {
runAnsibleCmd1(c.String("command"), c.StringSlice("var-file"), c.StringSlice("var"))
}
func runAnsibleCmd1(cmd string, varfiles []string, varstrs []string) {
runAnsibleCmd2(cmd, util.ToVars(varfiles, varstrs))
}
func runAnsibleCmd2(cmd string, vars map[string]interface{}) {
err := exec.SyscallExecute(cmd, vars)
log.Error("Error running ansible command.", "err", err.Error())
}
public static class DecimalHelpers
{
/// <summary>
/// Format a decimal XX.XX to XX,XX%.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static string FormatToStringPercentageValue(this decimal value)
{
return value.ToString().Replace(".", ",").FormatToPercentageValue();
}
}
public static class StringHelpers
{
/// <summary>
/// Add % at the end of the string.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static string FormatToPercentageValue(this string value)
{
return string.Concat(value, "%");
}
}
public static bool ValidateEmailAddress(string emailAddress)
{
string pattern = "^((?>[a-zA-Z\\d!#$%&'*+\\-/=?^_`{|}~]+\x20*|\"((?=[\x01-\x7f])[^\"\\]|\\[\x01-\x7f])*\"\x20*)*(?<angle><))?((?!\\.)(?>\\.?[a-zA-Z\\d!#$%&'*+\\-/=?^_`{|}~]+)+|\"((?=[\x01-\x7f])[^\"\\]|\\[\x01-\x7f])*\")@(((?!-)[a-zA-Z\\d\\-]+(?<!-)\\.)+[a-zA-Z]{2,}|\\[(((?(?<!\\[)\\.)(25[0-5]|2[0-4]\\d|[01]?\\d?\\d)){4}|[a-zA-Z\\d\\-]*[a-zA-Z\\d]:((?=[\x01-\x7f])[^\\\\[\\]]|\\[\x01-\x7f])+)\\])(?(angle)>)$";
if (!String.IsNullOrEmpty(emailAddress) && !(Regex.Match(emailAddress.Trim(), pattern, RegexOptions.IgnoreCase)).Success)
{
return false;
}
return true;
}
String s = "string";
String.valueOf(s).toString();
// just to make sure it's a damn string
while(!s instanceof String) {
String.valueOf(s).toString();
}
Native XML structure:
<?xml version="1.0" encoding="utf-8" ?>
<tree>
<node name="root">
<node name="TELEVISIONS">
<node name="TUBE"/>
<node name="LCD"/>
<node name="PLASMA"/>
</node>
<node name="PORTABLE ELECTRONICS">
<node name="MP3 PLAYERS">
<node name="FLASH"/>
</node>
<node name="CD PLAYERS"/>
<node name="2 WAY RADIOS"/>
</node>
</node>
</tree>
Flattened XML structure (example 1):
<tree>
<node key="0">root</node>
<node key="1" parent="0">TELEVISIONS</node>
<node key="2" parent="1">TUBE</node>
<node key="3" parent="1">LCD</node>
<node key="4" parent="1">PLASMA</node>
<node key="5" parent="0">PORTABLE ELECTRONICS</node>
<node key="6" parent="5">MP3 PLAYERS</node>
<node key="7" parent="6">FLASH</node>
<node key="8" parent="5">CD PLAYERS</node>
<node key="9" parent="5">2 WAY RADIOS</node>
</tree>
Flattened XML structure (example 2):
<tree>
<node>
<name>root</name>
<depth>0</depth>
</node>
<node>
<name>TELEVISIONS</name>
<depth>1</depth>
</node>
<node>
<name>TUBE</name>
<depth>2</depth>
</node>
<node>
<name>LCD</name>
<depth>2</depth>
</node>
<node>
<name>PLASMA</name>
<depth>2</depth>
</node>
<node>
<name>PORTABLE ELECTRONICS</name>
<depth>1</depth>
</node>
<node>
<name>MP3 PLAYERS</name>
<depth>2</depth>
</node>
<node>
<name>FLASH</name>
<depth>3</depth>
</node>
<node>
<name>CD PLAYERS</name>
<depth>2</depth>
</node>
<node>
<name>2 WAY RADIOS</name>
<depth>2</depth>
</node>
</tree>
public override List<Value> Values
{
get
{
if (_values == null && shouldLoadLazily)
{
_values = _lazerLoader.LoadValues<Value>()
}
return _values;
}
set
{
throw new InvalidOperationException("Values are actually readonly- please set in constructor")
}
}
How to create immutable fields in c#
<?php
if(!defined('WPINC')) // MUST have WordPress.
exit ('Do not access this file directly.');
if(!class_exists('pluginName_options_page_class'))
{
/**
* Menu page blah
*
* @package blah
* @since 140617
*/
class pluginName_options_page_class
{
public function __construct()
{
echo '<div class="wrap menu-page">'."\n";
echo '<div class="wp-header-end"></div>'."\n";
echo '<div class="menu-page-toolbox">'."\n";
pluginName_some_other_class::display();
echo '</div>'."\n";
echo '<h2>Options</h2>'."\n";
echo '<table class="menu-page-table">'."\n";
echo '<tbody class="menu-page-table-tbody">'."\n";
echo '<tr class="menu-page-table-tr">'."\n";
echo '<td class="menu-page-table-l">'."\n";
echo '<form method="post" name="plugin_options_form" id="plugin--options-form" autocomplete="off">'."\n";
echo '<input type="hidden" name="plugin_options_save" id="plugin--options-save" value="'.esc_attr(wp_create_nonce('plugin--options-save')).'" />'."\n";
echo '<div class="menu-page-group" title="Account Details">'."\n";
/* includes things like this gem */
echo (!is_multisite() || !pluginName_utils_conds::is_multisite_farm() || is_main_site()) ? '<p>[ Really Long message about something ]</p>'."\n" : '';
/* ... continues until end ... */
echo '</div>'."\n";
}
}
}
new pluginName_options_page_class ();
The entire file is a single class with a constructor. The constructor is ~ 1150 lines of echo statements with a few PHP conditionals thrown in. There are no other methods. The class is instantiated as soon as it is defined. Clever...
case (RSel)
4'b0000:begin
R1e = 1'b0; R2e = 1'b0; R3e = 1'b0; R4e = 1'b0;
end
4'b0001:begin
R1e = 1'b0; R2e = 1'b0; R3e = 1'b0; R4e = 1'b1;
end
4'b0010:begin
R1e = 1'b0; R2e = 1'b0; R3e = 1'b1; R4e = 1'b0;
end
4'b0011:begin
R1e = 1'b0; R2e = 1'b0; R3e = 1'b1; R4e = 1'b1;
end
4'b0100:begin
R1e = 1'b0; R2e = 1'b1; R3e = 1'b0; R4e = 1'b0;
end
4'b0101:begin
R1e = 1'b0; R2e = 1'b1; R3e = 1'b0; R4e = 1'b1;
end
4'b0110:begin
R1e = 1'b0; R2e = 1'b1; R3e = 1'b1; R4e = 1'b0;
end
4'b0111:begin
R1e = 1'b0; R2e = 1'b1; R3e = 1'b1; R4e = 1'b1;
end
4'b1000:begin
R1e = 1'b1; R2e = 1'b0; R3e = 1'b0; R4e = 1'b0;
end
4'b1001:begin
R1e = 1'b1; R2e = 1'b0; R3e = 1'b0; R4e = 1'b1;
end
4'b1010:begin
R1e = 1'b1; R2e = 1'b0; R3e = 1'b1; R4e = 1'b0;
end
4'b1011:begin
R1e = 1'b1; R2e = 1'b0; R3e = 1'b1; R4e = 1'b1;
end
4'b1100:begin
R1e = 1'b1; R2e = 1'b1; R3e = 1'b0; R4e = 1'b0;
end
4'b1101:begin
R1e = 1'b1; R2e = 1'b1; R3e = 1'b0; R4e = 1'b1;
end
4'b1110:begin
R1e = 1'b1; R2e = 1'b1; R3e = 1'b1; R4e = 1'b0;
end
4'b1111:begin
R1e = 1'b1; R2e = 1'b1; R3e = 1'b1; R4e = 1'b1;
end
endcase
case (TSel)
4'b0000:begin
T1e = 1'b0; T2e = 1'b0; T3e = 1'b0; T4e = 1'b0;
end
4'b0001:begin
T1e = 1'b0; T2e = 1'b0; T3e = 1'b0; T4e = 1'b1;
end
4'b0010:begin
T1e = 1'b0; T2e = 1'b0; T3e = 1'b1; T4e = 1'b0;
end
4'b0011:begin
T1e = 1'b0; T2e = 1'b0; T3e = 1'b1; T4e = 1'b1;
end
4'b0100:begin
T1e = 1'b0; T2e = 1'b1; T3e = 1'b0; T4e = 1'b0;
end
4'b0101:begin
T1e = 1'b0; T2e = 1'b1; T3e = 1'b0; T4e = 1'b1;
end
4'b0110:begin
T1e = 1'b0; T2e = 1'b1; T3e = 1'b1; T4e = 1'b0;
end
4'b0111:begin
T1e = 1'b0; T2e = 1'b1; T3e = 1'b1; T4e = 1'b1;
end
4'b1000:begin
T1e = 1'b1; T2e = 1'b0; T3e = 1'b0; T4e = 1'b0;
end
4'b1001:begin
T1e = 1'b1; T2e = 1'b0; T3e = 1'b0; T4e = 1'b1;
end
4'b1010:begin
T1e = 1'b1; T2e = 1'b0; T3e = 1'b1; T4e = 1'b0;
end
4'b1011:begin
T1e = 1'b1; T2e = 1'b0; T3e = 1'b1; T4e = 1'b1;
end
4'b1100:begin
T1e = 1'b1; T2e = 1'b1; T3e = 1'b0; T4e = 1'b0;
end
4'b1101:begin
T1e = 1'b1; T2e = 1'b1; T3e = 1'b0; T4e = 1'b1;
end
4'b1110:begin
T1e = 1'b1; T2e = 1'b1; T3e = 1'b1; T4e = 1'b0;
end
4'b1111:begin
T1e = 1'b1; T2e = 1'b1; T3e = 1'b1; T4e = 1'b1;
end
endcase
Just write assign {R1e, R2e, R3e, R4e} = Rsel assign {T1e, T2e, T3e, T4e} = Tsel
if(date.getFullYear() <= 2017) {
if(date.getMonth() <= 11) {
if(date.getDate() <= 26) {
if(date.getHours() <= 23) {
if(date.getMinutes() <= 59) {
if(date.getSeconds() <= 59) {
//Display popup before 2017-11-27
}
}
}
}
}
}
precision mediump float;
uniform float time;
uniform vec2 resolution;
#define equals =
#define divided /
#define plus +
#define minus -
#define times *
#define by
#define point .
#define zero 0.
#define one 1.
#define five 5.
#define output gl_FragColor
#define then {
#define end }
#define less <
#define than
#define increment ++
#define afterwards ;
#define comma ,
#define semi .5
#define hundred 100.
void main ( void ) then
vec2 uv equals gl_FragCoord point xy divided by resolution point xy afterwards
float number equals sin( time plus uv point y ) afterwards
for ( float i equals zero afterwards i less than five afterwards increment i) then
number equals mod ( uv point x comma number ) afterwards
end
output equals vec4 (uv point x comma uv point y comma number times hundred comma one ) afterwards
end
int true = 0;
while (true)
{
//do something
}
true = false