Skip to content

Instantly share code, notes, and snippets.

@azder
azder / csv.php
Last active April 13, 2017 01:25
array to csv string in php
/**
* @param array[] $data
*
* @return string
*
*/
$csv = function ( array $data )
{
$handle = fopen( 'php://temp', 'r+b' );
@azder
azder / functors.js
Created November 6, 2016 23:15 — forked from rjchatfield/functors.js
Maybe, Either & Try Functors in ES6
//--
//-- FUNCTORS in ES6
//--
//-- BOILER PLATE
let fmap = (f) => (functor) => functor.map(f);
let c2 = (f2, f1) => (x) => f2(f1(x));
let c3 = (f3, f2, f1) => (x) => f3(f2(f1(x)));
const R = require('ramda');
const drinkers = R.compose(
R.map(({name, surname}) => `${name} ${surname} can drink!`),
R.filter(({age}) => 21 < age)
);
const users = [
{
name: 'Kristijan',
@azder
azder / isgen.js
Created September 17, 2016 21:47
isgen
const isgen = (
fn => fn instanceof Object.getPrototypeOf(function*(){}).constructor
);
@azder
azder / .eslintrc
Created September 16, 2016 19:07 — forked from cletusw/.eslintrc
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"defaultParams": false, // enable default function parameters
"forOf": false, // enable for-of loops
"generators": false, // enable generators
"objectLiteralComputedProperties": false, // enable computed object literal property names
@azder
azder / semantic-pedantic.md
Created September 14, 2016 17:18 — forked from jashkenas/semantic-pedantic.md
Why Semantic Versioning Isn't

Spurred by recent events (https://news.ycombinator.com/item?id=8244700), this is a quick set of jotted-down thoughts about the state of "Semantic" Versioning, and why we should be fighting the good fight against it.

For a long time in the history of software, version numbers indicated the relative progress and change in a given piece of software. A major release (1.x.x) was major, a minor release (x.1.x) was minor, and a patch release was just a small patch. You could evaluate a given piece of software by name + version, and get a feeling for how far away version 2.0.1 was from version 2.8.0.

But Semantic Versioning (henceforth, SemVer), as specified at http://semver.org/, changes this to prioritize a mechanistic understanding of a codebase over a human one. Any "breaking" change to the software must be accompanied with a new major version number. It's alright for robots, but bad for us.

SemVer tries to compress a huge amount of information — the nature of the change, the percentage of users that wil

@azder
azder / html2canvas-logo
Created June 21, 2016 13:37
generate png image from html out of the page logo
@azder
azder / ex1-prototype-style.js
Created March 13, 2016 16:30 — forked from getify/ex1-prototype-style.js
OLOO (objects linked to other objects) pattern explored (with comparison to the prototype style of the same code)
function Foo(who) {
this.me = who;
}
Foo.prototype.identify = function() {
return "I am " + this.me;
};
function Bar(who) {
Foo.call(this,"Bar:" + who);
@azder
azder / lisp.c
Created March 13, 2016 11:23 — forked from sanxiyn/lisp.c
Lisp
#include <assert.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
enum type {
NIL,
// for when you need Constructor
const CF = fn => function (...args) {
return fn.apply(this, ...args)
};
const CL = fn => class Klass {
constructor(...args) {
return fn.apply(this, ...args);
}