Skip to content

Instantly share code, notes, and snippets.

View Krasnov8953's full-sized avatar

krasnov8953 Krasnov8953

View GitHub Profile
@Krasnov8953
Krasnov8953 / launch.json
Created January 29, 2020 17:14
vscode debug config
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Next: Chrome",
@Krasnov8953
Krasnov8953 / index.js
Created September 12, 2019 09:34
regex for validating string containing only whitespaces
/^(?!\s).*$/
@Krasnov8953
Krasnov8953 / .hyper.js
Last active April 19, 2019 19:04
hyper.is sync
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
syncSettings: {
quiet: false,
accelerators: {
checkForUpdates: 'CmdOrCtrl+8'
function memoize(func) {
const memo = {};
return function() {
const args = [...arguments];
if (args in memo) {
return memo[args];
}
else {
const debounce = (callback, delay) => {
let timerId;
return (...args) => {
timerId && clearTimeout(timerId);
timerId = setTimeout(
() => callback(...args),
delay
);
}
};
@Krasnov8953
Krasnov8953 / index.js
Created June 4, 2018 17:38
HMR React
if (module.hot && process.env.NODE_ENV !== 'production') {
console.log('HMR enabled')
module.hot.accept('./components/App', () => {
const NextApp = App.default
ReactDOM.render(
<NextApp />,
document.getElementById('root')
)
});
}
@Krasnov8953
Krasnov8953 / unpack.bash
Last active March 5, 2018 18:37
unpack tar.gz in terminal to opt folder
sudo tar xfz WebStorm-*.tar.gz -C /opt/
import find from 'lodash/find';
import findIndex from 'lodash/findIndex';
import moment from 'moment';
import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);
const state = {
isAuthenticated: false,
@Krasnov8953
Krasnov8953 / scroll.js
Created June 16, 2017 09:02
cmoozy scroll to ankor links
$('[data-action=link]').click(function(e){
e.preventDefault();
var toId = $(this).attr('href');
$('html,body').animate({
scrollTop:($(toId).offset().top)
}, 500);
});
@Krasnov8953
Krasnov8953 / gist:5c4f4cdc829537ed6c42f74130835240
Created May 24, 2017 11:08
drag and drop files to input type file
$(document).ready(function(){
$('body').on('dragenter', function(){
$('input[type="file"]').addClass('drag');
console.log('enter');
});
$('input[type="file"]').on('dragleave', function(e){
e.stopPropagation();
$('input[type="file"]').removeClass('drag');