Skip to content

Instantly share code, notes, and snippets.

Daniel Busłowicz Draccoz

Block or report user

Report or block Draccoz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View typedModel.ts
type TypedDispatcher<R> = R extends (state: any, payload?: infer P, meta?: infer M) => any
? (payload?: P, meta?: M) => Action<P, M>
: R extends (state: any, payload: infer P, meta?: infer M) => any
? (payload: P, meta?: M) => Action<P, M>
: R extends (state: any, payload: infer P, meta: infer M) => any
? (payload: P, meta: M) => Action<P, M>
: null;
type StripUnknown<T> = T extends (payload?: unknown, meta?: unknown) => Action<unknown, unknown>
? () => Action<never, never>
@Draccoz
Draccoz / extension.js
Last active Oct 4, 2017
Generates a CUID and copies it to clipboard.
View extension.js
const St = imports.gi.St;
const Main = imports.ui.main;
const Shell = imports.gi.Shell;
const Clipboard = St.Clipboard.get_default();
const CLIPBOARD_TYPE = St.ClipboardType.CLIPBOARD;
const namespace = 'cuid';
const blockSize = 4;
const base = 36;
@Draccoz
Draccoz / destroyable.js
Created Dec 20, 2016
Destroyable web components mixin
View destroyable.js
const Destroyable = (superclass, destroyTimeout) => class extends superclass {
detachedCallback() {this.__destroying = setTimeout(() => { if (!this.isConnected && this.destroyedCallback) this.destroyedCallback() }, destroyTimeout)},
attachedCallback() {clearTimeout(this.__destroying)}
};
@Draccoz
Draccoz / transform.js
Created Dec 8, 2016
CSS Transform getter and setter from single template
View transform.js
function buildPatterns(order) {
let orderMap = {};
let orderArray = order.split("|");
orderArray.forEach((t, i) => orderMap[ t ] = i);
return (consts, ...vars) => {
const escapePars = [ /(\(|\))/g, "\\$1" ];
const map = {
number: { match: `([\\de.-]+)`, cast: Number },
string: { match: `([\\w.-]+)`, cast: String },
@Draccoz
Draccoz / oarray.js
Last active Dec 2, 2016
Observable Array (POC, very slow)
View oarray.js
const mediator = new WeakMap();
const notify = (instance, ev, index, item) => mediator.get(instance)[ev].forEach(listener => listener({index, item}));
class OArray extends Array {
constructor() {
super();
mediator.set(this, {changed: [], added: [], removed: []});
}
push(...items) {
for (let i = 0, tl = this.length, l = items.length; i < l; i++) {
let item = items[i];
@Draccoz
Draccoz / config
Created Oct 14, 2016
Nginx config for wrapping js imports as html5 imports
View config
location ~/html-imports/(.+)$ {
set $path $1;
default_type 'text/html';
content_by_lua 'ngx.say("<script src=\'", ngx.var.path, ".js\'></script>")';
}
@Draccoz
Draccoz / polymer-expression-binding-behavior.js
Last active May 17, 2016
Google Polymer behavior allowing to use simple javascript expressions inside of the templates
View polymer-expression-binding-behavior.js
(function (global) {
var dynamicFunctionsNames = {};
var cached = {};
function expressBinding(match, p) {
var fun;
var attrs = p
.replace(/&amp;/g, "&") // decode &
.replace(/&lt;/g, "<") // decode <
.replace(/&gt;/g, ">") // decode >
You can’t perform that action at this time.