// this.collectPairs() returns data from the UI form 
// this.alert.alarmReasons contains empty array or alarmReason-Category pair objects

let newAlarmReasonsToAdd = []

this.collectPairs().forEach(categoryAndAlarmReasonPair => {
  !!!this.searchAmidExisting(categoryAndAlarmReasonPair, this.alert.alarmReasons) ? newAlarmReasonsToAdd.push(categoryAndAlarmReasonPair) : null
})

searchAmidExisting(alarmReasonToAdd, existingAlarmReasons){
    let res = existingAlarmReasons.find(existing => {
    if(alarmReasonToAdd.categoryDictEntryKey === existing.category && alarmReasonToAdd.reasonDictEntryKey === existing.reason){
      return true
    } else return false
  })
    return res
  }
By mallioppilas, 2023-11-03 14:13:41
    public static String arrayToString(List list) {
        if (list == null) {
            throw new IllegalArgumentException("list is null");
        }
        return list.toString()
                .replace("[", "")  //remove the right bracket
                .replace("]", "")  //remove the left bracket
                .trim();
    }
By Anonymous, 2023-07-30 00:29:07
fn add_unsafe(a: i32, b: i32) -> i32 {
  a + b
}

fn add_safer(a: i32, b: i32) -> std::io::Result<i32> {
  Ok(add_unsafe(a, b))
}

fn add_option(a: i32, b:i32) -> Option<std::io::Result<i32>> {
  Some(add_safer(a, b))
}

fn main() {
  println!("{:?}", add_option("4".parse::<i32>().unwrap(), "5".parse::<i32>().unwrap()).unwrap().unwrap());
}

it unwraps

By onrirr mqhirr, 2023-08-10 11:21:24
    string sum_numbers(string a, string b) {
        char ca, cb, ci, out, co = '0';
        string result = "";
        while (a.size() > 0 || b.size() > 0 || co != '0') {
            ci = co; ca = '0'; cb = '0';
            if (a.size() > 0) {ca = a.back(); a.pop_back();}
            if (b.size() > 0) {cb = b.back(); b.pop_back();}
            result = ((((ca != cb) ? '1' : '0') != ci) ? '1' : '0') + result;
            co = ((((ca == '1' && cb == '1') ? '1' : '0') == '1' || 
                 ((((ca != cb) ? '1' : '0') == '1' && ci == '1') ? '1' : '0') == '1') ? '1' : '0');
        }
        return result;
    }

Scary stuff

By Anonymous, 2023-12-01 22:20:27
def __getCurlOutput (self, url, **kwargs):
	curlcmd = "curl {0}".format(url)

	for key, value in kwargs.items():
		key = key.lower()

		if key == "origin":
			curlcmd += " -H 'Origin: {0}'".format(value)
		elif key == "contenttype":
			curlcmd += " -H 'Content-Type: {0}'".format(value)
		elif key == "referer":
			curlcmd += " -H 'Referer: {0}'".format(value)
		elif key == "cookie":
			curlcmd += " -H 'Cookie: {0}'".format(value)
		elif key == "data":
			curlcmd += " --data '{0}'".format(value)
		elif key == "verbose":
			if value == True:
				curlcmd += " --verbose"
			else:
				curlcmd += " --silent"
		elif key == "output":
			curlcmd += " --output {0}".format(value)
		else:
			print "Unsupported key: {0}".format(key)

	curlcmd += " 2>&1"

	print curlcmd

	curlout = subprocess.check_output(curlcmd,shell=True)

	return curlout
By AnonimaPitoni, 2018-12-04 19:22:34
export const LandingReducer=createSlice({
    name:'MAIN_SLICE',
    initialState:initialStates,
    reducers: {
        changeStateValue:(state,action) => {
            state[action.payload.name] = action.payload.value
            const check = action.payload.name.includes('.')
            if (!check) {
                state[action.payload.name] = action.payload.value
            }else{
                const groups=action.payload.name.split('.')
                console.log(groups);
                if(groups.length===2){
                    state[groups[0]][groups[1]]=action.payload.value;
                }else if(groups.length===3){
                    state[groups[0]][groups[1]][groups[2]]=action.payload.value;
                }else if(groups.length===4){
                    state[groups[0]][groups[1]][groups[2]][groups[3]]=action.payload.value;
                }
            }
        }
    }
});
By shitmaker, 2023-08-08 16:33:56
def even?(number)
  if number > 0
    result = number
  else
    result = -number
  end

  while result > 2 or result == 2
    result = result - 2
  end

  if result == 0
    true
  else
    false
  end
end

Best solution to find out if a number is even.

By Anonymous, 2023-11-12 14:59:07
const allowed = {
    '1': true,
    '2': true,
    '3': true,
    '4': true,
    '5': true,
    '6': true,
    '7': true,
    '8': true,
    '9': true,
    '0': true,
    'ArrowLeft': true,
    'ArrowDown': true,
    'ArrowRight': true,
    'ArrowUp': true,
    'Backspace': true,
    '.': true,
}

const isValidInput = allowed[key]
By Anonymous, 2019-07-26 16:34:12
<style type="text/css">
    <?php echo file_get_contents(
            \realpath(ROOT_PATH . '/public/').$this->assetPath('css/styles.css', true)
            ); ?>
</style>

Including style file (about 100kb) directly to HTML page. Thanks for developer, it's in .

By Ed, 2023-07-28 10:51:07
> const today = new Date(2016, 7, 7)
undefined
> const tomorrow = new Date(2016, 7, 8)
undefined
> tomorrow >= today
true
> today <= tomorrow
true
> today == tomorrow
false
By winek, 2016-05-30 16:08:25