Skip to content

Instantly share code, notes, and snippets.

Fedor Nezhivoi gyzerok

Block or report user

Report or block gyzerok

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gyzerok
gyzerok / elm-make-perf.sh
Last active Aug 14, 2018 — forked from jinjor/elm-make-perf.sh
elm-make one by one
View elm-make-perf.sh
# make sure every time only one file is re-compiled
echo "time\t\tlines\timports\tfile"
for f in `find src -name *.elm`
do
elm-make $f --output=/dev/null > /dev/null
sleep 1
touch $f
a=`wc -l $f | awk '{print $1}'`
View ports-technique-in-elm.md

Only have one outgoing port, and only one incoming port

If you have many ports, they could be all over your project, and therefore hard to manage and easy for forget about. Keep track of all of them by representing your outgoing ports in a union type like..

type JsMsg
    = Download
    | Login Login.Payload
    | Logout
    | Track Tracking.Payload
@gyzerok
gyzerok / QueryBuilder.js
Last active Apr 3, 2018
RxJS MongoDB Query Builder
View QueryBuilder.js
/* @flow */
import { Observable, Disposable, ReplaySubject } from 'rx';
import mongo from 'mongodb';
import { dbUrl } from './config';
import { assign } from 'lodash';
class QueryBuilder {
_db$: Observable;
_selectors: Object;
@gyzerok
gyzerok / cron.md
Created Jan 4, 2018 — forked from evancz/cron.md
Cron job to remind myself to stretch
View cron.md

Type crontab -l to see your cron jobs. Type crontab -e to edit them. You have to use Vim apparently.

Add a line like this:

0,30	*	*	*	*	/Users/YOURNAME/Documents/scripts/stretch.sh

That is on every 0th and 30th minute of the hour. Make sure all the separators in there are tabs!

View fp-ladder.md

Standardized Ladder of Functional Programming

The LambdaConf Ladder of Functional Programming (LOFP) is a standardized progression of different concepts and skills that developers must master on their journey to becoming expert-level functional programmers. LOFP can be used to rank workshops, talks, presentations, books, and courseware, so that aspiring functional programmers have a better understanding of what material is appropriate for them given their current experience.

Novice

Concepts

  • Immutable Data
  • Second-order Functions
View io-ts-reporter.ts
function decode<T>(value: any, type: t.Type<T>): Promise<T> {
const validation = t.validate(value, type);
return validation.fold(
([e, ..._unused]) => {
const actualErr = _.last(e.context);
const errPath = e.context
.map(c => c.key)
.filter(key => key.length)
.join(".");
@gyzerok
gyzerok / base64ArrayBuffer.js
Last active Feb 1, 2017 — forked from jonleighton/base64ArrayBuffer.js
Encode an ArrayBuffer as a base64 string
View base64ArrayBuffer.js
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then
// use window.btoa' step. According to my tests, this appears to be a faster approach:
// http://jsperf.com/encoding-xhr-image-data/5
function base64ArrayBuffer(arrayBuffer) {
var base64 = ''
var encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
var bytes = new Uint8Array(arrayBuffer)
var byteLength = bytes.byteLength
@gyzerok
gyzerok / elm-graphql.md
Last active Nov 28, 2016
Thoughts on implementing GraphQL in Elm
View elm-graphql.md

GraphQL in Elm

Before going down to some problem statement and requirement I'd like to tell you what makes Elm for me a better choice upon JavaScript and why I moving towards adopting it for productions usage.

I can make some changes in my codebase, run elm-make and see all the places where I should do subsequent changes. Statically. Ave compiler and static types!

The goal of this paper is to describe why proposition of using different types for different queries would result in almost the same pitfalls I have in JavaScript with GraphQL.

Requirements

View stylesheet.elm
stylesheet : String -> Html.Html Msg
stylesheet link =
let
tag =
"link"
attrs =
[ Html.Attributes.attribute "rel" "stylesheet"
, Html.Attributes.attribute "property" "stylesheet"
, Html.Attributes.attribute "href" link
View class-methods-to-properties.js
module.exports = function (fileInfo, api) {
const j = api.jscodeshift;
const root = j(fileInfo.source);
return root.find(j.MethodDefinition)
.filter(method => method.value.kind !== 'constructor')
.replaceWith(method => {
const { key, value: { body, params } } = method.value;
return j.classProperty(
You can’t perform that action at this time.