Skip to content

Instantly share code, notes, and snippets.

View gmlnchv's full-sized avatar

Georgy Malanichev gmlnchv

View GitHub Profile
@WebReflection
WebReflection / why-i-use-web-components.md
Last active December 5, 2023 17:47
Why I use web components

Why I use web components

This is some sort of answer to recent posts regarding Web Components, where more than a few misconceptions were delivered as fact.

Let's start by defining what we are talking about.

The Web Components Umbrella

As you can read in the dedicated GitHub page, Web Components is a group of features, where each feature works already by itself, and it doesn't need other features of the group to be already usable, or useful.

/*!
* Webflow: Front-end site library
* @license MIT
* Inline scripts may access the api using an async handler:
* var Webflow = Webflow || [];
* Webflow.push(readyFunction);
*/
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
@developit
developit / unistore.js
Last active September 8, 2020 15:13
Update: the newer & better version of this is published: https://github.com/developit/unistore
import { h, Component } from 'preact';
/** Creates a new store, which is a tiny evented state container.
* @example
* let store = createStore();
* store.subscribe( state => console.log(state) );
* store.setState({ a: 'b' }); // logs { a: 'b' }
* store.setState({ c: 'd' }); // logs { c: 'd' }
*/
@danieldunderfelt
danieldunderfelt / StoreContainer.js
Created October 28, 2016 15:36
next.js global store that persists between routes
/**
* PROBLEM:
* In next.js, each route points to a distinct top-level component.
* Since there is no higher-level components in next.js, how to have
* a store that persists between route changes is not immediately
* obvious. One solution is this: a higher-order component that you
* wrap each of your top-level route components with.
*
* This is borrowed from next.js' Redux example from here:
* https://github.com/zeit/next.js/wiki/Redux-example
@vincentorback
vincentorback / debounce-es2015.js
Last active July 22, 2024 11:49
Smarter debouncing
export function debounce (fn, wait = 1) {
let timeout
return function (...args) {
clearTimeout(timeout)
timeout = setTimeout(() => fn.call(this, ...args), wait)
}
}
@chrismccoy
chrismccoy / gitcheats.txt
Last active July 16, 2024 11:44
git cheats
# alias to edit commit messages without using rebase interactive
# example: git reword commithash message
reword = "!f() {\n GIT_SEQUENCE_EDITOR=\"sed -i 1s/^pick/reword/\" GIT_EDITOR=\"printf \\\"%s\\n\\\" \\\"$2\\\" >\" git rebase -i \"$1^\";\n git push -f;\n}; f"
# count total commits in a repo
git rev-list --all --count
# edit all commit messages
git rebase -i --root
@katowulf
katowulf / 1_query_timestamp.js
Last active September 21, 2023 20:28
Get only new items from Firebase
// assumes you add a timestamp field to each record (see Firebase.ServerValue.TIMESTAMP)
// pros: fast and done server-side (less bandwidth, faster response), simple
// cons: a few bytes on each record for the timestamp
var ref = new Firebase(...);
ref.orderByChild('timestamp').startAt(Date.now()).on('child_added', function(snapshot) {
console.log('new record', snap.key());
});
@cullymason
cullymason / Laravel_Ember.md
Last active December 20, 2015 21:38
It would be nice if we had a plugin that allows Laravel to play nice with Ember. Put simply I would like to create an easy way for Laravel to output JSON strings in a way that Ember likes.

Basic Explaination

It would be nice if we had a plugin that allows Laravel to play nice with Ember. Put simply I would like to create an easy way for Laravel to output JSON strings in a way that Ember likes.

What Laravel Does

return Model::find($id);
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active July 7, 2024 19:32
A badass list of frontend development resources I collected over time.
@markdurrant
markdurrant / _fluid-grid-generator-mixin.scss
Created August 13, 2012 16:10
Sass fluid grid generator mixin based on Twitter Bootstrap fluid grid.
// =======================================================================
// Fluid Grid Generator Mixin
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// Based on fluid grid from http://twitter.github.com/bootstrap/
// =======================================================================
//
//
// Parameters
// =======================================================================