Skip to content

Instantly share code, notes, and snippets.

Jack Tomaszewski jtomaszewski

Block or report user

Report or block jtomaszewski

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
@jtomaszewski
jtomaszewski / axe.js
Last active Mar 11, 2019 — forked from donaldpipowitch/axe.js
aXe based a11y checks in your CI for Storybook
View axe.js
/* eslint-disable no-await-in-loop */
/* eslint-disable no-restricted-syntax */
// eslint-disable-next-line import/no-extraneous-dependencies
const puppeteer = require('puppeteer');
const { green, red, cyan, grey, bold } = require('chalk');
const url = 'http://localhost:9001/iframe.html';
function runAxe() {
return new Promise((resolve, reject) =>
View appunite-frontend-code-formatting.md

Code formatting & linting

In AppUnite, we enforce proper code style by:

  1. formatting of all our **/*.{js,jsx,ts,tsx,css,less,scss} files with prettier,

  2. linting all **/*.js files with ESLint,

  3. linting all **/*.ts files with TSLint.

@jtomaszewski
jtomaszewski / rt-stateful-component.ts
Created Jan 11, 2019
Example implementation of StatefulComponent in Angular
View rt-stateful-component.ts
// Code authored by [Recruitee](https://recruitee.com)
// License: MIT
import { Injectable, ChangeDetectorRef } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
const immutableStateInvariantMiddleware = process.env.NODE_ENV !== 'production'
? require('redux-immutable-state-invariant').default
: null;
export interface RtStatefulComponent<State> {
View flatten.js
flatten = array => {
return array.reduce((sum, x) => {
if (Array.isArray(x)) {
return [...sum, ...flatten(x)];
} else {
return [...sum, x];
}
}, [])
};
View good-dumb-components-example.ts
// wrong (impure)
class DateTimePickerComponent {
timeZone: string = "Europe/Warsaw";
constructor(private account: AccountService) {
if (this.account.currentUser) {
this.timeZone = this.account.currentUser.timeZone;
}
}
View my-search-page.component.html
<div class="sidebar">
<my-search-page-sidebar
[filters]="state.filters"
(filtersChange)="changeFilters($event)">
</my-search-page-sidebar>
</div>
<div class="content">
<h2>Search</h2>
<my-search-page-query-input
[value]="state.query"
View Recruitee-code-formatting.md

Code formatting & linting

In Recruitee, enforce correct formatting of our files with js-beautify for all src/ng2/**/*.html files and prettier for all **/*.{ts,js,css,less} files.

We also lint all **/*.ts files (and components' .html templates) code style with TSLint, although during the automatic linting, we ignore legacy files listed in ./tslint.without-legacy.json.

During npm install, husky automatically sets up a pre-commit hook in this repository, that will check your code before each commit and fail if it's wrong. If you want to skip the pre-commit hook, you can run git commit --no-verify.

Additionally, our CI will also check your code with npm run format-test && npm run lint command and fail if it's badly formatted or its' non-legacy fi

@jtomaszewski
jtomaszewski / 015-disable_bitcode_on_ios.sh
Last active Jan 5, 2016
hooks/after_platform_add/015-disable_bitcode_on_ios.sh
View 015-disable_bitcode_on_ios.sh
#!/bin/sh
# Exit, if there's no ios here.
[[ $CORDOVA_PLATFORMS == *"ios"* ]] || exit 0
# This is needed until https://github.com/Wizcorp/phonegap-facebook-plugin/issues/1116 gets fixed.
XCCONFIG_FILE="platforms/ios/cordova/build.xcconfig"
if ! cat $XCCONFIG_FILE | grep -q "ENABLE_BITCODE"; then
echo "\nENABLE_BITCODE = NO" >> $XCCONFIG_FILE
fi
@jtomaszewski
jtomaszewski / deploy.rb
Last active Oct 21, 2015
Eye configuration for unicorn && sidekiq
View deploy.rb
# ...
namespace :deploy do
desc 'Restart application'
task :restart => ["eye:reload", "eye:restart"]
after :published, :restart
end
@jtomaszewski
jtomaszewski / app_run.coffee
Created Jan 7, 2015
Ionic Framework: Turn off animations on Android and iOS 6 devices.
View app_run.coffee
app.config ($injector) ->
model = ionic.Platform.device().model or ""
animateNavigation = ionic.Platform.grade == "a"
unless animateNavigation
defaults =
'$ionicNavBarConfig':
transition: 'no-animation'
'$ionicNavViewConfig':
transition: 'no-animation'
You can’t perform that action at this time.