Skip to content

Instantly share code, notes, and snippets.

⛵️
(loop [] (recur))

Honza Břečka honzabrecka

⛵️
(loop [] (recur))
Block or report user

Report or block honzabrecka

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
View repl.js
// require without cache
const __r = (m) => { delete require.cache[require.resolve(m)]; return require(m) }
const reload = () = {
Object.keys(require.cache).forEach((module) => {
delete require.cache[module]
require(module)
})
}
View withLogger.js
const withLogger = (reducer) => (state, action) => {
const boldStyle = 'font-weight:bold';
console.groupCollapsed(`%caction %c${action.type}`, 'color:#CCC', boldStyle);
console.log('%cprev state', `${boldStyle};color:#9E9E9E`, state);
console.log('%caction ', `${boldStyle};color:#03A9F4`, action);
const after = reducer(state, action);
console.log('%cnext state', `${boldStyle};color:#4CAF50`, after);
console.groupEnd();
return after;
};
View wrapComponent.js
// @flow
import * as React from 'react';
import classNames from 'classnames';
// import type { ClassNames } from 'classnames';
type ClassNames = any;
export type ClassNamesOrFunction = ClassNames | ((props: any) => ClassNames);
View console.log.cypress.js
beforeEach(() => {
cy.window().then((win) => {
cy.spy(win.console, "error");
cy.spy(win.console, "warn");
});
});
afterEach( () => {
cy.window().then((win) => {
expect(win.console.error).to.have.callCount(0);
View dedup.py
import hashlib
import os
from os.path import exists, isfile, join, basename
import shutil
def md5(file):
hash_md5 = hashlib.md5()
with open(file, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
@honzabrecka
honzabrecka / AoC2018-day-01.clj
Last active Dec 2, 2018 — forked from kepi74/AoC2018-day-01.clj
Advent of Code 2018 day 01
View AoC2018-day-01.clj
(defn get-final-freq
"Day one: calculate resulting frequency"
[freq_list]
; 1. clojurist prefer to use `-` instead of `_` in names
; 2. I'm not sure how you got and what's inside `freq_list` (I suppose integers, then it's fine)
(reduce + freq_list))
(defn repeated-freq
"Day one: first occur of repeated frequency"
[freq_list]
View p-map.cljs
(defn p-pmap
[max f result xs]
(p/then (->> xs (take max) (map f) p/all)
(fn [resolved]
(let [result (concat result resolved)]
(if (>= (count xs) max)
(p-pmap max f result (drop max xs))
result)))))
View Dockerfile
FROM ruby:2.5
WORKDIR /usr/src/app
EXPOSE 4000
COPY Gemfile ./
RUN gem install jekyll rouge
RUN bundle install
View fetch.js
/* eslint-env browser */
import fetch from 'isomorphic-fetch'
import { composableFetch, pipeP, tryCatchP } from 'composable-fetch'
export const handleFetchError = async (error) => {
const { res } = error
const genericError = new Error('Fetch error')
genericError.res = res
genericError.data = { success: false, message: 'An error occured.' }
View Layout.js
import page from '../pages/page'
const config = {
env: {
NODE_ENV: 'production',
},
publicPathDist: '',
}
const initialState = { auth: { loggedIn: false } }
You can’t perform that action at this time.