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}
By Anonymous, 2021-07-30 21:13:46
Button.MouseButton1Click:Connect(function()
    if TextHolder.Text == Codes.Code1 then
        if Check1.Value == false then
            Check1.Value = true
        elseif Check1.Value == false then
            TextHolder.Text = "Code Already Redeemed"
        Event:FireServer("Code1")
        TextHolder.Text = "Success! 500 Coins Rewarded"
    elseif TextHolder.Text == Codes.Code2 then
        if Check2.Value == false then
            Check2.Value = true
        elseif Check2.Value == false then
            TextHolder.Text = "Code Already Redeemed"
        Event:FireServer("Code2")
        TextHolder.Text = "Success! 250 Coins Rewarded"
    elseif TextHolder.Text == Codes.Code3 then
        if Check3.Value == false then
            Check3.Value = true
        elseif Check3.Value == false then
            TextHolder.Text = "Code Already Redeemed"
        Event:FireServer("Code3")
        TextHolder.Text = "Sucess! 100 Coins Rewarded"
            else TextHolder.Text = "Invalid/Expired Code"
                end
            end
        end
    end
end)
By ShitFuck, 2021-08-07 00:55:53
.stepper a{
}

.stepper>div>div>div>div>a{
  color: transparent !important;
}
stepper>div>div>div>div>span{
  color: transparent !important;
}

.stepper>div>div>div:nth-child(1)>div>a:after, .stepper>div>div>div:nth-child(1)>div>span:after{
  color: rgb(52, 58, 64);
  content: '4' !important;
  margin-left: -10px;
}
.stepper>div>div>div:nth-child(2)>div>a:after{
  color: rgb(52, 58, 64);
  content: '3' !important;
  margin-left: -10px;
}
.stepper>div>div>div:nth-child(3)>div>a:after{
  color: rgb(52, 58, 64);
  content: '2' !important;
  margin-left: -10px;
}
.stepper>div>div>div:nth-child(4)>div>a:after{
  color: rgb(52, 58, 64);
  content: '1' !important;
  margin-left: -10px;
}
.stepper>div>div>div:nth-child(4)>div>span:after{
  color: rgb(52, 58, 64);
  background-color: rgb(108, 117, 125);
  content: '1' !important;
  margin-left: -10px;
}
.stepper>div>div>div:nth-child(3)>div>span:after{
  color: rgb(52, 58, 64);
  background-color: rgb(108, 117, 125);
  content: '2' !important;
  margin-left: -10px;
}
.stepper>div>div>div:nth-child(2)>div>span:after{
  color: rgb(52, 58, 64);
  background-color: rgb(108, 117, 125);
  content: '3' !important;
  margin-left: -10px;
}
.stepper>div>div>div:nth-child(1)>div>span:after{
  color: rgb(52, 58, 64);
  background-color: rgb(108, 117, 125);
  content: '4' !important;
  margin-left: -10px;
}
By Anonymous, 2021-08-11 11:24:55
for (const order of orders) {
    for (const resultItem of results) {
        if (resultItem.machine != "TRANSFER") {
            shiftsLoop: for (const shift of resultItem.shifts) {
                if (shift.products) {
                    for (const product of shift.products) {
                        if (product.product == order.product) {
                            for (const routing of routings) {
                                if (routing.output == order.product) {
                                    const machinePlant = findMachinePlant(resultItem.machine, machines)
                                    if (routing.type == "ODP") {
                                        if (machinePlant == order.plant) {
                                            const msg = createMessage(order, shift, resultItem.machine, CHOR)
                                            requests.push(buildRequest(msg))
                                        } else {
                                            //CHEE CHIE CHEI
                                        }
                                        break shiftsLoop
                                    } else if (routing.type == "OCL" || routing.type == "RCL") {
                                        const msg = createMessage(order, shift, resultItem.machine, CHCL)
                                        requests.push(buildRequest(msg))
                                        //CHCL
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
By sgaloppo, 2021-08-28 20:28:59
'use strict'

// exports //

module.exports = Math.sqrt
By Igor, 2021-09-01 21:28:26
const handleBoolean = value => {
        switch (value) {
            case "true":
                return true;
            case true:
                return "true";
            case "false":
                return false;
            case false:
                return "false"
            default:
                return null;
        }
    }
By Anonymous, 2021-09-29 11:53:22
isCreatedUser : !this.isEdit ? true : false

Vue.js project, someone wanted to verify if the user was being edited or created...

By rat, 2021-10-21 17:11:54
#define private public
#define protected public
#define class struct

#include "your_private_parts.hpp"
// ...

#undef class
#undef protected
#undef private

// ...

Fails miserably if template <class>, template <template <class> class> or their variations are found anywhere inside your header. :(

By 2 + 2 = 3.99999999999999999999999999999999999, 2021-11-08 07:59:05
                Path path = FileSystems.getDefault().getPath("../../../../../../../../../../EmailResults.csv");
                Files.deleteIfExists(path);
By Anonymous, 2021-11-12 20:18:57

abstract class ASong(
    var songId: Int = 0,
    var title: String? = "",
    var clipArt: String? = "",
    var artist: String? = "",
    var source: String? = "",
    var songType: Int = 0,
    var length: String? = "",
    var downloadPath: String? = "",
    var category: String? = ""
) : Parcelable {

    @Transient
    var totalDuration: Long = 0
    @Transient
    var currentPosition: Long = 0
    @Transient
    var playingPercent = 0

    private fun calculatePlayingPercent(): Int {
        return if (currentPosition == 0L || totalDuration == 0L) 0 else (currentPosition * 100 / totalDuration).toInt()
    }

}
© 2021 GitHub, Inc

Probably meant to stand for AbstractSong. Ens up sounding awkward or like somebody who just wrote their first class.

By peakvalleytech, 2021-11-13 00:07:44
StartCoroutine(Patrol());

public IEnumerator Patrol() {
    while(true) {
        dt.Walk();
        yield return new WaitForSeconds(reactionTime);
    }
}
By Mario, 2021-11-19 07:18:22
function add(input1,input2) {
	var number1 = input1.toString();
	var number2 = input2.toString();
	var numbers1 = new Array();
	var numbers2 = new Array();
	var size1 = 0;
	var size2 = 0;
	while(size1 < number1.length) {
		var SizeAndNumberToAddToNumbers1Array = 0;
		var Number1FromFunctionAddLength = number1.length-size1-1;
		SizeAndNumberToAddToNumbers1Array = number1.charAt(size1);
		while(Number1FromFunctionAddLength > 0){
			SizeAndNumberToAddToNumbers1Array = SizeAndNumberToAddToNumbers1Array + "0";
			Number1FromFunctionAddLength = Number1FromFunctionAddLength-1;
		}
		numbers1.push(SizeAndNumberToAddToNumbers1Array);
		size1 = size1 + 1;
	}
	while(size2 < number2.length) {
		var SizeAndNumberToAddToNumbers1Array2 = 0;
		var Number1FromFunctionAddLength2 = number2.length-size2-1;
		SizeAndNumberToAddToNumbers1Array2 = number2.charAt(size2);
		while(Number1FromFunctionAddLength2 > 0){
			SizeAndNumberToAddToNumbers1Array2 = SizeAndNumberToAddToNumbers1Array2 + "0";
			Number1FromFunctionAddLength2 = Number1FromFunctionAddLength2-1;
		}
		numbers2.push(SizeAndNumberToAddToNumbers1Array2);
		size2 = size2 + 1;
	}
	var result1 = 0;
	var saize1 = 0;
	while(saize1 < numbers1.length){
		var topush1 = numbers1[saize1];
		result1=result1+parseInt(topush1);
		saize1 = saize1 + 1;
	}
	var result2 = 0;
	var saize2 = 0;
	while(saize2 < numbers2.length){
		var topush2 = numbers2[saize2];
		result2=result2+parseInt(topush2);
		saize2 = saize2 + 1;
	}
	return result1+result2;
}

advanced and optimized add function better than a + b

By Rzaba Kiddo, 2021-11-27 21:25:24
let arr = []
if(arr[record.id]) {
    arr[record.id] = false
} else {
    arr[record.id] = false
}
this.setState({a: arr})
arr = []
By Anonymous, 2021-12-27 06:55:59
 elsif ( $att =~ m/!!ARRAY!!/ ) {    # Updated to allow us to get data from an Array - 
        &Debug("get_value_from_hash:: parsing the ARRAY attribute - $att");
        my ( $key1, $key2, $key3, $key4, $key5, $key6 ) = split( /\./, $att );

        #&Debug("get_value_from_hash:: key1=$key1, key2=$key2, key3=$key3, key4=$key4, key5=$key5");
        if ( defined $key6 ) {
            if ( $key5 =~ m/!!ARRAY!!/ ) {
                for my $item ( @{ $hash->{$key1}->{$key2}->{$key3}->{$key4} } ) { $value = $item->{$key6}; }
            }
            elsif ( $key4 =~ m/!!ARRAY!!/ ) {
                for my $item ( @{ $hash->{$key1}->{$key2}->{$key3} } ) { $value = $item->{$key5}->{$key6}; }
            }
            elsif ( $key3 =~ m/!!ARRAY!!/ ) {
                for my $item ( @{ $hash->{$key1}->{$key2} } ) { $value = $item->{$key4}->{$key5}->{$key6}; }
            }
            elsif ( $key2 =~ m/!!ARRAY!!/ ) {
                for my $item ( @{ $hash->{$key1} } ) { $value = $item->{$key3}->{$key4}->{$key5}->{$key6}; }
            }
            elsif ( $key1 =~ m/!!ARRAY!!/ ) {
                for my $item ( @{$hash} ) { $value = $item->{$key2}->{$key3}->{$key4}->{$key5}->{$key6}; }
            }
        }
        elsif ( defined $key5 ) {
            if ( $key4 =~ m/!!ARRAY!!/ ) {
                for my $item ( @{ $hash->{$key1}->{$key2}->{$key3} } ) { $value = $item->{$key5}; }
            }
            elsif ( $key3 =~ m/!!ARRAY!!/ ) {
                for my $item ( @{ $hash->{$key1}->{$key2} } ) { $value = $item->{$key4}->{$key5}; }
            }
            elsif ( $key2 =~ m/!!ARRAY!!/ ) {
                for my $item ( @{ $hash->{$key1} } ) { $value = $item->{$key3}->{$key4}->{$key5}; }
            }
            elsif ( $key1 =~ m/!!ARRAY!!/ ) {
                for my $item ( @{$hash} ) { $value = $item->{$key1}->{$key3}->{$key4}->{$key5}; }
            }
        }
        elsif ( defined $key4 ) {
            if ( $key3 =~ m/!!ARRAY!!/ ) {
                for my $item ( @{ $hash->{$key1}->{$key2} } ) { $value = $item->{$key4}; }
            }
            elsif ( $key2 =~ m/!!ARRAY!!/ ) {
                for my $item ( @{ $hash->{$key1} } ) { $value = $item->{$key3}->{$key4}; }
            }
            elsif ( $key1 =~ m/!!ARRAY!!/ ) {
                for my $item ( @{$hash} ) { $value = $item->{$key1}->{$key3}->{$key4}; }
            }
        }
        elsif ( defined $key3 ) {
            if ( $key2 =~ m/!!ARRAY!!/ ) {
                for my $item ( @{ $hash->{$key1} } ) { $value = $item->{$key3}; }
            }
            elsif ( $key1 =~ m/!!ARRAY!!/ ) {
                for my $item ( @{$hash} ) { $value = $item->{$key3}; }
            }
        }
        elsif ( defined $key2 ) {
            if ( $key1 =~ m/!!ARRAY!!/ ) {
                for my $item ( @{$hash} ) { $value = $item->{$key2}; }
            }
        }
    }
    elsif ( $att =~ m/!!HITS\[\d+\]!!/ ) {
        &Debug("get_value_from_hash:: parsing the HITS attribute - $att");
        my $id = $att;
        $id =~ s/!!HITS\[(\d+)\]!!.*/$1/;
        $att =~ s/!!HITS\[\d+\]!!\.//;
        &Debug("get_value_from_hash:: parsing the attribute - $att");
        my ( $key1, $key2, $key3, $key4, $key5, $key6 ) = split( /\./, $att );

        #&Debug("get_value_from_hash:: id=$id, key1=$key1, key2=$key2, key3=$key3, key4=$key4, key5=$key5");
        if ( defined $key6 ) {
            $value = $$hash{hits}{hits}[$id]{$key1}{$key2}{$key3}{$key4}{$key5}{$key6};
        }
        elsif ( defined $key5 ) {
            $value = $$hash{hits}{hits}[$id]{$key1}{$key2}{$key3}{$key4}{$key5};
        }
        elsif ( defined $key4 ) {
            $value = $$hash{hits}{hits}[$id]{$key1}{$key2}{$key3}{$key4};
        }
        elsif ( defined $key3 ) {
            $value = $$hash{hits}{hits}[$id]{$key1}{$key2}{$key3};
        }
        elsif ( defined $key2 ) {
            $value = $$hash{hits}{hits}[$id]{$key1}{$key2};
        }
    }
    elsif ( $att =~ m/!!DELIMITER!!.+!!/ ) {
        &Debug("get_value_from_hash:: parsing the DELIMITER attribute - $att");
        my $delimiter = $att;
        $delimiter =~ s/!!DELIMITER!!(.*)!!.*/$1/;
        $att =~ s/!!DELIMITER!!.+!!//;
        &Debug("get_value_from_hash:: parsing the attribute - $att");
        my ( $key1, $key2, $key3, $key4, $key5, $key6 ) = split( $delimiter, $att );

        #        &Debug("get_value_from_hash:: key1=$key1, key2=$key2, key3=$key3, key4=$key4, key5=$key5, key6=$key6");
        if ( defined $key6 ) {
            $value = $$hash{$key1}{$key2}{$key3}{$key4}{$key5}{$key6};
        }
        elsif ( defined $key5 ) {
            $value = $$hash{$key1}{$key2}{$key3}{$key4}{$key5};
        }
        elsif ( defined $key4 ) {
            $value = $$hash{$key1}{$key2}{$key3}{$key4};
        }
        elsif ( defined $key3 ) {
            $value = $$hash{$key1}{$key2}{$key3};
        }
        elsif ( defined $key2 ) {
            $value = $$hash{$key1}{$key2};
        }
    }
    else {
        &Debug("get_value_from_hash:: parsing the attribute - $att");
        my ( $key1, $key2, $key3, $key4, $key5, $key6 ) = split( /\./, $att );

        #&Debug("get_value_from_hash:: key1=$key1, key2=$key2, key3=$key3, key4=$key4, key5=$key5");
        if ( defined $key6 ) {
            $value = $$hash{$key1}{$key2}{$key3}{$key4}{$key5}{$key6};
        }
        elsif ( defined $key5 ) {
            $value = $$hash{$key1}{$key2}{$key3}{$key4}{$key5};
        }
        elsif ( defined $key4 ) {
            $value = $$hash{$key1}{$key2}{$key3}{$key4};
        }
        elsif ( defined $key3 ) {
            $value = $$hash{$key1}{$key2}{$key3};
        }
        elsif ( defined $key2 ) {
            $value = $$hash{$key1}{$key2};
        }
    }

When you try to debug, why value is not filled, and find this...

By Anonymous, 2022-01-04 07:00:11
public array<P extends Path<NotNul<T>>, Key extends string>(
  name: P,
  ...args: NotNul<PathValue<NotNul<T>, P>> extends Array<infer Item> ? ('id' extends keyof Item ? [keyname: Key] : [keyName?: Key]) : []
): NotNul<PathValue<NotNul<T>, P>> extends Array<infer Item>
  ? Key extends keyof Item
    ? never
    : Field<Array<Item & (Key extends keyof Item ? {} : string extends Key ? {} : { [P in Key]?: string })>>
  : never {
  return this.createField(name as any, this.name, args[0]) as any
}
By Anonymous, 2022-01-10 03:36:55