string month = DateTime.Today.Month.ToString();
if (DateTime.Today.Month < 10)
{
month = "0" + month;
}
string day = DateTime.Today.Day.ToString();
if (DateTime.Today.Day < 10)
{
day = "0" + day;
}
string dateCorrect = String.Format("{0}.{1}.{2}", DateTime.Today.Year, month, day);
string dateDue = "";
if (transferFields.DueDate.SelectedDate.HasValue)
{
var dateDuearr = transferFields.DueDate.Value.Split(' ')[0].Split('.');
dateDue = dateDuearr[2] + '.' + dateDuearr[1] + '.' + dateDuearr[0];
}
else {
dateDue = dateCorrect;
}
Real developers don't use built in parsing and formatting methods.
if ((string)filtros[0] != "-1" && (string)filtros[0] != "0")
filtros[0] = (string)filtros[0] != "" ? filtros[0] : DBNull.Value;
else
filtros[0] = DBNull.Value;
const configs = {
employeeObject: {
// tab 0
firstName: "",
middleName: "",
nickname: "",
lastName: "",
gender: "",
race: "",
title: "",
dob: "",
employeeIDNo: "",
// tab 1
userName: "",
permissionRole: 0,
employeeNo: "",
phoneExt: "",
startDate: "",
company: "",
division: "",
jobDescription: "",
businessUnit: "",
regionId: "",
participantStatus: "",
costCentre: "",
personType: "",
comments: "",
// tab 2
phone1: "",
phone2: "",
phone3: "",
address1: "",
address2: "",
address3: "",
address4: "",
postalCode: "",
email: "",
},
Why add another object with a title when you can just add a comment saying... well... nothing really...
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);
local part = script.Parent
local OriginColor = Color3.new(0,170,255)
local KillColor = Color3.new(1, 0, 0)
part.Touched:Connect(function(H)
local humanoid = H.Parent:FindFirstChild("Humanoid")
if humanoid and part.Color == KillColor then
humanoid.Health = 0
end
end)
local shit = 1
repeat
part.Color = OriginColor
wait(1.5)
part.Color = KillColor
wait(1.5)
until shit == 2
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
var token = new CancellationTokenSource().Token;
Task.Factory.StartNew (() => {
while (!token.IsCancellationRequested) {
try {
if (/*Condition*/)
this.Invoke(new Action(() => label.Text = " =)"));
else
this.Invoke(new Action(() => label.Text = " =("));
Thread.Sleep(10);
}
catch (Exception) {
throw;
}
finally {
throw new Exception();
}
}
}) ;
}
}
My collegue's way of using multithreading features (and exceptions handling) :)
class Timer extends React.Component{
state ={
time: 10
};
setInvt = () =>{
let t = this.state.time
if(t<=1){
clearInterval(this.invertal)
}
this.setState({time: t-1})
}
componentDidMount(){
this.invertal = setInterval(this.setInvt, 1000)
}
render(){
return (<label>{this.state.time}</label>)
}
}
export {Timer}
class {
public State state;
//enums cant take double values...
public struct State
{
public const float IDLE = 0f;
public const float WALKING = 0.5f;
public const float RUNNING = 1f;
}
protected void Stop()
{
SetSpeed(State.IDLE);
}
protected void SetSpeed(float f)
{
agent.speed = f;
if (agent.speed > 1f && agent.speed < 5f)
{
f = State.WALKING;
agent.Resume();
}
else if (agent.speed > 5f)
{
f = State.RUNNING;
agent.Resume();
}
else
{
f = State.IDLE;
agent.Stop();
}
}
}
Who needs static float
when you can have a constant in a nested struct, as a bonus State state
has 0 references in the project
product = None
for key in dictionary.keys():
if product is None:
product = dictionary[key]
else:
product = itertools.product(product, dictionary[key])
product = "{0}".format(list(product))
product = re.sub(r"\), \(+", "], [", product)
product = re.sub(r"\(+", "[", product)
product = product.replace(")]", "]]").replace(")", "")
product = ast.literal_eval(product)
Ok, I have a weird array of objects as output of itertools and I need an array of strings... 1 - Convert the array to string 2 - Clean it up with regex and replace 3 - Convert the string to array 4 - Problem solved
function isEmpty(value) {
if (value === '') {
return false;
} else if (value === 0) {
return false;
} else if (value === null) {
return false;
} else if (value === undefined) {
return false;
} else {
return true;
}
return true;
}
javascript empty value check
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
public static int[] xxx(String filename) throws IOException{
int[] f = new int[26];
BufferedReader in = new BufferedReader(new FileReader(filename));
String line;
while((line = in.readLine()) != null){
line = line.toUpperCase();
for(char ch:line.toCharArray()){
if(Character.isLetter(ch)){
f[ch - 'A']++;
}
}
}
in.close();
return f;
}
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
}
}
}
}
}
}