Skip to content

Instantly share code, notes, and snippets.

View alisherafat01's full-sized avatar
🏠
Working from home

Ali Sherafat alisherafat01

🏠
Working from home
View GitHub Profile
@alisherafat01
alisherafat01 / tape.py
Last active December 17, 2016 11:59
Tape equilibrium
class Tape:
def __init__(self, _array):
self.array = _array
if len(self.array) < 2:
raise Exception("array must have at least 2 items")
# without considering complexity -> because of using sum() function in for loop
def getAnswer1(self):
leftSum = rithtSum = 0
diff = 999999999 # a big int number for the first comparison
@alisherafat01
alisherafat01 / gist:a16a3612545e206cba3ede4125b31931
Created March 13, 2018 19:49
sequelize-joi validation helper
const getFixedModelName = (modelName) => {
if (models[modelName]) return modelName;
return modelName.slice(0, -1);
};
const getModelFilterSchema = (modelName) => {
const modelWhereAttrs = {};
const modelAttrs = models[modelName].attributes;
for (let attr in modelAttrs) {
if (modelAttrs[attr].joiFilter)