Skip to content

Instantly share code, notes, and snippets.

Avatar
🙂

Nikhil Vijayan nkhil

🙂
View GitHub Profile
View sum_of_pairs.md

Sum of Pairs

Given a list of integers and a single sum value, return the first two values (parse from the left please) in order of appearance that add up to form the sum. CodeWars kata link

Note: The following solution is not by me. It was one of the first solutions in the showcase under 'Solutions'. Apologies for not attributing the authors.

var sum_pairs = function (ints, s) {
@nkhil
nkhil / s3.md
Last active Oct 8, 2020
Creating copies of files
View s3.md

Create bucket 'test'

awslocal s3api create-bucket --bucket test --region us-east-1

Copy local file into S3

awslocal s3 cp test.txt s3://test/test.txt
@nkhil
nkhil / longest_palindrome.md
Last active Sep 14, 2020
Given a string, find the longest palindrome (JavaScript)
View longest_palindrome.md

Find the longest palindrome (JavaScript)

This is my solution to the longest palindrome kata on Code Wars.

Solution

  function reverseString(st) {
    return st.split('').reverse().join('')
  }
View smiley.md

Given an array (arr) as an argument complete the function countSmileys that should return the total number of smiling faces. Rules for a smiling face:

  • Each smiley face must contain a valid pair of eyes. Eyes can be marked as : or ;
  • A smiley face can have a nose but it does not have to. Valid characters for a nose are - or ~
  • Every smiling face must have a smiling mouth that should be marked with either ) or D
  • No additional characters are allowed except for those mentioned.
  • Valid smiley face examples: :) :D ;-D :~)
  • Invalid smiley faces: ;( :> :} :]
View healthcheck.js
// ./src/handlers/healthcheck.js
'use strict'
function ping(_, res) {
res.status(200).json({ message: 'OK' });
}
module.exports = {
ping,
View index.js
'use strict';
const express = require('express');
const cors = require('cors');
const path = require('path');
const { OpenApiValidator } = require('express-openapi-validator');
const config = require('./config');
const app = express();
const apiSpec = path.join(__dirname, `../definitions/${config.name}.yml`);
View definitions.yaml
paths:
/healthcheck/ping:
get:
description: Returns the readiness of the service
operationId: ping
x-eov-operation-id: ping
x-eov-operation-handler: healthcheck
parameters:
- $ref: '#/components/parameters/x-correlation-id'
responses:
View node-scheduler.md

Quick reference for using node-scheduler

Every 5 seconds

const x = schedule.scheduleJob('*/5 * * * * *', function() {
  console.log('The answer to life, the universe, and everything!');
});
View vscode_settings.json
{
"window.zoomLevel": 0,
"terminal.integrated.shell.osx": "zsh",
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
"editor.minimap.enabled": false,
"workbench.iconTheme": "material-icon-theme",
"workbench.editor.enablePreview": false,
"editor.tabSize": 2,
"editor.rulers": [100],
View mongodb_cheat_sheet.md

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

You can’t perform that action at this time.