Skip to content

Instantly share code, notes, and snippets.

@astashov
astashov / liftosaur_documentation.md
Created August 16, 2020 22:36
Liftosaur Documentation

Documentation

Workouts

You can clone existing workouts and edit cloned ones, or create your own workouts from scratch.

A workout consists of days. Each day consists of excercises. Each excercise consists of sets. Each set consists of:

  • number of reps
@astashov
astashov / k8s.yaml
Last active January 14, 2018 22:33
Kubernetes mounted host dir
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: app-deployment
spec:
replicas: 1
template:
metadata:
labels:
app: app
@astashov
astashov / redstone_logger_example.dart
Created October 3, 2015 02:16
Redstone logger, which has unique id per request, to avoid interleaved request logs
Logger get logger => Zone.current[#logger];
Logger _initializeRequestLogger() {
var uid = new Random().nextInt(1000);
var logger = new Logger.detached("app:${uid}");
logger.onRecord.listen(print);
return logger;
}
@app.Route("/foo")
@astashov
astashov / gist:c0510538847f4d48e8eb
Last active August 29, 2015 14:18
Dart isolates benchmarking
// It seems like it takes ~60-100ms to create an isolate and 20-30ms to send messages over a
// cold port on my Macbook Pro. Once ports are warmed up, it works way faster, especially sending
// from the isolate to the main process - 0-1ms. By some reason, sending a message from the main
// process to isolate fluctuates way more - 0-10ms.
import 'dart:isolate';
import 'dart:async';
import 'package:isols/src/logging.dart';
import 'package:logging/logging.dart';
library maybe;
abstract class Maybe<T> {
T get value;
bool get isEmpty;
}
class Nothing extends Maybe {
get value => null;
bool get isEmpty => true;
@astashov
astashov / gist:b90c0888c25272399262
Last active October 13, 2016 16:37
Rebound.js-like spring animation in SCSS/SASS
$solver_timestamp_sec: 0.01;
// Rebound.js-like spring animations in SCSS.
// There is a bunch of functions, which helps generating keyframes for you spring
// animations, if you (like me) really want to avoid doing that in JavaScript.
//
// It only generates values for one spring, with given friction, tension and end value
// (i.e. it doesn't support spring systems)
// Friction and tension are matched to the values used in Origami, so you can use whatever
// your designers put in a Quartz Composer file in "Bouncy Animation" blocks :)
@astashov
astashov / yuras_task.rb
Last active December 17, 2015 21:29
Юрина задачка. Я не делал никаких проверок правильности ввода и схемы, будем считать что они все правильные. По сути, все что делает скриптик - конвертирует массив со схемой во что-то, что знает контекст получше, ну там когда какой тип данных встречается. А потом рекурсивно проходит по input'у и применяет схему.
require 'forwardable'
require 'pp'
# * Schema may be only an array
# * It may not contain an array, only a symbol or a hash
# * The key of a hash is always a symbol and the value is always an array or array inside an array
# * To show that it should iterate through a collection on input, we use array in array
class Schema
include Enumerable
extend Forwardable
@astashov
astashov / css_js_principles.txt
Created September 3, 2011 08:44
General Organizational Principles for CSS and JS in Rails
==== General Organizational Principles for CSS and JS in Rails
=== Framework requirements
1. Modularity
2. Complex components are built from simple, atomic components
3. Cross-browser compatibility
a. Follow W3C standards
b. Keep IE hacks in a separate style file
4. Bulletproof
@astashov
astashov / gist:1012345
Created June 7, 2011 14:20
will_paginate replacement
scope :paginate, lambda { |page, per_page| limit(per_page.to_i).offset((page.to_i - 1) * per_page.to_i) }
FAQ for CSS Framework (http://gist.github.com/113972)
1. How are you using the "classes" var in JavaScript template?
Often, you need to make some manipulations with DOM objects. We almost don't use ids (#blabla) by our Law, only if this is really necessary for improving performance (if this is bottle-neck). But mostly, we use classes. I suggest to avoid using inline classes (because refactoring here is very often, and we often need to change name of classes), but use classes variable instead. E.g. use:
var classes = { some_class: 'b-something_some-class' };
$('.' + classes.some_class).hide();