Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Victor Mus sdwvit

🏠
Working from home
View GitHub Profile
@sdwvit
sdwvit / sentenseCasePOC
Created Mar 19, 2018
Convert text to sentence case
View sentenseCasePOC
<html><body><input id="in"></input>
<br />
<button id="convert" onclick="convert()">Convert to sentence case</button>
<div id="out"></div>
<script>
function toSentenceCase(t) {
t = t.toLowerCase();
for (var e = !0, n = "", o = 0; o < t.length; o++) {
var r = t.charAt(o);
/\.|\!|\?|\n|\r/.test(r) ? e = !0 : "" != r.trim() && 1 == e && (r = r.toUpperCase(), e = !1), n += r
@sdwvit
sdwvit / cc.ts
Last active Nov 23, 2017
Holy clean code
View cc.ts
static checkComment(comment: Comment): void {
function resetCompactMode() { // TODO: props mutation is bad
comment.compactMode = false;
}
const parent = comment.compactMode && comment.parent;
if (!parent) { return; }
if (parent.level === 1 || parent.children.length > 1) {
@sdwvit
sdwvit / worker.example.js
Created Apr 1, 2017
Spawn worker abstraction
View worker.example.js
function spawnWorker(func) {
const response = `self.onmessage = () => postMessage(
(${func.toString()})()
)`;
const blob = new Blob([response], {type: 'application/javascript'});
const worker = new Worker(URL.createObjectURL(blob));
worker.onmessage = function (e) {
const data = e.data;
@sdwvit
sdwvit / gist:9ae1ce2cd463dc175e4fcdef05c28d84
Last active Feb 25, 2017
Linkedin: delete connections one by one with confirmation
View gist:9ae1ce2cd463dc175e4fcdef05c28d84
const keywords = ['recru', 'apply', 'looking for', 'hr', 'talent'];
const names = $('.mn-person-info__name');
const positions = $('.mn-person-info__occupation');
const dropdowns = $('.mn-connections__dropdown-trigger');
const deleteButtonSelector = () => $('.mn-connections__dropdown-option-btn');
const confirmButtonSelector = () => $('.remove-btn');
let connections = {};
for (let i = 0; i < names.length; i++) {
@sdwvit
sdwvit / gist:493b61d6367cae8d0b12d52f19092652
Last active May 16, 2016
Delete all branches on page github
View gist:493b61d6367cae8d0b12d52f19092652
$.map($('.branch-delete'), (val, i) => {return [val]}).forEach((el) => {el.click()})
You can’t perform that action at this time.