Skip to content

Instantly share code, notes, and snippets.


Viktor Lazarev gentoid

View GitHub Profile
View .babelrc
"presets": [
gentoid /
Last active Jul 29, 2018
Human readable time diff
mod time_diff;
use time_diff::TimeDiff;
fn main() {
let td = TimeDiff::new(1234123);
let td2 = TimeDiff::new(1233);
println!("First diff is {}", td);
println!("Second diff is {}", td2);
println!("Sum of that diffs is {}", td + td2);
View 0. Ruby Meta Programming - spells
  • Dynamic Dispatch
  • Dynamic Method
  • Ghost Methods
  • Dynamic Proxies
  • Blank Slate
  • Kernel Method
  • Flattening the Scope (aka Nested Lexical Scopes)
  • Context Probe
  • Class Eval (not really a 'spell' more just a demonstration of its usage)
  • Class Macros
gentoid /
Created Aug 23, 2016 — forked from yang-wei/
Elm Destructuring (or Pattern Matching) cheatsheet

Destructuring(or pattern matching) is a way used to extract data from a data structure(tuple, list, record) that mirros the construction. Compare to other languages, Elm support much less destructuring but let's see what it got !


myTuple = ("A", "B", "C")
myNestedTuple = ("A", "B", "C", ("X", "Y", "Z"))

  (a,b,c) = myTuple
gentoid / ajax_setup.js
Created Jun 20, 2016 — forked from alanhamlett/ajax_setup.js
Sets the X-CSRFToken header for every jQuery ajax non-GET request to make CSRF protection easy. This fixes the example from Django docs here:
View ajax_setup.js
beforeSend: function(xhr, settings) {
if (settings.type == 'POST' || settings.type == 'PUT' || settings.type == 'DELETE') {
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHYAMnK0x4q12K7UqeR7sd6joJN9LgGc1d6XQhg/eOUD viktor@gentoo
gentoid /
Created Oct 15, 2015 — forked from paulirish/
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.


Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
View responsive-font.css
body {
font-size: 5vw;
@media (max-width: 700px) {
body {
font-size: 35px;
@media (min-width: 3000px) {
body {
gentoid /
Created Jun 25, 2015
CoffeeScript + jQuery event handling
# 1. trigger events
$(document).trigger 'flash:message', { level: 'error', message: 'There was an error' }
# 2. catch events in another place
.on 'flash:message', (e, params) =>
if params.level && params.message
@show params.level, params.message # call 'show' method doing something interesting :-)
View app.po
# English translations for Retina package.
# This file is distributed under the same license as the Retina package.
msgid ""
msgstr ""
"Project-Id-Version: Retina 0.33.2-26-g8a4bb2a\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-06-01 16:37+0400\n"