Skip to content

Instantly share code, notes, and snippets.

View hexode's full-sized avatar

Alexander Verkhoglyad hexode

  • Toloka
  • Belgrade
  • 08:56 (UTC +02:00)
View GitHub Profile
@hexode
hexode / bezier.js
Created May 10, 2016 18:40 — forked from mckamey/bezier.js
JavaScript port of Webkit CSS cubic-bezier(p1x.p1y,p2x,p2y) and various approximations
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
@hexode
hexode / d3.sandbox.js
Last active March 17, 2016 09:34
d3 sandbox
var Person = function(name, age) {
if (!(this instanceof Person)) return new Person(name, age);
return { name, age };
}
var data = [
Person('John', 29),
Person('Helen', 18),
Person('Tom', 59)
@hexode
hexode / interpolate.less
Last active December 23, 2015 09:19
{Inter,Extra}polating css property
/*
linear extrapolate(interpolate) property based on viewport units
@example:
// extrapolating
.example {
.linear(height, 320px, 100px, 480px, 128px);
}
result:
.example {
height: calc(17.5vw + 44px);
@hexode
hexode / coin-exchange-recursive.clj
Created October 29, 2015 13:08
Coin exchange problem - recursive solution
(defn coin-exchange [amount, coins]
(cond (= amount 0) 1
(< amount 0) 0
(empty? coins) 0
(= (count coins) 1) (if (= (rem amount (first coins)) 0) 1 0)
:else (let [[coin & remaining-coins] coins]
(+ (coin-exchange (- amount coin) coins)
(coin-exchange amount remaining-coins)))))
(defn calc-spiral-coord [index]
(defn iterate [cell direction-index index steps increase-steps]
(defn add-vectors [a b]
[(+ (first a) (first b)) (+ (second a) (second b))])
(defn get-direction [i] (nth [[1 0] [0 1] [-1 0] [0 -1]] (mod i 4)))
(defn walk [cell direction steps]
(if (= steps 0)
cell
#
# This is the main Apache server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.2/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive.
#
#
# Do NOT simply read the instructions in here without understanding
@hexode
hexode / index.js
Created March 3, 2015 19:06
requirebin sketch
var no = require('nommon');
var promise = new no.Promise();
promise
.then(function() {
console.log(10);
})
.then(function() {
console.log(10);
});
@hexode
hexode / fsm.js
Last active October 19, 2016 11:07
Simple fsm
var fsm = (function() {
function transition(name, from, to) {
this.transitions[name] = {name: name, from: from, to: to};
return this;
}
function init(state) {
this.initState = state;
return this;
}
@hexode
hexode / chart-gen.js
Last active August 29, 2015 14:13
D3 chart generator
/**
* Create d3 chart generator
*
* @param {Function} render function with parameters vis(d3 selection), width, height, and config context
*
* @returns {Function} chart
*/
var createChartGenerator = function(render) {
var chart;
var config = {
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
#canvas {
width: 500x;
height: 300px;
}