Skip to content

Instantly share code, notes, and snippets.

View Linrstudio's full-sized avatar
🌴
On vacation

xyz Linrstudio

🌴
On vacation
View GitHub Profile
import React from 'react'
function defaultGetWidth () {
return window.innerWidth;
}
function defaultGetHeight () {
return window.innerHeight;
}
@Gaubee
Gaubee / GaussianBlur.js
Last active March 1, 2018 02:59
PIXI.js gaussian triangle blur
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
define(["require", "exports"], function (require, exports) {
var GaussianBlur = (function (_super) {
__extends(GaussianBlur, _super);
function GaussianBlur() {
@kdzwinel
kdzwinel / main.js
Created April 15, 2016 20:59
Animate any UI component in a fancy way
function getFamilyTree(el) {
const levels = new Map();
function bfs(el, level) {
const levelElements = levels.get(level) || [];
for (const child of el.children) {
child.style.opacity = '0';
levelElements.push(child);
@ryan-roemer
ryan-roemer / bundle.multiple-exports.js
Last active March 4, 2021 05:44
Webpack: Various ways to have multiple exports.
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
@bameyrick
bameyrick / detect-number-of-children.css
Created March 29, 2016 09:04
Detect the number of children purely in css
/* one item */
li:first-child:nth-last-child(1) {
width: 100%;
}
/* two items */
li:first-child:nth-last-child(2),
li:first-child:nth-last-child(2) ~ li {
width: 50%;
}
@nadav-dav
nadav-dav / dom2comp.js
Created March 15, 2016 10:37
React: Getting a component from a DOM element
let searchRoot = ReactDom.render(React.createElement(Main), document.getElementById('main'));
try {
var getComponent = (comp) => comp._renderedComponent ? getComponent(comp._renderedComponent) : comp;
var getComponentById = (id)=> {
var comp = searchRoot._reactInternalInstance;
var path = id.substr(1).split('.').map(a=> '.' + a);
if (comp._rootNodeID !== path.shift()) throw 'Unknown root';
while (path.length > 0) {
comp = getComponent(comp)._renderedChildren[path.shift()];
@kdzwinel
kdzwinel / kata.js
Last active February 11, 2020 17:32
Code kata featuring: fetch, promises, array.sort, array.reduce, array.map
// 1) fetch members of polish parlament (poslowie)
// 2) group them by occupation
// 3) sort occupations by number of members and occupation name
// 4) get top 5 entries
// 5) print result on the screen
(function() {
'use strict';
const POSLOWIE_ENDPOINT = 'https://api-v3.mojepanstwo.pl/dane/poslowie/';
<head>
...
<meta name="viewport" content="width=device-width">
...
</head>
@rotassator
rotassator / css-prevent-autofill-styles.css
Last active March 7, 2018 00:13
CSS: prevent Webkit autofill styles
// prevent webkit autofill style
&:-webkit-autofill,
&:-webkit-autofill:focus {
-webkit-box-shadow: 0 0 0 100px #fff inset;
-webkit-text-fill-color: #333;
}
Math.radians = function(degrees) {
return degrees * Math.PI / 180;
};
Math.degrees = function(radians) {
return radians * 180 / Math.PI;
};
Math.ctg = function(val) {
return 1/Math.tan(val);
}