Skip to content

Instantly share code, notes, and snippets.

View jtomaszewski's full-sized avatar

Jacek Tomaszewski jtomaszewski

View GitHub Profile
@donaldpipowitch
donaldpipowitch / axe.js
Created November 26, 2018 11:44
aXe based a11y checks in your CI for Storybook
const puppeteer = require('puppeteer');
const chalk = require('chalk');
const { green, red, cyan, grey, bold } = chalk;
// we assume storybook can visited at http://localhost:9001
const url = 'http://localhost:9001/iframe.html';
const runAxe = () =>
new Promise((resolve, reject) =>
@nicjansma
nicjansma / ie89-console-apply-support.js
Created January 29, 2013 17:42
Adds .apply() and .call() support to IE8/9's console object, which treates .log()/etc as Objects and not Functions. Requires jQuery for $.each().
if (Function.prototype.bind && typeof console == "object" && typeof console.log == "object") {
var logFns = ["log", "info", "warn", "error", "assert", "dir", "clear", "profile", "profileEnd"];
$.each(logFns, function (i, method) {
console[method] = Function.prototype.call.bind(console[method], console);
});
}
@jack-sf
jack-sf / KeyboardFocusHandler.tsx
Created July 8, 2019 08:42
Add `.has-keyboard-focus` class to your `<body>` element whenever keyboard focus is active - as an easy solution to add focus outline to all keyboard-focused elements (until `:focus-visible` is supported in all the major browsers)
import * as React from 'react';
import { document, window } from '../../../utils/browser';
// https://hackernoon.com/removing-that-ugly-focus-ring-and-keeping-it-too-6c8727fefcd2
export class KeyboardFocusHandler extends React.PureComponent {
componentDidMount(): void {
window!.addEventListener('keydown', this.handleFirstTab);
}
componentWillUnmount(): void {
@Globegitter
Globegitter / es.sh
Last active November 18, 2020 12:52
Easy install for elasticsearch on Ubuntu 14.04
cd ~
##If you want to install OpenJDK
#sudo apt-get update
#sudo apt-get install openjdk-8-jre-headless -y
###Or if you want to install Oracle JDK, which seems to have slightly better performance
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
@vasilii-b
vasilii-b / magento2-layout-empty-container.xml
Last active January 14, 2021 23:58
Adding an empty container in Magento 2 layout file
<container name="some.container" htmlTag="div" htmlClass="container">
<!-- Force container to render -->
<block class="Magento\Framework\View\Element\Text">
<arguments>
<argument name="text" xsi:type="string"><![CDATA[&nbsp;]]></argument>
</arguments>
</block>
</container>
@NickClark
NickClark / thoughts.markdown
Last active September 27, 2021 22:33
Elm vs TypeScript Thoughts

Elm and TypeScript

  • Elm Task - An Elm specific implementation of Observables (more limited?)
  • TS and Elm - Once it compiles it usually runs (Provided you're following the warnings provided in either the compiler output (better) or editor (best) )
  • Editor and tooling support?
  • TS and Elm - Typed Langs
  • Most suitable for complete apps, not just a JS compiler
  • Enforces Reactive programming - Angular 2 (Observables) provides the same thing, just not forced.
  • Know TS, know JS. Able to contribute back to the community easier.
  • Object assignment kinda weird: { point | x = 42 } Reason? (overall weird sytnax)
@royshouvik
royshouvik / console.ts
Last active October 4, 2022 00:12
Nestjs REPL
import 'dotenv/config';
import { NestFactory } from '@nestjs/core';
import * as repl from 'repl';
import * as Logger from 'purdy';
const LOGGER_OPTIONS = {
indent: 2,
depth: 1,
};
@jrhames
jrhames / moment-holidays.js
Last active January 19, 2023 03:12
Holidays plugin for Moment.JS
//## Moment.JS Holiday Plugin
//
//Usage:
// Call .holiday() from any moment object. If date is a US Federal Holiday, name of the holiday will be returned.
// Otherwise, return nothing.
//
// Example:
// `moment('12/25/2013').holiday()` will return "Christmas Day"
//
//Holidays:
@ebeigarts
ebeigarts / RAILS_RELATIVE_URL_ROOT.md
Last active February 2, 2023 15:16
RAILS_RELATIVE_URL_ROOT

RAILS_RELATIVE_URL_ROOT

Rails

By default RAILS_RELATIVE_URL_ROOT is used only for asset pipeline.

To namespace your rails routes you need to wrap run MyApp::Application with map in your config.ru:

map ENV['RAILS_RELATIVE_URL_ROOT'] || "/" do
@wpiekutowski
wpiekutowski / some_subscription_test.exs
Created August 7, 2020 13:34
Testing subscriptions: Elixir + Absinthe + Phoenix WebSocket
defmodule App.Schema.SomeSubscriptionTest do
use App.SubscriptionCase
test "subscription: someSubscription" do
subscription_query = """
subscription {
someSubscription {
someData
}
}