This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fib(n) { | |
//Other checks to validate the input go here. | |
//Assume n is a integer greater than or equal to zero if we get here. | |
return (n === 0 || n == 1) ? 1 : (fib(n-1) + fib(n-2)); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Define parent constructor. | |
var Parent = function (args) { | |
//Parent constructor code goes here. | |
this.name = args.name; | |
}; | |
//Define a parent's instance method. | |
Parent.prototype.getName = function () { | |
return this.name; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.isAnagram = function (testString) { | |
'use strict'; | |
if (typeof testString === 'string' || testString instanceof String) { | |
if (testString.length !== this.length) { | |
return false; | |
} | |
var thisArray = this.split(''), | |
testStringArray = testString.split(''), | |
thisCharCounts = {}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Singleton = function (args) { | |
if (Singleton.prototype.instance) { | |
return Singleton.prototype.instance; | |
} | |
Singleton.prototype.instance = this; | |
this.method1 = function (args) { | |
//do something with the args. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Suppose that you have a draggable span like this. | |
// <span style="position:relative;top:3px;" ng-bind="entity.Entity.Name" draggable="true" data-type="result"></span> | |
//Then implement draggability like this. | |
var draggableSpanList = $('span[draggable="true"]').get(); | |
$.each(draggableSpanList, function(idx, span) { | |
span.addEventListener('dragstart', function (evt) { | |
evt.stopPropagation(); | |
evt.dataTransfer.setData('text/plain', JSON.stringify({ | |
name: evt.target.innerHTML.trim(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import reduce | |
def compose(functions): | |
return reduce(lambda f, g: lambda x: f(g(x)), functions) | |
# Assume that you have an iterable such as list of functions to compose. | |
def functionsComposition(functions, x): | |
return compose(map(eval, functions))(x) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo -H -u mysql service mysqld restart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Interviwer asks: An expression will be given which can contain open and close parentheses and | |
# optionally some characters, No other operator will be there in string. We need to remove the minimum number of | |
# parentheses to make the input string valid. If more than one valid output is possible removing the same number | |
# of parentheses, then print all such output possibilities. | |
def isvalid(s): | |
ctr = 0 | |
for c in s: | |
if c == '(': | |
ctr += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Interviwer asks: An expression will be given which can contain open and close parentheses and | |
optionally some characters, No other operator will be there in string. We need to remove the minimum | |
number of parentheses to make the input string valid. If more than one valid output is possible | |
removing the same number of parentheses, then print all such output possibilities. | |
*/ | |
function isValidString(s) { | |
var count = 0; | |
for (let c of s) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Removing visual-regression-tests/mock-accounts/BASE_ACCOUNT/screenshots/baseline/protectedbrowsing_full_page_Chrome_v63_1024x654.png | |
Removing visual-regression-tests/mock-accounts/BASE_ACCOUNT/screenshots/baseline/help_full_page_Chrome_v63_1024x654.png | |
Auto-merging index.html | |
Auto-merging copy/en-US/dictionary.json | |
CONFLICT (content): Merge conflict in copy/en-US/dictionary.json | |
Auto-merging app/elements/si-page-troubleshoot-device/test/si-page-troubleshoot-device.html | |
Auto-merging app/elements/si-page-support/test/si-page-support.html | |
Auto-merging app/elements/si-page-support/si-page-support.js | |
Auto-merging app/elements/si-page-support/si-page-support.html | |
Auto-merging app/elements/si-page-device-entity/test/si-page-device-entity.html |
OlderNewer