Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Ali sherafatian alisherafat01

🏠
Working from home
View GitHub Profile
View gist:a16a3612545e206cba3ede4125b31931
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)
@alisherafat01
alisherafat01 / tape.py
Last active Dec 17, 2016
Tape equilibrium
View tape.py
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