// Save the files for 100 timea in case failed
try {
for (let i; i <= 100; i++) {
File.save();
}
} catch (e) {
// Save the files for 100 timea since it already failed
for (let i; i <= 100; i++) {
File.save();
}
}
if "[trait]" in lines[i]:
in_trait = True
elif "[/trait]" in lines[i]:
in_trait = False
elif "[object]" in lines[i]:
in_object = True
elif "[/object]" in lines[i]:
in_object = False
elif "[stage]" in lines[i]:
in_stage = True
elif "[/stage]" in lines[i]:
in_stage = False
elif "[cfg]" in lines[i]:
in_cfg = True
elif "[/cfg]" in lines[i]:
in_cfg = False
elif "[goal]" in lines[i]:
in_goal = True
elif "[/goal]" in lines[i]:
in_goal = False
#... 150 more lines of this
Basically, linting a config file with a DOM tree, using Python
double func_atof(char *p){
double integer = 0.0, div = 1.0 , fract = 0.0 , sign = 1.0;
if( *p == 45 ){sign = -1.0, *p++ ; }
while ( isdigit(*p) ) {
integer = ( *p++ ) + (10.0 * integer) - 48.0 ;
}
if(*p == 46 ){
(*p++ ) ;
while ( isdigit(*p) ) {
fract = ( *p++ ) + (10.0 * fract) - 48.0 ;
div *= 10;
}
}
return (integer + fract / div ) * sign ;
}
int true = 0;
while (true)
{
//do something
}
true = false
<h1 className="sidebar-text">
<h1 className="sidebar-text">My Applauses</h1>
</h1>
How do you even miss this... the Console will literally complain in red to you...
$orderDateTS = strtotime($data['ordertime']);
$nowTS = strtotime('now');
$diff = $nowTS - $orderDateTS;
$diff = $diff / 86400;
$dayDiff = floor($diff);
found in a shopware plugin
cd /some/directory
rm -rf *
I regularly see these two lines in Bash scripts I don't understand but some programmers think you need a CD command before any command, and they also don't know that paths can be part of parameters (which explains why they use many CD commands)
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
ngOnInit() {
this._FunctionService.getSicksList().then(res => {
let resf:any = res;
if (resf.err) {
} else {
this.diagnosticAll = resf.data
}
}, err => { })
}
/*
ngOnInit() {
this._FunctionService.getSicksList().then(res => {
this.diagnosticAll = res.data
}, err => { })
}
*/
class ExampleClass {
public void DoSomething()
{
if (this != null) {
//omitted
}
}
public void DoSomething2()
{
if (this != null) {
//omitted
}
}
}
Explanation: This can't be null in C# virtual instance methods - I was so confused by the widespread use of this check that I asked this question at SO: https://stackoverflow.com/questions/31747718/can-this-be-null-in-c-sharp-virtual-methods-what-happens-with-the-rest-of-ins
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.
val weekEnd = DateTime.now.withDayOfWeek(5).plusDays(2)
case ClientMessage:
if (*XGetAtomName(GLWin.dpy, event.xclient.message_type)
== *"WM_PROTOCOLS")
{ printf("Exiting sanely...\n");
done = True;
}
break;
someone just want to watch the world burn
function sortUsers(a, b) {
return a.last_name.localeCompare(b.last_name) * -1;
}
StartCoroutine(Patrol());
public IEnumerator Patrol() {
while(true) {
dt.Walk();
yield return new WaitForSeconds(reactionTime);
}
}