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 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 } }
View pbt.hs
data Presentation = Presentation
{ prev :: [Int]
, current :: Int
, next :: [Int]
} deriving (Show)
instance Arbitrary Presentation where
arbitrary = arbitraryPresentation
View roman.js
const template = (i, v, x) => ({
0: '',
1: `${i}`,
2: `${i}${i}`,
3: `${i}${i}${i}`,
4: `${i}${v}`,
5: `${v}`,
6: `${v}${i}`,
7: `${v}${i}${i}`,
8: `${v}${i}${i}${i}`,
View advent-of-code-2017-1.cljs
(defn shift
[[h & t]]
(concat t [h]))
(defn apply-times
[f n v]
(if (= n 0)
v
(recur f (dec n) (f v))))
View foo.js
const effects = {}
const coeffects = {}
const actions = {}
const state = {}
function registerEffect(id, f) {
effects[id] = f
}
function registerCoeffect(id, f) {
You can’t perform that action at this time.