Skip to content

Instantly share code, notes, and snippets.

View Krabaton's full-sized avatar
:dependabot:
Working

Yuriy Kuchma Krabaton

:dependabot:
Working
View GitHub Profile
@Krabaton
Krabaton / console.log
Created April 12, 2016 14:12
console.log
var css = "text-shadow: -1px -1px hsl(0,100%,50%), 1px 1px hsl(5.4, 100%, 50%), 3px 2px hsl(10.8, 100%, 50%), 5px 3px hsl(16.2, 100%, 50%), 7px 4px hsl(21.6, 100%, 50%), 9px 5px hsl(27, 100%, 50%), 11px 6px hsl(32.4, 100%, 50%), 13px 7px hsl(37.8, 100%, 50%), 14px 8px hsl(43.2, 100%, 50%), 16px 9px hsl(48.6, 100%, 50%), 18px 10px hsl(54, 100%, 50%), 20px 11px hsl(59.4, 100%, 50%), 22px 12px hsl(64.8, 100%, 50%), 23px 13px hsl(70.2, 100%, 50%), 25px 14px hsl(75.6, 100%, 50%), 27px 15px hsl(81, 100%, 50%), 28px 16px hsl(86.4, 100%, 50%), 30px 17px hsl(91.8, 100%, 50%), 32px 18px hsl(97.2, 100%, 50%), 33px 19px hsl(102.6, 100%, 50%), 35px 20px hsl(108, 100%, 50%), 36px 21px hsl(113.4, 100%, 50%), 38px 22px hsl(118.8, 100%, 50%), 39px 23px hsl(124.2, 100%, 50%), 41px 24px hsl(129.6, 100%, 50%), 42px 25px hsl(135, 100%, 50%), 43px 26px hsl(140.4, 100%, 50%), 45px 27px hsl(145.8, 100%, 50%), 46px 28px hsl(151.2, 100%, 50%), 47px 29px hsl(156.6, 100%, 50%), 48px 30px hsl(162, 100%, 50%), 49px 31px hsl(167.4, 100%, 5
$('a[href^="#"]').on('click', function(e){
e.preventDefault();
var
$this = $(this),
target = $this.attr('href'),
strip = target.slice(1),
anchor = $("[id='"+ strip +"']");
$('html, body').animate({
mixin triangle(className)
.ls-triangle-section(class=className)
svg(xmlns="http://www.w3.org/2000/svg" viewbox="0 0 1000 85" preserveaspectratio="none")
polygon.ls-triangle-section_left(points="0,0 0,86 500.8,86 500.8,75.5")
polygon.ls-triangle-section_right(points="1000,0 1000,86 500,86 500,75.5")
@Krabaton
Krabaton / router.html
Created July 3, 2016 16:38 — forked from joakimbeng/router.html
A really simple Javascript router
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Building a router</title>
<script>
// Put John's template engine code here...
(function () {
// A hash to store our routes:
function extend(Child, Parent) {
var F = function() {}
F.prototype = Parent.prototype
Child.prototype = new F()
Child.prototype.constructor = Child
Child.superclass = Parent.prototype
} // Child extend Parent {};
gulp.task('nodemon', callback => {
nodemon({
nodeArgs: ['--debug'],
script: 'index.js',
watch: ['*'],
ext: 'js css html jade json'
});
});
$phone-width: 320px;
$tablet-width: 768px;
$desktop-width: 1200px;
$large-desktop-width: 1800px;
@mixin phone {
@media (min-width: #{$phone-width}) and (max-width: #{$tablet-width - 1px}) {
@content;
}
}
@Krabaton
Krabaton / debounce.js
Created January 11, 2017 18:31
Debouncing
// debounce function that will wrap our event
function debounce(fn, delay) {
// maintain a timer
let timer = null;
// closure function that has access to timer
return function() {
// get the scope and parameters of the function
// via 'this' and 'arguments'
let context = this;
let args = arguments;
@Krabaton
Krabaton / array_iteration_thoughts.md
Created January 16, 2017 09:53 — forked from ljharb/array_iteration_thoughts.md
Array iteration methods summarized

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it much simpler to think about both the old list and the new one, what they contain, and

@Krabaton
Krabaton / app.js
Created February 17, 2017 01:08 — forked from sogko/app.js
gulp + expressjs + nodemon + browser-sync
'use strict';
// simple express server
var express = require('express');
var app = express();
var router = express.Router();
app.use(express.static('public'));
app.get('/', function(req, res) {
res.sendfile('./public/index.html');