Skip to content

Instantly share code, notes, and snippets.

View somebody32's full-sized avatar

Ilya Zayats somebody32

View GitHub Profile
@somebody32
somebody32 / gist:5232120
Last active October 4, 2022 08:19
Список литературы для ознакомления с concurrent programming и реализацией этих принципов и подходов на ruby. Огромное спасибо @brainopia за составление.

Введение

Начать стоит отсюда. Не пугайтесь то, что это книга по незнакомой OS, эти термины практически везде одинаковые и здесь они изложены в понятной для начинающих форме.

http://www.qnx.com/developers/docs/6.4.1/neutrino/getting_started/s1_procs.html

Прочесть нужно треть главы до подраздела "Starting a process", если С не пугает, читайте полностью. После прочтения вы будете понимать, что такое process, thread, mutex, priorites, semaphores, scheduler, contex-switch, kernel states.

Ruby

@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.

@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
Created September 12, 2015 14:24
How to convert multiline vars into separate let/const declarations

You can convert js-code like this:

var a = '1',
    b,
    c = '2';

into

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 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 / 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 / index.diff
Last active February 6, 2016 20:16
importing apps in the index.js
import Backbone from 'backbone';
import $ from 'jquery';
import Router from './router';
+import AboutApp from './apps/about/';
+import HeavyApp from './apps/heavy/';
$(() => {
new Router();
+ AboutApp();
@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 / 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;