Skip to content

Instantly share code, notes, and snippets.

View nobitagit's full-sized avatar
🕸️
The less I know the better

Aurelio nobitagit

🕸️
The less I know the better
View GitHub Profile
@nobitagit
nobitagit / index.MD
Created September 11, 2018 13:02
videos to watch
@nobitagit
nobitagit / launch.json
Last active July 29, 2018 18:56
VSCode ES2017 ingle file debug
{
 "name": "Single JS file",
 "type": "node",
 "request": "launch",
 "program": "${file}",
 "stopOnEntry": false,
 "args": [],
 "cwd": "${workspaceRoot}",
 "preLaunchTask": null,
 "runtimeExecutable": null,
@nobitagit
nobitagit / numlen.js
Last active June 6, 2018 21:20
Pipe implementation in js
const len = num => {
const isNum = !isNaN(parseFloat(num)) && isFinite(num);
if (!isNum) {
return new Error('not a number');
}
const str = num.toString().replace('.', '');
return str.length;
}
function translateError(msg) {
var newErr = new Error(msg); // placed here to get correct stack
return e => {
newErr.originalError = e;
throw newErr;
}
}
async function asyncTask() {
const user = await UserModel.findById(1).catch(translateError('No user found'))
maxScore = 7
scores = {
'q': 5,
'w': 4,
'e': 3,
'r': 2,
't': 3,
'y': 3,
'u': 2,
'i': 3,
# for a given sentence calcultate the characters score
def score_sentence(sentence):
scored = list(map(to_score, sentence))
aggregate = reduce(lambda x, y: x + y, scored, 0)
return aggregate
def to_score(ch):
if ch in scores:
if ch.isupper():
return scores[ch] + 2
else:
return scores[ch]
return maxScore
scores = {
'q': 5,
'w': 4,
'e': 3,
'r': 2,
't': 3,
'y': 3,
'u': 2,
'i': 3,
'o': 4,
# only diff by etension (or whatever pattern)
git diff -- '*.js'
# show file from another branch without checkout
git show master:./src/path/to/my/file.js
import re
from functools import reduce
my_str = "one two three"
words = re.split(r'(\s+)', my_str)
# Scoring logic
# To each finger we associate a score:
# thumbs: 1
# index: 1