Skip to content

Instantly share code, notes, and snippets.

View apostololeg's full-sized avatar
🦉
d–_–b

Oleg Apostol apostololeg

🦉
d–_–b
View GitHub Profile
@apostololeg
apostololeg / test.js
Last active August 29, 2015 14:02
vow promises
var vow = require('vow'),
request = require('request'),
handler = 'http://api.geonames.org/postalCodeLookupJSON?postalcode=6600&country=AT&username=demo';
function getData(remote) {
if(remote) {
var promise = new vow.promise();
request(remote, function(err, req, body) {
@apostololeg
apostololeg / scrollIntoView.js
Last active September 15, 2018 06:24
scrollIntoView
function scrollIntoView(elem) {
var elemTop = elem.offset().top,
elemBottom = elemTop + elem.height(),
viewHeight = window.innerHeight,
limitTop = window.scrollY,
limitBottom = limitTop + viewHeight,
offset = 10;
if (elemTop < limitTop) {
window.scrollTo(0, elemTop - offset);
var backgroundColor = '#262626';
var activeColor = 'darkcyan';
var highlightColor = '#152929';
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 12,
// font family with optional fallbacks
fontFamily: 'Menlo, "DejaVu Sans Mono", "Lucida Console", monospace',
.List {
height: 100%;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
.List__inner {
margin: 0;
padding: 0;
list-style: none;
{
"always_show_minimap_viewport": true,
"auto_indent": true,
"bold_folder_labels": true,
"close_sidebar_if_opened": false,
"color_scheme": "Packages/User/SublimeLinter/Juicy (SL).tmTheme",
"enable_tab_scrolling": false,
"ensure_newline_at_eof_on_save": true,
"font_face": "Menlo",
"font_options":
@apostololeg
apostololeg / eslint-changed.sh
Last active July 4, 2018 12:26 — forked from kentcdodds/eslint-changed.sh
Shell script to lint only changed files to be used as a githook (specific to my project)
#!/usr/bin/env bash
set -e
NM_BIN=./node_modules/.bin
echo "Linting changed files"
SRC_FILES=$(git diff --staged --diff-filter=ACMTUXB --name-only -- '*.js' | grep -v '\.test\|mock\|e2e\.js$') && x=1
function lint() {
if [ "$2" ]; then
@apostololeg
apostololeg / Elevator.js
Last active January 22, 2019 11:49
Elevator
const DIRECTION_DOWN = -1;
const DIRECTION_NONE = 0;
const DIRECTION_UP = 1;
function HardwareElevator() {}
HardwareElevator.prototype = {
moveUp: function() { console.log("up") },
moveDown: function() { console.log("down") },
#!/bin/bash
gpg --version # Check GPG installation
git --version # Check Git installation
git-secret --version # Check git-secret installation
gpg --list-keys # Make sure that your GPG key is listed here
git init # Initialize the repository if you have not done it already
git secret init # Initialize the repository using git-secret
git secret tell email@example.com # Add a user
const METRICS_BY_AXIS = {
horizontal: {
size: 'clientWidth',
scroll: 'scrollWidth'
},
vertical: {
size: 'clientHeigh',
scroll: 'scrollHeigh'
}
};
// Mask('**.**.****', '17.02');
// Mask('+7 (***) ***-**-**', '9854554354123283293');
// Mask('+7 (***) ***-**-**', '9854554354123283293', { isStrict: true });
export function mask(maskStr, str, { isStrict = false } = {}) {
let decorSymbCount = 0;
let maskedStr = '';
for (let i = 0; i < maskStr.length && str[i - decorSymbCount]; i++) {
const m = maskStr[i];
const v = str[i - decorSymbCount];