write some config into config file
@param {string} mnemonic_phrase - mnemonic phrase
@param {string} deviceTempPrivKey - temp private key
@param {string} devicePrevTempPrivKey - temp device private key
@param {function} onDone - callback
512159
function writeKeys(mnemonic_phrase, deviceTempPrivKey, devicePrevTempPrivKey, onDone){
	var keys = {
		mnemonic_phrase: mnemonic_phrase,
		temp_priv_key: deviceTempPrivKey.toString('base64'),
		prev_temp_priv_key: devicePrevTempPrivKey.toString('base64')
	};
	fs.writeFile(KEYS_FILENAME, JSON.stringify(keys, null, '\t'), 'utf8', function(err){
		if (err)
			throw Error("failed to write keys file");
		if (onDone)
			onDone();
	});
}
552489
public static void config(String host, String personal, String from, String key) {
        setHost(host);
        setPersonal(personal);
        setFrom(from);
        setKey(key);
    }
669280
def set_device_name(self, newname):
        
        return self.write(request.SetDeviceName(self.seq, *self.prep_str(newname)))
551693
def get_lock_config(self, device_label):
        
        response = None
        try:
            response = requests.get(
                urls.lockconfig(self._giid, device_label),
                headers={
                    'Accept': 'application/json, text/javascript, */*; q=0.01',
                    'Cookie': 'vid={}'.format(self._vid)})
        except requests.exceptions.RequestException as ex:
            raise RequestError(ex)
        _validate_response(response)
        return json.loads(response.text)
690608
function writeKey(key, value, masterPassword) {
    var contents = getContents(masterPassword);
    contents[key] = value;
    var fileContents = JSON.stringify(contents);
    var encryptedFileContents = encryption.encrypt(fileContents, masterPassword);
    file.writeToFile(encryptedFileContents);
}
362089
def write(self, version):
        
        with tempfile.NamedTemporaryFile(mode='w', delete=False) as fh:
            fh.write(str(version))

        if self._path.exists():
            shutil.copystat(str(self._path), fh.name)

        try:
            pathlib.Path(fh.name).rename(self._path)
        except OSError as exc:
            # handling situation with tmp file on another device
            if exc.errno == 18 and 'Invalid cross-device link' in exc.strerror:
                with self._path.open(mode='w') as fh:
                    fh.write(str(version))
            else:
                raise
90359
def save_config(self, cmd="write mem", confirm=False, confirm_response=""):
        """"""
        return super(OneaccessOneOSBase, self).save_config(
            cmd=cmd, confirm=confirm, confirm_response=confirm_response
        )
80849
function (successCallback, errorCallback, args) {
		winble.logger.logApiEntry("writeCharacteristic");
		var deviceHandle = args[0] ? args[0] : "";
		var charHandle = args[1] ? args[1] : "";
		var dataBuffer = args[2] ? args[2] : "";
		winble.deviceManager.writeCharacteristic(successCallback, errorCallback, deviceHandle, charHandle, dataBuffer);
		winble.logger.logApiExit("writeCharacteristic");
	}
150551
function handlePairingMessage(json, device_pubkey, callbacks){
	var body = json.body;
	var from_address = objectHash.getDeviceAddress(device_pubkey);
	if (!ValidationUtils.isNonemptyString(body.pairing_secret))
		return callbacks.ifError("correspondent not known and no pairing secret");
	if (!ValidationUtils.isNonemptyString(json.device_hub)) // home hub of the sender
		return callbacks.ifError("no device_hub when pairing");
	if (!ValidationUtils.isNonemptyString(body.device_name))
		return callbacks.ifError("no device_name when pairing");
	if ("reverse_pairing_secret" in body && !ValidationUtils.isNonemptyString(body.reverse_pairing_secret))
		return callbacks.ifError("bad reverse pairing secret");
	db.query(
		"SELECT is_permanent FROM pairing_secrets WHERE pairing_secret=? AND expiry_date > "+db.getNow(), 
		[body.pairing_secret], 
		function(pairing_rows){
			if (pairing_rows.length === 0)
				return callbacks.ifError("pairing secret not found or expired");
			// add new correspondent and delete pending pairing
			db.query(
				"INSERT "+db.getIgnore()+" INTO correspondent_devices (device_address, pubkey, hub, name, is_confirmed) VALUES (?,?,?,?,1)", 
				[from_address, device_pubkey, json.device_hub, body.device_name],
				function(){
					db.query( // don't update name if already confirmed
						"UPDATE correspondent_devices SET is_confirmed=1, name=? WHERE device_address=? AND is_confirmed=0", 
						[body.device_name, from_address],
						function(){
							eventBus.emit("paired", from_address);
							if (pairing_rows[0].is_permanent === 0){ // multiple peers can pair through permanent secret
								db.query("DELETE FROM pairing_secrets WHERE pairing_secret=?", [body.pairing_secret], function(){});
								eventBus.emit('paired_by_secret-'+body.pairing_secret, from_address);
							}
							if (body.reverse_pairing_secret)
								sendPairingMessage(json.device_hub, device_pubkey, body.reverse_pairing_secret, null);
							callbacks.ifOk();
						}
					);
				}
			);
		}
	);
}
4340
function AvrYamahaNodeGet(config) {
    RED.nodes.createNode(this, config);

    // Save settings in local node
    this.device = config.device;
    this.deviceNode = RED.nodes.getNode(this.device);
    this.name = config.name;
    this.topic = config.topic;

    var node = this;
    if (this.deviceNode) {

  		// Input handler, called on incoming flow
      this.on('input', function(msg) {

        // If no topic is given in the config, then we use the topic in the msg.
        var topic = (node.topic) ? node.topic : msg.topic;
        if (!topic) {
          node.error('No topic given. Specify either in the config or via msg.topic!');
          return;
        }

        // Get data from the device.
        node.deviceNode.sendGetCommand(topic).then(function(value) {
          msg.payload = value;
          node.send(msg);
        }).catch(function(error) {
          node.error("Failed to request data from AVR with error: " + error);
        });

      });

    } else {
      this.error(RED._("avr-yamaha.errors.missing-config"));
    }
  }
106720
def __write_p4settings(self, config):
        
        self.logger.info("Writing p4settings...")
        root_dir = os.path.expanduser(config.get('root_path'))
        p4settings_path = os.path.join(root_dir, ".p4settings")
        if os.path.exists(p4settings_path):
            if self.target.get('overwrite_p4settings', False):
                self.logger.info("Overwriting existing p4settings...")
                os.remove(p4settings_path)
            else:
                return
        with open(p4settings_path, "w+") as p4settings_file:
            p4settings_file.write(p4settings_template % config.to_dict())
            if config.get('write_password_p4settings', 'no'):
                p4settings_file.write("\nP4PASSWD=%s" % config['password'])
1024404
function writeATSEntries (config) {
    var pObj = processAccessAndAllowNavigationEntries(config);

    var ats = {};

    for (var hostname in pObj) {
        if (pObj.hasOwnProperty(hostname)) {
            var entry = pObj[hostname];

            // Guiding principle: we only set values if they are available

            if (hostname === '*') {
                // always write this, for iOS 9, since in iOS 10 it will be overriden if
                // any of the other three keys are written
                ats['NSAllowsArbitraryLoads'] = true;

                // at least one of the overriding keys is present
                if (entry.NSAllowsArbitraryLoadsInWebContent) {
                    ats['NSAllowsArbitraryLoadsInWebContent'] = true;
                }
                if (entry.NSAllowsArbitraryLoadsForMedia) {
                    ats['NSAllowsArbitraryLoadsForMedia'] = true;
                }
                if (entry.NSAllowsLocalNetworking) {
                    ats['NSAllowsLocalNetworking'] = true;
                }

                continue;
            }

            var exceptionDomain = {};

            for (var key in entry) {
                if (entry.hasOwnProperty(key) && key !== 'Hostname') {
                    exceptionDomain[key] = entry[key];
                }
            }

            if (!ats['NSExceptionDomains']) {
                ats['NSExceptionDomains'] = {};
            }

            ats['NSExceptionDomains'][hostname] = exceptionDomain;
        }
    }

    return ats;
}
1289102
def _log_config_on_step(self, trial_state, new_state, trial,
                            trial_to_clone, new_config):
        
        trial_name, trial_to_clone_name = (trial_state.orig_tag,
                                           new_state.orig_tag)
        trial_id = "".join(itertools.takewhile(str.isdigit, trial_name))
        trial_to_clone_id = "".join(
            itertools.takewhile(str.isdigit, trial_to_clone_name))
        trial_path = os.path.join(trial.local_dir,
                                  "pbt_policy_" + trial_id + ".txt")
        trial_to_clone_path = os.path.join(
            trial_to_clone.local_dir,
            "pbt_policy_" + trial_to_clone_id + ".txt")
        policy = [
            trial_name, trial_to_clone_name,
            trial.last_result[TRAINING_ITERATION],
            trial_to_clone.last_result[TRAINING_ITERATION],
            trial_to_clone.config, new_config
        ]
        # Log to global file.
        with open(os.path.join(trial.local_dir, "pbt_global.txt"), "a+") as f:
            f.write(json.dumps(policy) + "\n")
        # Overwrite state in target trial from trial_to_clone.
        if os.path.exists(trial_to_clone_path):
            shutil.copyfile(trial_to_clone_path, trial_path)
        # Log new exploit in target trial log.
        with open(trial_path, "a+") as f:
            f.write(json.dumps(policy) + "\n")
237579
private void write(final byte memAddr, final int value) throws IOException {

		// bit 8 of value
		byte firstBit = (byte) ((value >> 8) & 0x000001);

		// ask device for setting a value - see FIGURE 7-2
		byte cmd = (byte) ((memAddr << 4) | CMD_WRITE | firstBit);

		// 7 bits of value
		byte data = (byte) (value & 0x00FF);

		// write sequence of cmd and data to the device
		byte[] sequence = new byte[] { cmd, data };
		i2cDevice.write(sequence, 0, sequence.length);

	}
69668
private void writeToDiskCache(
      final CacheKey key,
      final EncodedImage encodedImage) {
    FLog.v(TAG, "About to write to disk-cache for key %s", key.getUriString());
    try {
      mFileCache.insert(
          key, new WriterCallback() {
            @Override
            public void write(OutputStream os) throws IOException {
              mPooledByteStreams.copy(encodedImage.getInputStream(), os);
            }
          }
      );
      FLog.v(TAG, "Successful disk-cache write for key %s", key.getUriString());
    } catch (IOException ioe) {
      // Log failure
      // TODO: 3697790
      FLog.w(TAG, ioe, "Failed to write to disk-cache for key %s", key.getUriString());
    }
  }
655919
function run(context) {
    const preferences = configPreferences.read(context);
    const platforms = context.opts.cordova.platforms;

    platforms.forEach(platform => {
      if (platform === ANDROID) {
        androidManifest.writePreferences(context, preferences);
      }
      if (platform === IOS) {
        iosDevelopmentTeam.addDevelopmentTeam(preferences);
      }
    });
  }
1286743
function mnemonicToPubKey(str) {

  var m = new Mnemonic(str);

  var xpriv1 = m.toHDPrivateKey(); // no passphrase

  var xpub1 = xpriv1.hdPublicKey;

  return xpub1
}