Skip to content

Instantly share code, notes, and snippets.

View s-melnikov's full-sized avatar

Sehii Melnykov s-melnikov

View GitHub Profile
@s-melnikov
s-melnikov / easings.css
Created July 30, 2020 13:39 — forked from argyleink/easings.css
Handy CSS properties for easing functions
:root {
--ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53);
--ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19);
--ease-in-quart: cubic-bezier(0.895, 0.03, 0.685, 0.22);
--ease-in-quint: cubic-bezier(0.755, 0.05, 0.855, 0.06);
--ease-in-expo: cubic-bezier(0.95, 0.05, 0.795, 0.035);
--ease-in-circ: cubic-bezier(0.6, 0.04, 0.98, 0.335);
--ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);
--ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);
--ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);
let seed = Date.now();
function randomA() {
seed = (5 * seed + 3) % 16;
return seed / 16;
}
function randomB() {
seed = (seed * 7919 + 1) & 0xffff;
// upper range is 0xffff (65535) so bring it down to 0-1
#include <iostream>
#include <SDL.h>
#undef main
struct Point {
int x;
int y;
};
SDL_Window *window;
@s-melnikov
s-melnikov / gcd.cpp
Created March 21, 2019 19:51
Greatest common divider
#include <iostream>
using namespace std;
int gcd(int a, int b) {
while (a != b) {
if (a > b) {
a = a - b;
} else {
b = b - a;
}
text
.replace(/\n{3,}/, '\n\n')
.replace(/\n+$/, '\n\n')
.replace(/(#+)(.+?)\n/gm, (p, h, m) => `\n<h${h.length}>${m.trim()}</h${h.length}>\n`)
.replace(/^([^\n<][\S\s]+?)\n\n/gm, (p, m) => `<p>${m.trim()}</p>\n\n`)
.replace(/\*\*([\S ]+?)\*\*|__([\S ]+?)__/g, (p, m1, m2) => `<b>${m1||m2}</b>`)
.replace(/\*([\S ]+?)\*|_([\S ]+?)_/g, (p, m1, m2) => `<em>${m1||m2}</em>`)
@s-melnikov
s-melnikov / sublime-config.json
Last active January 30, 2019 18:47
Sublime Text config
{
"font_size": 10,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"indent_to_bracket": true,
"trim_trailing_white_space_on_save": true,
"ensure_newline_at_eof_on_save": true,
"save_on_focus_lost": true,
"copy_with_empty_selection": false,
"drag_text": false,
@s-melnikov
s-melnikov / functional_hell.js
Created December 26, 2018 16:55
Functional way.
const compose = (...fns) => arg => fns.reduce((composed, f) => f(composed), arg)
const oneSecond = () => 1000
const getCurrentTime = () => new Date()
const clear = () => console.clear()
const log = message => console.log(message)
const serializeClockTime = date => ({
hours: date.getHours(),
minutes: date.getMinutes(),
P = (pow(e + 2.5) + 7.1 * pow(h, 3)) / (log(sqrt(y + 0.04 * h)));
function h(type, props, ...children) {
props = props != null ? props : {};
return { type, props, children };
}
function render(vdom, parent = null) {
if (parent) parent.textContent = "";
const mount = parent ? (el => parent.appendChild(el)) : (el => el);
if (typeof vdom == "string" || typeof vdom == "number") {
return mount(document.createTextNode(vdom));
@s-melnikov
s-melnikov / easing.js
Created April 12, 2018 06:47 — forked from gre/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity