Skip to content

Instantly share code, notes, and snippets.

Avatar
🌌
Loading...

Yuriy Yakovenko djleonskennedy

🌌
Loading...
View GitHub Profile
@djleonskennedy
djleonskennedy / contavatiant-example.hs
Last active Mar 27, 2019
Contravariant Functor how to use it in practice
View contavatiant-example.hs
import Data.Functor.Contravariant
-- newtype Predicate a = Predicate { getPredicate :: a -> Bool }
--instance Contravariant Predicate where
-- contramap f (Predicate p) = Predicate (p . f)
-- | `- First, map the input...
-- `----- then apply the predicate.
fb = Predicate (\x -> x > 20)
View gist:d63498e6571f5709a28cd7b25469049c
I had the same issue but manually triggering configure script
```(cd ./node_modules/react-native/third-party/glog-0.3.4 && ../../scripts/ios-configure-glog.sh)``` resolves it.
Also - If you want to build app for iOS 12 you have to switch path to the active developer directory
```(xcode-select -s /Applications/Xcode-beta.app/Contents/Developer).```
View sync-control.directive.spec.ts
import { Component } from '@angular/core';
import { async, TestBed } from '@angular/core/testing';
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { SyncControlDirective } from './sync-control.directive';
class FormGroupHostComponent {
formGroup = new FormGroup({
ctrl: new FormControl('')
});
View haskell-monad-laws.hs
-- Left identity
-- return x >>= f 'same as' f x
return 3 >>= (\x -> Just (x+100000))
-- Just 100003
(\x -> Just (x+100000)) 3
-- Just 100003
-- Right identity
@djleonskennedy
djleonskennedy / identity-functor-compare.hs
Created Aug 19, 2017
Compare Identity Functor Implementation
View identity-functor-compare.hs
// Typescript
class Identity {
constructor(private x: any) {
}
map(f: Function): any {
this.x = f(this.x);
}
}
const id = new Identity(2);
View regular-and-tail.js
// Recursive:
const factorial = n =>
n < 2
? 1
: n * factorial(n-1);
// Tail-recursive:
@djleonskennedy
djleonskennedy / renderSharePointList.js
Last active Apr 27, 2017
example how to render SharePoint List to App, es5
View renderSharePointList.js
requirejs.config({
paths: {
ramda: '../Scripts/vendor/ramda.min',
jquery: '../Scripts/vendor/jquery-1.12.4.min',
}
});
require(['ramda', 'jquery'], function (R, $) {
$.ajaxSetup({
@djleonskennedy
djleonskennedy / randomColorGenerator.ts
Last active Apr 18, 2017
generates random HEX color
View randomColorGenerator.ts
// TS
const randomColorGenerator = (): string =>
`#${(Math.random().toString(16) + '0000000').slice(2, 8)}`;
// ES6
const randomColorGenerator = () =>
`#${(Math.random().toString(16) + '0000000').slice(2, 8)}`;
// ES5
var randomColorGenerator = function () {
View RxJs-dblclick.js
let clicks$ = Rx.Observable.fromEvent(document.getElementById('button'), 'click');
clicks$
.buffer(clicks$.debounce(250))
.map(list => list.length)
.filter(x => x === 2)
.subscribe(() => {
console.log('doubleclick');
})
@djleonskennedy
djleonskennedy / futurizeP.js
Created Jan 26, 2017
futurizeP get payload with json()
View futurizeP.js
const Task = require('data.task');
const fetch = require('node-fetch');
// futurizeP :: (* -> Promise a b) -> * -> Task a b
const futurizeP = require('futurize').futurizeP(Task);
// fetchJson_ :: Url -> Promise Error Object
const fetchJson_ = url => fetch(url).then(res => res.json());
// fetchJson :: Url -> Task Error Object