Skip to content

Instantly share code, notes, and snippets.

View john-lemon's full-sized avatar

Roman Dmiterko john-lemon

View GitHub Profile
const getOptions = require('loader-utils').getOptions;
const validateOptions = require('schema-utils');
module.exports = function (source) {
const schema = {
type: 'object',
properties: {
attributes: {
type: 'array',
items: {
@john-lemon
john-lemon / Gist.md
Last active December 5, 2017 12:19
Difference between method = () = {} and method () {} as class methods
class Foo {
  constructor() {
    this.handleClick = this.handleClick.bind(this)
  }
  
  consoleLog () {
  	console.log('consoleLog')
    console.log(this)
   	console.log('-------')
@john-lemon
john-lemon / Python test mock methods and fields
Last active August 18, 2017 09:12
python_tests_mock_tip.py
from unittest.mock import Mock, patch
from path.to.your.class import Classname
"""if you need to mock class feild:"""
@patch.object(Classname, 'Fieldname', new=<new_value>)
def your_test(self):
"""If you need to mock class method:"""
npm ls -gp --depth=0 | awk -F/ '/node_modules/ && !/\/npm$/ {print $NF}' | xargs npm -g rm
We couldn’t find that file to show.
@john-lemon
john-lemon / swipe.js
Created October 8, 2015 12:55
Detect swipe event on pure js
document.addEventListener('touchstart', handleTouchStart, false);
document.addEventListener('touchmove', handleTouchMove, false);
var xDown = null;
var yDown = null;
function handleTouchStart(evt) {
xDown = evt.touches[0].clientX;
yDown = evt.touches[0].clientY;
};
@john-lemon
john-lemon / script.js
Created June 18, 2015 13:56
Input formatting for mask HH:MM
function timeField(input) {
var time = '23:59'
var mins = '00'
var numberPattern = /\d|:/g ;
var noDotsPattern = /\d/g ;
input.keyup(function(e){
var len = input.val().length;
var match = input.val().match(numberPattern);
@john-lemon
john-lemon / gulpfile.js
Last active August 29, 2015 14:06
Working example for stylus compile by gulp (include package.json)
/*
{
"name": "project",
"version": "0.0.0",
"devDependencies": {
"gulp": "^3.8.8",
"gulp-concat": "^2.4.0",
"gulp-rename": "^1.2.0",
"gulp-stylus": "^1.3.2",
@john-lemon
john-lemon / Preferences.sublime-settings
Last active August 29, 2015 14:03
My ST3 settings
{
"bold_folder_labels": true,
"detect_indentation": true,
"drag_text": true,
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"font_face": "Monaco",
"font_size": 14.0,
"highlight_line": true,
"highlight_modified_tabs": true,