Skip to content

Instantly share code, notes, and snippets.

@aloyr
aloyr / clean_code.md
Created November 19, 2022 05:36 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@aloyr
aloyr / sprints.js
Last active November 12, 2020 16:23
get sprint dates
(function() {
const startDay = new Date('01/04/2021');
let currentDay = new Date(startDay.getTime());
let sprintNo = 1;
while (currentDay.getYear() == startDay.getYear()) {
let endDay = new Date(currentDay.getTime());
endDay.setDate(endDay.getDate() + 11);
console.log(fSprint(sprintNo++), fDate(currentDay), fDate(endDay));
currentDay.setDate(currentDay.getDate() + 14);
@aloyr
aloyr / README.md
Last active February 15, 2020 07:57
Phar template

call with php -dphar.readonly=0 create-phar.php

// Some structure lifted from the official API docs.
// https://developers.google.com/youtube/iframe_api_reference#Loading_a_Video_Player
// 1. Prep elements.
newPlayer = document.createElement('div');
newPlayer.setAttribute('id', 'yttest');
newPlayer.style.filter = 'grayscale(1) brightness(0.5)';
newPlayer.style.transition = '1s';
document.querySelectorAll('.flex-layout-base')[0].appendChild(newPlayer);
@aloyr
aloyr / svg-font-family-fix.js
Created January 31, 2020 23:16
use proper font family inside svgs
(function() {
document.querySelectorAll('svg tspan, svg text').forEach(e => {
var currentFont = e.getAttribute('font-family');
if (!currentFont) {
return;
}
currentFont = currentFont.replace(/'/g, '');
var modes = {
'Thin': 100,
'ExtraLight': 200,

Keybase proof

I hereby claim:

  • I am aloyr on github.
  • I am aloyr (https://keybase.io/aloyr) on keybase.
  • I have a public key ASDc9FmZi-YYLsfTX8hQIsjCz7M_bsKeU4B8KhugBihJXAo

To claim this, I am signing this object:

@aloyr
aloyr / workflow.gdsl
Created July 18, 2017 08:06 — forked from gclayburg/workflow.gdsl
Jenkins workflow plugin groovy code completion support for IntelliJ IDE
/*
Author: Gary Clayburg
This file allows IntelliJ IDEA to perform basic syntax checking and code completion for
Jenkins workflow groovy scripts. https://github.com/jenkinsci/workflow-plugin
These methods are supported
sh
readFile
node
echo
@aloyr
aloyr / SCSS.md
Created July 17, 2017 12:19 — forked from jareware/SCSS.md
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

Font Face

A mixin for writing @font-face rules in SASS.

Usage

Create a font face rule. Embedded OpenType, WOFF2, WOFF, TrueType, and SVG files are automatically sourced.

@include font-face(Samplino, fonts/Samplino);
@aloyr
aloyr / ssh-agent-snippets.sh
Created May 2, 2017 10:34 — forked from alexras/ssh-agent-snippets.sh
Bash snippets to automatically start and stop an ssh-agent process on login and logout
#!/bin/bash
## in .bash_profile
SSHAGENT=`which ssh-agent`
SSHAGENTARGS="-s"
if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then
eval `$SSHAGENT $SSHAGENTARGS`
trap "kill $SSH_AGENT_PID" 0
fi