Skip to content

Instantly share code, notes, and snippets.

View kre1z0's full-sized avatar
:octocat:
CSS archbishop

Igor kre1z0

:octocat:
CSS archbishop
  • Ukraine, Khmelnytskyi
View GitHub Profile
@aPinix
aPinix / svg-rounded-rectangle-path.js
Last active April 16, 2024 21:22
Create a rounded rectangle (different radius for each corner)
createSvgRectWithBorderRadius('.wrapper', '#09f', 0, 0, 400, 300, 40, 70, 20, 110);
/**
* Create a rounded rectangle (different radius for each corner)
* @author aPinix <https://twitter.com/aPinix>
* @version 1.0
* @see {@link https://codepen.io/aPinix/pen/dyRvjQq}
* @link https://codepen.io/aPinix/pen/dyRvjQq
* @param {string} elemSelector The selector for the element to append the svg
* @param {string} color The color of the rectangle
@cjfswd
cjfswd / api_discord_get_channel_messages.js
Last active June 7, 2024 10:33
discord rest api get all messages from channel
import fs from 'fs'
import fetch from 'cross-fetch';
import dotenv from 'dotenv';
dotenv.config();
const TOKEN = process.env.TOKEN || ''
const GUILD_URL = process.env.GUILD_URL || ''
class IGuild {
@davidkpiano
davidkpiano / ts-0-60.ts
Last active January 22, 2021 04:55
TypeScript from 0 to 60
// No TypeScript
function add(a, b) {
return a + b;
}
// Type function arguments
// vvvvvv vvvvvv
function add(a: number, b: number) {
return a + b;
}
// This injects a box into the page that moves with the mouse;
// Useful for debugging
async function installMouseHelper(page) {
await page.evaluateOnNewDocument(() => {
// Install mouse helper only for top-level frame.
if (window !== window.parent)
return;
window.addEventListener('DOMContentLoaded', () => {
const box = document.createElement('puppeteer-mouse-pointer');
const styleElement = document.createElement('style');
@JMPerez
JMPerez / service-worker.js
Created October 27, 2018 20:21
An example of a service worker for serving network first, cache second
// the cache version gets updated every time there is a new deployment
const CACHE_VERSION = 10;
const CURRENT_CACHE = `main-${CACHE_VERSION}`;
// these are the routes we are going to cache for offline support
const cacheFiles = ['/', '/about-me/', '/projects/', '/offline/'];
// on activation we clean up the previously registered service workers
self.addEventListener('activate', evt =>
evt.waitUntil(
@akella
akella / facebook-normalize-wheel.js
Created November 25, 2017 22:49
Facebook attempt at normalizing wheel event
/**
* Copyright (c) 2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule normalizeWheel
* @typechecks
@mbostock
mbostock / .block
Last active May 19, 2020 12:51
Stacked Negative Values
license: gpl-3.0
redirect: https://observablehq.com/@d3/diverging-stacked-bar-chart
@A-gambit
A-gambit / REACTIVE2016-LIGHTNING-PROPOSAL.md
Last active February 22, 2024 18:24
Proposal for lightning talk at ReactiveConf 2016: Road from UndefinedLand

Proposal for a lightning talk at the Reactive 2016.

Keep calm and like/retweet it on Twitter and star this Gist to vote on this talk.

Road from UndefinedLand

Undefiend

I work at Grammarly. We like React and happily use it in our applications. However, sometimes something goes wrong and bugs creep into the code. Here comes testing. It helps make us confident about the quality of our code.

@huytd
huytd / d3-text-measure.js
Created May 6, 2016 18:19
Measure text size in pixels with D3.js
function textSize(text) {
if (!d3) return;
var container = d3.select('body').append('svg');
container.append('text').attr({ x: -99999, y: -99999 }).text(text);
var size = container.node().getBBox();
container.remove();
return { width: size.width, height: size.height };
}
// Usage: textSize("This is a very long text");

@kangax's ES6 quiz, explained

@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).

Here we go with the explanations:

Question 1:
(function(x, f = () =&gt; x) {