for (int i = 0;i < n / 2;i++)
{
while (num[a[p].id].n == 0 || num[num[a[p].id].nxt].n == 0)
{
p++;
}
printf("%d %d ", num[a[p].id].n, num[num[a[p].id].nxt].n);
num[a[p].id].n = 0;
num[num[a[p].id].nxt].n = 0;
num[num[a[p].id].lst].nxt = num[num[a[p].id].nxt].nxt;
num[num[num[a[p].id].nxt].nxt].lst = num[a[p].id].lst;
}
<Image source={ this.props.pickupOrDropoff == "pickup"
? i.pickup
? iconBlue
: iconWhite
: i.dropoff
? iconBlue
: iconWhite} style={{
height:this.props.pickupOrDropoff == "pickup"
? i.pickup
? 30
: i.sign === 'D' ? 30 : 35
: i.dropoff
? 30
: i.sign === 'D' ? 30 : 35,
marginRight:10 ,
width: this.props.pickupOrDropoff == "pickup"
? i.pickup
? 40
: 40
: i.dropoff
? 40
: 40
,resizeMode:'contain'}}/>
I love when the code is neat...
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, "%");
}
}
const handleBoolean = value => {
switch (value) {
case "true":
return true;
case true:
return "true";
case "false":
return false;
case false:
return "false"
default:
return null;
}
}
SELECT CAST(CASE a8900.AllowCloserChanges
WHEN 0
THEN 0
ELSE 1 END AS BIT) AllowCloserChanges
FROM Vision.sub8900.tApplication8900 a8900
WHERE a8900.ApplicationNum = @ApplicationNum
Inheriting others' code in the fun world of corporate development.
http://localhost:52108/Trade/Details/1953452?class=pull-left
$guard = ($vars->a_payment) + (0) * $price;
if ($bless >= $guard) {
$amount = $bless;
}
Why not to write just 1 line?! $amount = max($bless, $vars->a_payment);
if (code === null) {
return null;
} else {
return code;
}
if (model.env.Trim().ToUpper() == "Release")
{
retVal = false;
if (!string.IsNullOrEmpty(model.Server_Core))
{
// Perform a trim in case user specified just whitespace...
string tmpStr = model.Server_Core.Trim();
if (!string.IsNullOrEmpty(tmpStr))
{
retVal = true;
}
}
}
String.prototype.capitalize=function(){return this.charAt(0).toUpperCase()+this.slice(1);};
String.prototype.followCase=function(b){
if(b==b.toUpperCase()){return this.toUpperCase();}
if(b==b.toLowerCase()){return this.toLowerCase();}
if(b==b.capitalize()){return this.capitalize();}
return this;
};
String.prototype.atRemoveAdd=function(index,n,string){
return this.substring(0,index)+string+this.substring(index+n,this.length);
};
String.prototype.matchIndex=function(re){
var a=[];
while((match=re.exec(this))!==null){
a.push({chars:match[0].length,index:match.index});
}
return a;
};
String.prototype.caseReplace=function(o,n){
for(var s=this,a=this.matchIndex(o),shift=0,i=0;i<a.length;i++){
var c=n.followCase(this.substring(a[i].index,a[i].index+a[i].chars));
s=s.atRemoveAdd(a[i].index+shift,a[i].chars,c);
shift+=c.length-a[i].chars;
}
return s;
};
My code from 2016 for the hall of shame where I realized today that caseReplace could just return this.replace(o,m=>n.followCase(m))
instead.
if ($customerId > 0) {
$customerId = $customerId;
} else {
$customerId = $this->customerSession->getId();
}
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 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;
}
filterForProvincia() {
console.log('ciao');
}
The last line of code of a parting Developer
public static function getUser(){
return \App\Models\User::all();
}