Skip to content

Instantly share code, notes, and snippets.

View somebody32's full-sized avatar

Ilya Zayats somebody32

View GitHub Profile
@somebody32
somebody32 / automator.js
Created February 17, 2019 12:52
Fluent typing effect with Automator
const sysEvents = Application("System Events");
sysEvents.includeStandardAdditions = true;
function typeWithDelay(text, delayValue = 0.02) {
if (delayValue) {
for (let i = 0; i < text.length; i++) {
sysEvents.keystroke(text[i]);
delay(delayValue);
}
@somebody32
somebody32 / README.md
Last active April 25, 2022 18:24
Tailwind purging + external components library

Prerequisites

  1. The app that uses tailwind + external component library (CL) (but not 3rdparty, your company internal one, for example)
  2. The component library also uses tailwind

The goal

To be able to purge safely unused tailwind classes from the build (https://tailwindcss.com/docs/controlling-file-size)

Solution

The idea here is simple: we're going to purge css on the app side + whitelist classes that component library is using.

ActiveRecord::Base.transaction do
- # doing delete ... where task_id in (...) and subtask_id is null (inequality test on secondary key),
- # locks secondary indexes and primary key index
- AssignedUser.where(task_id: task.id, subtask_id: nil).delete_all
+ assigned_user_ids_to_clean = AssignedUser.where(task_id: task.id, subtask_id: nil).pluck(:id)
+ # doing delete ... where id in (...) (equality test on primary key), locks only primary key index
+ AssignedUser.where(id: assigned_user_ids_to_clean).delete_all
task.assigned_user_ids = assigned_user_ids # inserts multiple records
end
@somebody32
somebody32 / router.diff
Last active July 16, 2016 16:49
Webpack 2 Router diff
import Backbone from 'backbone';
import $ from 'jquery';
import AppFinder from './app_finder';
export default Backbone.Router.extend({
routes: {
'': 'home',
'main_app_part': 'mainAppPart',
'*handleMissingRoute': 'handle404',
@somebody32
somebody32 / router.diff
Last active July 16, 2016 16:49
webpack 2 router example
import Backbone from 'backbone';
import $ from 'jquery';
import AppFinder from './app_finder_test';
export default Backbone.Router.extend({
routes: {
'': 'home',
'main_app_part': 'mainAppPart',
'*handleMissingRoute': 'handle404'
@somebody32
somebody32 / index.diff
Created February 6, 2016 19:47
Removing mini apps from index.js
import Backbone from 'backbone';
import $ from 'jquery';
import Router from './router';
$(() => {
new Router();
- require.ensure([], require => {
- const AboutApp = require('./apps/about/').default;
@somebody32
somebody32 / app_finder.diff
Last active February 6, 2016 20:02
Requiring metadata with webpack
import _ from 'underscore';
import Backbone from 'backbone';
- // all the routes from the mini-apps
- const custom_apps_routes = {
- about: {
- 'about': 'about',
- },
- heavy: {
- 'heavy(/:heavy_param)': 'heavy',
@somebody32
somebody32 / metadata-about.js
Created February 6, 2016 18:48
Adding metadata
import routes from './routes';
export default {
name: 'about',
routes
};
@somebody32
somebody32 / router.diff
Created February 6, 2016 18:43
Extracting routes
port Backbone from 'backbone';
import $ from 'jquery';
+ import routes from './routes';
export default Backbone.Router.extend({
- routes: {
- 'about': 'about',
- },
+ routes,
@somebody32
somebody32 / router.diff
Last active February 6, 2016 18:28
router with bundle loader
import Backbone from 'backbone';
import $ from 'jquery';
import AppFinder from './app_finder_test';
export default Backbone.Router.extend({
routes: {
'': 'home',
'main_app_part': 'mainAppPart',
'*handleMissingRoute': 'handle404'