Skip to content

Instantly share code, notes, and snippets.

🏠
huh

Łukasz Korecki lukaszkorecki

🏠
huh
Block or report user

Report or block lukaszkorecki

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 rec.clj
user=> (defrecord Foo [foo bar])
user.Foo
user=> (def f (->Foo :foo :bar))
#'user/f
user=> (defrecord Qux [foo bar baz])
user.Qux
user=> (def q (map->Qux (select-keys f [:foo :bar])))
#'user/q
user=> (clojure.pprint/pprint q)
{:foo :foo, :bar :bar, :baz nil}
View sigh.rb
class SomeDataThing < OpenStruct
include ActiveModel::Validations
validates :name, presence: true
validates :email, presence: true
end
SomeDataThing.new(name: "I'm tired").valid? # => false
@lukaszkorecki
lukaszkorecki / .circle.yml
Last active Aug 10, 2019
How to setup code coverage for Clojure + Cloverage + CircleCI + CodeClimate
View .circle.yml
version: 2
jobs:
build:
docker:
- image: circleci/clojure:lein-2.7.1
environment:
- CC_TEST_REPORTER_ID=....set in project settings....
steps:
View app-project.clj
(defproject some-app "0.1.0"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:repositories [["bintray"
{:url "https://fruit.bintray.com/bananas"
:snapshots true
:username :env/bintray_username
:password :env/bintray_api_key}]]
View lib-project.clj
(defproject some-lib "0.1.0"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:deploy-repositories [["releases"
{:url
"https://api.bintray.com/maven/fruit/bananas/some-lib/;publish=1"
:sign-releases false
:username :env/bintray_username
:password :env/bintray_api_key}]
["snapshots"
@lukaszkorecki
lukaszkorecki / receiver.clj
Created Jun 6, 2017 — forked from stingh711/receiver.clj
A simple UDP server in clojure
View receiver.clj
(import '(java.net DatagramSocket DatagramPacket))
(def socket (DatagramSocket. 5200))
(def running (atom true))
(def buffer (make-array Byte/TYPE 1024))
(defn parse [packet]
(println (String. (.getData packet) 0 (.getLength packet))))
(defn start-receiver []
View aleph.proxy.clj
(require '[aleph.http :as http])
(require '[ring.middleware.cookies :as cookies])
;; serv is a component which wraps aleph.http.server creation/teardown
(def ECHO (component/start (serv/create "ECHO" {:port 3037
:handler (fn [req]
(log/info req)
{:status 200 :body "ok" })})))
@lukaszkorecki
lukaszkorecki / socks.sh
Last active Apr 30, 2017
Fast and easy socks proxy setup on OSX: enables proxy, starts the proxy connection and cleans up after itself when its done
View socks.sh
#!/usr/bin/env bash
# Enable SOCKS tunnel for given interface, ssh to a remote machine
# and open a SOCKS proxy.
# When cancelled it will disable proxy settings for given interface
# Start with sudo socks.sh if you want it to modify all settings for you
# or just run socks.sh to be prompted on all settings changes
user= # ssh user
host= # ssh host
View woah.sh
jq -r '(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @csv' team.json > foo.csv
View temp-files.clj
(defn create-tmp-file
"Create tmp file. Return path to the file!
Note file is deleted when JVM terminates"
[prefix suffix]
(let [file (File/createTempFile prefix suffix)]
(.deleteOnExit file)
(.getPath file)))
(defn create-tmp-directory
You can’t perform that action at this time.