Skip to content

Instantly share code, notes, and snippets.

View AZaviruha's full-sized avatar

Alexei Zaviruha AZaviruha

  • Nikolaev, Ukraine
View GitHub Profile
function Maybe ( val ) {
this.__val = val;
this.__error = this.isError();
this.__defaultVal = null;
}
Maybe.prototype.isError = function () {
var val = this.__val;
return (null === val)
|| (undefined === val)
@AZaviruha
AZaviruha / Mocha_JSCheck.js
Last active November 17, 2016 15:06
Simple helper to use JSCheck generated tests inside Mocha test runner
var isArray = require( '../../src/checkers/isArray' ) // my function to test
, JSC = require( 'jscheck' )
, _ = require( 'lodash' )
, $ = require( 'jquery' )
, chai = require( 'chai' )
, expect = chai.expect;
function JSC_it ( name, predicate, signature ) {
it( name, function ( done ) {
JSC.claim( name, function ( verdict ) {
13:15 <xQuasar> | HASKELL IS FOR FUCKIN FAGGOTS. YOU'RE ALL A BUNCH OF
| FUCKIN PUSSIES
13:15 <xQuasar> | JAVASCRIPT FOR LIFE FAGS
13:16 <luite> | hello
13:16 <ChongLi> | somebody has a mental illness!
13:16 <merijn> | Wow...I suddenly see the error of my ways and feel
| compelled to write Node.js!
13:16 <genisage> | hi
13:16 <luite> | you might be pleased to learn that you can compile
| haskell to javascript now
@AZaviruha
AZaviruha / core.cljs
Last active August 29, 2015 14:21 — forked from swannodette/core.cljs
(ns typed-play.core
(:require-macros [cljs.core.typed :as t])
(:require [cljs.core.typed :as t]))
(t/ann my-identity (All [x] (Fn [x -> x])))
(defn my-identity [x]
(if (number? x)
(inc x)
x))
@AZaviruha
AZaviruha / localstorage.cljs
Last active August 29, 2015 14:25 — forked from daveliepmann/localstorage.cljs
HTML5 localStorage utility functions for ClojureScript. I find it makes for cleaner code when I wrap the native JS.
(ns localstorage)
(defn set-item!
"Set `key' in browser's localStorage to `val`."
[key val]
(.setItem (.-localStorage js/window) key val))
(defn get-item
"Returns value of `key' from browser's localStorage."
[key]
@AZaviruha
AZaviruha / nginxproxy.md
Last active August 29, 2015 14:25 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@AZaviruha
AZaviruha / hkt.rs
Last active January 4, 2018 22:16 — forked from 14427/hkt.rs
Higher-kinded type trait
use std::rc::Rc;
trait HKT<U> {
type C; // Current type
type T; // Type with C swapped with U
}
macro_rules! derive_hkt {
($t:ident) => {
impl<T, U> HKT<U> for $t<T> {
@AZaviruha
AZaviruha / gulpfile.js
Last active August 29, 2015 14:25 — forked from danharper/gulpfile.js
New ES6 project with Babel, Browserify & Gulp
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var watchify = require('watchify');
var babel = require('babelify');
function compile(watch) {
var bundler = watchify(browserify('./src/index.js', { debug: true }).transform(babel));
@AZaviruha
AZaviruha / code-1.txt
Last active August 29, 2015 14:25 — forked from bennadel/code-1.txt
Treating Complex User Interface (UI) Widgets Like Finite State Machines
function gotoState( newState ){ .. }
@AZaviruha
AZaviruha / _reader-macros.md
Created October 19, 2015 07:34 — forked from chaitanyagupta/_reader-macros.md
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.