Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const saveValue = value => {
cy.get(oembedInputSelector).clear();
if (value) {
cy.get(oembedInputSelector).type(value, { force: true });
}
const alias = cuid.slug();
// Setup to track XHR requests
cy.server();
// Alias the graphql request route
cy.route('post', '**/admin/api').as(alias);
// Avoid accidentally mocking routes
cy.server({ enable: false });
cy.get('#item-page-save-button').click({ force: true });
return cy.wait(`@${alias}`);
};
this.handleQuestionModeStart = () => {
this.setState({
questionModeStart: true,
challengeId: cuid.slug(),
selectedQuestionIds: [
// Put question ids here.
// Run by calling this function with a button click. Ideally in ChallengeKickoff.
],
});
};
}
exports.compileCPP = function ( envData , code , fn ) {
//creating source file
var filename = cuid.slug();
path = './temp/';
//create temp0
fs.writeFile( path + filename +'.cpp' , code , function(err ){
if(exports.stats)
{
if(err)
console.log('ERROR: '.red + err);
else
{
console.log('INFO: '.green + filename +'.cpp created');
//compiling and exrcuiting source code
if(envData.cmd === 'g++')
{
exports.compileCPPWithInput = function ( envData , code , input , fn ) {
var filename = cuid.slug();
path = './temp/';
//create temp0
fs.writeFile( path + filename +'.cpp' , code , function(err ){
if(exports.stats)
{
if(err)
console.log('ERROR: '.red + err);
else
{
console.log('INFO: '.green + filename +'.cpp created');
if(envData.cmd ==='g++')
{
//compile c code
commmand = 'g++ ' + path + filename +'.cpp -o '+ path + filename+'.exe' ;
var filesToSave = {}
if (e.target.password.value.trim()) {
let password = e.target.password.value + '~' + SALT + '~' + name
let w = SimpleEncryptor(password)
for (let i = 0; i < queuedFiles.length; i++) {
let {url, name} = queuedFiles[i]
let encurl = w.encrypt(url)
let encname = w.encrypt(name)
filesToSave[cuid.slug()] = {url: encurl, name: encname}
}
for (let i = 0; i < validLinks.length; i++) {
let encl = w.encrypt(validLinks[i])
filesToSave[cuid.slug()] = {url: encl, name: encl}
}
} else {
for (let i = 0; i < queuedFiles.length; i++) {
let {url, name} = queuedFiles[i]
filesToSave[cuid.slug()] = {url, name}
}
for (let i = 0; i < validLinks.length; i++) {
let url = validLinks[i]
filesToSave[cuid.slug()] = {url, name: url}
}
}
filekeys
.child(nextkey)
.set({
choices: this.props.qaData.answer.data.multiple.choices.map(choice => ({
unit: choice.unit,
mixedValue: choice.value || choice.written,
cuid: cuid.slug(),
})),
} : null,
instanceByName(middlewareName) {
const middleware = middlewareFactoryMap.get(middlewareName);
const middlewareObject = {
name: middlewareName,
type: middleware.type,
cuid: cuid.slug(),
whichList: this.props.whichList,
};
if (middleware.type === 'protocol' || middleware.type === 'middleware') {
const middlewareInstance = new middleware.factory();
middlewareObject.instance = middlewareInstance;
} else {
middlewareObject.path = middleware.path;
}
return middlewareObject;
}
makeUniqueFn = ({ slug }) => `${slug}-${cuid.slug()}`;
} else {
async createIncident (incident) {
if (!incident) {
throw new Error('Incident is empty')
}
if (!incident.updates || incident.updates.length === 0) {
throw new Error('Incident has no updates')
}
const id = `${slug(incident.title)}-${cuid.slug()}`.toLowerCase()
const timestamp = new Date().toISOString()
incident.id = id
incident.createdAt = timestamp
incident.status = incident.updates[0].status || incident.status
incident.resolvedAt = incident.status === config.Statuses.RESOLVED ? timestamp : undefined
incident.updates[0].status = incident.status
incident.updates[0].updatedAt = timestamp
const result = this.db.get('incidents').unshift(incident).write()
if (!result[0].id) {
throw new Error('Unable to create incident.')
}
this.db.set('unpublishedChanges', true).write()
return { id }
}