Skip to content

Instantly share code, notes, and snippets.

View jerryvig's full-sized avatar

Jerry Vigil jerryvig

  • Invitae
  • Austin, TX, USA
View GitHub Profile
@jerryvig
jerryvig / fibonacci.js
Last active August 29, 2015 14:01
Simple Fibonacci Algorithm in JavaScript
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));
};
@jerryvig
jerryvig / inherit.js
Created May 15, 2014 06:47
Simple JavaScript Inheritance Example
//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;
};
@jerryvig
jerryvig / anagram.js
Last active August 29, 2015 14:01
String.prototype.isAnagram
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 = {},
@jerryvig
jerryvig / singleton.js
Created May 16, 2014 19:45
Simple Singleton Pattern in JavaScript
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.
}
@jerryvig
jerryvig / dragdrop.js
Created May 20, 2014 17:35
HTML5 Drag & Drop Basic Example
//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(),
@jerryvig
jerryvig / function_composition.py
Last active May 19, 2017 00:54
How to compose multiple functions in Python3
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)
sudo -H -u mysql service mysqld restart
@jerryvig
jerryvig / remove_invalid_parentheses.py
Last active July 20, 2017 00:20
Interview Question - Remove Invalid Parentheses
# 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
@jerryvig
jerryvig / remove_invalid_parentheses.js
Created July 20, 2017 00:20
Interview Question - Remove Invalid Parentheses - JavaScript
/**
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) {
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