How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • // Imports the Google Cloud Tasks library.
    const {CloudTasksClient} = require('@google-cloud/tasks');
    
    // Instantiates a client.
    const client = new CloudTasksClient();
    
    async function quickstart() {
      // TODO(developer): Uncomment these lines and replace with your values.
      // const project = 'my-project-id';
      // const queue = 'my-appengine-queue';
      // const location = 'us-central1';
      // const payload = 'hello';
    
      // Construct the fully qualified queue name.
      const parent = client.queuePath(project, location, queue);
    
      const task = {
        appEngineHttpRequest: {
          httpMethod: 'POST',
          relativeUri: '/log_payload',
        },
      };
    
      if (payload) {
        task.appEngineHttpRequest.body = Buffer.from(payload).toString('base64');
      }
    
      if (inSeconds) {
        task.scheduleTime = {
          seconds: inSeconds + Date.now() / 1000,
        };
      }
    
      const request = {
        parent: parent,
        task: task,
      };
    
      console.log('Sending task:');
      console.log(task);
      // Send create task request.
      const [response] = await client.createTask(request);
      const name = response.name;
      console.log(`Created task ${name}`);
    }
    quickstart();
    Docs
    0
  • //...
    const tsProject = ts.createProject('tsconfig.json');
    
    gulp.task('buildJs', () => {
        return tsProject.src()
            .pipe(tsProject())
            .js.pipe(inject.replace('var fsm; var behaviourTree; var utilityAI;', ''))
            .pipe(inject.prepend('window.fsm = {}; window.behaviourTree = {}; window.utilityAI = {};\n'))
            .pipe(inject.replace('var __extends =', 'window.__extends ='))
            .pipe(minify({ ext: { min: ".min.js" } }))
            .pipe(gulp.dest('./bin'));
    });
    
    
    
    //...
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">const</span> tsProject<span class="token operator">:</span> Project</code></pre>
    /esengine/BehaviourTree-ai mit
    0
  • //...
    const tsProject = ts.createProject('tsconfig.json');
    
    gulp.task('buildJs', () => {
        return tsProject.src()
            .pipe(tsProject())
            .js.pipe(inject.replace('var es;', ''))
            .pipe(inject.prepend('window.es = {};\n'))
            .pipe(inject.replace('var __extends =', 'window.__extends ='))
            .pipe(minify({ ext: { min: ".min.js" } }))
            .pipe(gulp.dest('./bin'));
    });
    
    
    
    //...
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">const</span> tsProject<span class="token operator">:</span> Project</code></pre>
    /esengine/ecs-framework Apache-2.0
    0
  • //...
    const tsProject = ts.createProject('tsconfig.json');
    
    gulp.task('buildJs', () => {
        return tsProject.src()
            .pipe(tsProject())
            .js.pipe(inject.replace('var fgui;', ''))
            .pipe(inject.prepend('window.fgui = {};\nwindow.fairygui = window.fgui;\n'))
            .pipe(inject.replace('var __extends =', 'window.__extends ='))
            .pipe(minify({ ext: { min: ".min.js" } }))
            .pipe(gulp.dest('./bin'));
    });
    
    
    
    //...
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">const</span> tsProject<span class="token operator">:</span> <span class="token builtin">any</span></code></pre>
    /fairygui/FairyGUI-egret mit
    0
  • function () {
        var tsProject = ts.createProject('tsconfig.json');
        var tsResult = tsProject.src()
            .pipe(tsProject())
            .once("error", function () {
                this.once("finish", () => process.exit(1));
            });
    
        return tsResult.pipe(gulp.dest(buildConfig.targetPath));
    }
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>local <span class="token keyword">var</span><span class="token punctuation">)</span> tsProject<span class="token operator">:</span> Project</code></pre>
    /aspose-words-cloud/aspose-words-cloud-node mit
    0
  • validate(" leading-space:and:weirdchars")
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token builtin">any</span></code></pre>
    Docs
    0
  • module.exports = class extends BaseGenerator {
      constructor(args, opts) {
        
        //...
    }
    
      initializing() {
        
        //...
    }
    
      prompting() {
        
        //...
    npmVersion(function(err, version){
          
          //...
    promptsPromise.then(function(props) {
            
            //...
    var validationResults = validate(this.props.name);
            
            //...
    }.bind(this));
        }.bind(this));
      }
    
      writing() {
        
        //...
    }
    
      end() {
        
        //...
    }
    
      /**
       * Given a list of Inquirer prompts, returns default values for each.
       *
       * It filters out prompts with `when` field set to false, those would not
       * haven been shown to the user anyway.
       *
       * @return {Promise.<Object>}
       */
      _getPromptDefaults(prompts) {
        
        //...
    }
    
      _getGeneratorLicenseOptions() {
        
        //...
    }
    }
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token punctuation">(</span>local <span class="token keyword">class</span><span class="token punctuation">)</span> <span class="token keyword">export</span><span class="token operator">=</span> <span class="token keyword">import</span> <span class="token keyword">export</span><span class="token operator">=</span></code></pre>
    /donejs/generator-donejs mit
    0
  • var validate = require("validate-npm-package-name")
     
    validate("some-package")
    validate("example.com")
    validate("under_score")
    validate("123numeric")
    validate("excited!")
    validate("@npm/thingy")
    validate("@jane/foo.js")
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">import</span> validate</code></pre>
    Docs
    0
  • module.exports = {
      
      //...
    ,
      actions() {
        const validation = validate(this.answers.name);
        validation.warnings &&
          validation.warnings.forEach((warn) => {
            console.warn('Warning:', warn);
          });
        validation.errors &&
          validation.errors.forEach((err) => {
            console.error('Error:', err);
          });
        
        //...
    },
      
      //...
    ,
    }
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">module</span> <span class="token keyword">export</span><span class="token operator">=</span> <span class="token punctuation">(</span>property<span class="token punctuation">)</span> <span class="token keyword">export</span><span class="token operator">=</span><span class="token operator">:</span> <span class="token punctuation">{</span> prompts<span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token punctuation">[</span>n<span class="token operator">:</span> <span class="token builtin">number</span><span class="token punctuation">]</span><span class="token operator">:</span> <span class="token punctuation">{</span> name<span class="token operator">:</span> <span class="token builtin">string</span><span class="token punctuation">;</span> message<span class="token operator">:</span> <span class="token builtin">string</span><span class="token punctuation">;</span> <span class="token keyword">default</span><span class="token operator">:</span> <span class="token builtin">string</span><span class="token punctuation">;</span> <span class="token function-variable function">filter</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">val<span class="token operator">:</span> any</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token builtin">any</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token operator">|</span> <span class="token punctuation">{</span> name<span class="token operator">:</span> <span class="token builtin">string</span><span class="token punctuation">;</span> message<span class="token operator">:</span> <span class="token builtin">string</span><span class="token punctuation">;</span> <span class="token keyword">default</span><span class="token operator">:</span> <span class="token builtin">string</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token operator">|</span> <span class="token punctuation">{</span> name<span class="token operator">:</span> <span class="token builtin">string</span><span class="token punctuation">;</span> message<span class="token operator">:</span> <span class="token builtin">string</span><span class="token punctuation">;</span> store<span class="token operator">:</span> <span class="token builtin">boolean</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token operator">|</span> <span class="token punctuation">{</span> <span class="token operator">...</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token operator">|</span> <span class="token punctuation">{</span> <span class="token operator">...</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token operator">|</span> <span class="token punctuation">{</span> <span class="token operator">...</span><span class="token punctuation">;</span> <span class="token punctuation">}</span><span class="token punctuation">;</span> <span class="token operator">...</span> <span class="token number">34</span> more <span class="token operator">...</span><span class="token punctuation">;</span> <span class="token function">at</span><span class="token punctuation">(</span>index<span class="token operator">:</span> <span class="token builtin">number</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token punctuation">{</span> name<span class="token operator">:</span> <span class="token builtin">string</span><span class="token punctuation">;</span> message<span class="token operator">:</span> <span class="token builtin">string</span><span class="token punctuation">;</span> <span class="token keyword">default</span><span class="token operator">:</span> <span class="token builtin">string</span><span class="token punctuation">;</span> <span class="token function-variable function">filter</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">val<span class="token operator">:</span> any</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token builtin">any</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token operator">|</span> <span class="token operator">...</span> <span class="token number">4</span> more <span class="token operator">...</span> <span class="token operator">|</span> <span class="token punctuation">{</span> <span class="token operator">...</span><span class="token punctuation">;</span> <span class="token punctuation">}</span><span class="token punctuation">;</span> <span class="token function">at</span><span class="token punctuation">(</span>index<span class="token operator">:</span> <span class="token builtin">number</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token punctuation">{</span> name<span class="token operator">:</span> <span class="token builtin">string</span><span class="token punctuation">;</span> message<span class="token operator">:</span> <span class="token builtin">string</span><span class="token punctuation">;</span> <span class="token keyword">default</span><span class="token operator">:</span> <span class="token builtin">string</span><span class="token punctuation">;</span> <span class="token function-variable function">filter</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">val<span class="token operator">:</span> any</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token builtin">any</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token operator">|</span> <span class="token operator">...</span> <span class="token number">4</span> more <span class="token operator">...</span> <span class="token operator">|</span> <span class="token punctuation">{</span> <span class="token operator">...</span><span class="token punctuation">;</span> <span class="token punctuation">}</span><span class="token punctuation">;</span> <span class="token punctuation">}</span><span class="token punctuation">;</span> <span class="token function">actions</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token punctuation">{</span> <span class="token operator">...</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token operator">|</span> <span class="token punctuation">{</span> <span class="token operator">...</span><span class="token punctuation">;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token function">completed</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">Promise</span><span class="token operator">&lt;</span><span class="token operator">...</span><span class="token operator">></span><span class="token punctuation">;</span> <span class="token punctuation">}</span></code></pre>
    /vinayakkulkarni/janak MIT
    0
  • validate("eLaBorAtE-paCkAgE-with-mixed-case-and-more-than-214-characters-----------------------------------------------------------------------------------------------------------------------------------------------------------")
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token builtin">any</span></code></pre>
    Docs
    0
  • const vpc = ec2.Vpc.fromLookup(this, 'Vpc', {
      isDefault: true,
    });
    
    const cluster = new ecs.Cluster(this, 'FargateCluster', { vpc });
    
    const taskDefinition = new ecs.TaskDefinition(this, 'TD', {
      memoryMiB: '512',
      cpu: '256',
      compatibility: ecs.Compatibility.FARGATE,
    });
    
    const containerDefinition = taskDefinition.addContainer('TheContainer', {
      image: ecs.ContainerImage.fromRegistry('foo/bar'),
      memoryLimitMiB: 256,
    });
    
    const runTask = new tasks.EcsRunTask(this, 'RunFargate', {
      integrationPattern: sfn.IntegrationPattern.RUN_JOB,
      cluster,
      taskDefinition,
      assignPublicIp: true,
      containerOverrides: [{
        containerDefinition,
        environment: [{ name: 'SOME_KEY', value: sfn.JsonPath.stringAt('$.SomeKey') }],
      }],
      launchTarget: new tasks.EcsFargateLaunchTarget(),
    });
    
    Docs
    0
  • const vpc = ec2.Vpc.fromLookup(this, 'Vpc', {
      isDefault: true,
    });
    
    const cluster = new ecs.Cluster(this, 'Ec2Cluster', { vpc });
    cluster.addCapacity('DefaultAutoScalingGroup', {
      instanceType: new ec2.InstanceType('t2.micro'),
      vpcSubnets: { subnetType: ec2.SubnetType.PUBLIC },
    });
    
    const taskDefinition = new ecs.TaskDefinition(this, 'TD', {
      compatibility: ecs.Compatibility.EC2,
    });
    
    taskDefinition.addContainer('TheContainer', {
      image: ecs.ContainerImage.fromRegistry('foo/bar'),
      memoryLimitMiB: 256,
    });
    
    const runTask = new tasks.EcsRunTask(this, 'Run', {
      integrationPattern: sfn.IntegrationPattern.RUN_JOB,
      cluster,
      taskDefinition,
      launchTarget: new tasks.EcsEc2LaunchTarget({
        placementStrategies: [
          ecs.PlacementStrategy.spreadAcrossInstances(),
          ecs.PlacementStrategy.packedByCpu(),
          ecs.PlacementStrategy.randomly(),
        ],
        placementConstraints: [
          ecs.PlacementConstraint.memberOf('blieptuut'),
        ],
      }),
    });
    
    Docs
    0
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples