Skip to content

Instantly share code, notes, and snippets.

@pdkovacs
pdkovacs / init.el
Created July 29, 2017 15:55
Custom emacs settings
(add-to-list 'default-frame-alist '(fullscreen . maximized))
(setq mac-command-modifier 'control)
@pdkovacs
pdkovacs / profile.boot
Created August 20, 2017 11:20
Global clojure boot profile
(deftask cider "CIDER profile"
[]
(require 'boot.repl)
(swap! @(resolve 'boot.repl/*default-dependencies*)
concat '[[org.clojure/tools.nrepl "0.2.13"]
[cider/cider-nrepl "0.15.0"]
[refactor-nrepl "2.3.1"]])
(swap! @(resolve 'boot.repl/*default-middleware*)
concat '[cider.nrepl/cider-middleware
refactor-nrepl.middleware/wrap-refactor])
@pdkovacs
pdkovacs / profiles.clj
Created August 20, 2017 11:22
Global (clojure) leiningen profile
{:repositories [["java.net" "http://download.java.net/maven/2"]
["sonatype" {:url "http://oss.sonatype.org/content/repositories/releases"
;; If a repository contains releases only setting
;; :snapshots to false will speed up dependencies.
:snapshots false
;; Disable signing releases deployed to this repo.
;; (Not recommended.)
:sign-releases false
;; You can also set the policies for how to handle
;; :checksum failures to :fail, :warn, or :ignore.
@pdkovacs
pdkovacs / explore.asynch.batch.clj
Last active August 20, 2017 16:15
Exploring the first example in "Core.Async in Use - Timothy Baldridge / Clojure West 2017"
(ns org.bitkitchen.explore.async.batch
(:require [clojure.core.async
:as a
:refer [>! <! >!! <!! go chan close! pipeline]]))
;;;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;;; TEST TARGETS
;;; Core.Async in Use - Timothy Baldridge / Clojure West 2017
;;;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@pdkovacs
pdkovacs / exercise-web-crawler.go
Last active September 8, 2018 18:46
A Tour of Go: exercise-web-crawler.go
package main
import (
"fmt"
"sync"
"time"
)
type Fetcher interface {
// Fetch returns the body of URL and
@pdkovacs
pdkovacs / git-branch-prompt.sh
Last active February 3, 2019 14:46
git-branch-prompt
git_branch_ps() {
git_branch=$(git branch 2>/dev/null | grep "^*" | colrm 1 2)
if [ -n "$git_branch" ];
then
echo " ($git_branch)"
fi
}
export PS1='\u@\w$(git_branch_ps) $ '
@pdkovacs
pdkovacs / contentBoundingBox.js
Created October 25, 2019 15:37
Calculate bounding box for content on an HTML5 Canvas
const contextBoundingBox = (ctx: CanvasRenderingContext2D, alphaThreshold: number) => {
const effectiveAlphaThrh = alphaThreshold || 15;
const w = ctx.canvas.width;
const h = ctx.canvas.height;
const data = ctx.getImageData(0, 0, w, h).data;
let x: number;
let y: number;
let minX: number;
let minY: number;
let maxX: number;
@pdkovacs
pdkovacs / gist:a1c8268e2e9db3433ef3b20b15a7ab6b
Created January 24, 2020 22:42
"A component is changing a controlled input of type undefined to be uncontrolled"
React seems to monitor the `value` attributes that is being set to <input> elements and if it finds that the `value` is set to `undefined` emits the above warning. There are cases where figuring out what is happening may be tricky. But knowing that you have to look for `undefined` being set to `values` will help you a lot figure out how to have this warning go away. (An example of such a non-trivial situation is that you display the properties of an object in separate input elements. When the user starts setting the first property of the object, the other properties are still undefined, but a simple state management logic -- and you'll want to keep the state management logic simple, I bet -- will try to set all the input tags representing the properties of the object.)
The closest to give a clue I've found by Googling was this issue. Unfortunately, it uses the word "empty" instead of the `undefined` keyword.
@pdkovacs
pdkovacs / apacheds.bat
Last active April 14, 2020 11:01
Windows starter script for Apache Directory Service with fixed command line settings
@ECHO off
REM Licensed to the Apache Software Foundation (ASF) under one
REM or more contributor license agreements. See the NOTICE file
REM distributed with this work for additional information
REM regarding copyright ownership. The ASF licenses this file
REM to you under the Apache License, Version 2.0 (the
REM "License"); you may not use this file except in compliance
REM with the License. You may obtain a copy of the License at
REM
REM http://www.apache.org/licenses/LICENSE-2.0
@pdkovacs
pdkovacs / explain-try-catch-finally.go
Last active May 28, 2021 08:49
Try-catch-finally in so many words
package main
import (
"errors"
"fmt"
)
func foo() (string, error) {
doErr := false
beOpportunist := false