Skip to content

Instantly share code, notes, and snippets.

View tomekw's full-sized avatar
🥇
🏅

Tomek Wałkuski tomekw

🥇
🏅
View GitHub Profile
@bricker
bricker / promises.md
Last active March 14, 2018 00:33
Promises in Rails callbacks, using after_save and after_commit together.

"Russian-Doll Caching" is great. It embraces the Rails (and Ruby) goal to "make the developer happy". And it does. Not having to worry about cache expiration is superb.

It has its limits, though. If you're trying to avoid any database queries, russian-doll caching will not work for you. If you are trying to represent thousands, or even hundreds, of objects under a single cache fragment, russian-doll caching is not the best option.

We use it whenever it makes sense, but sometimes we just have to bite the bullet and expire a cache fragment manually. When you want to start manually expiring cache on a fairly busy website, you have to start considering race conditions. I recently ran into the following scenario:

class Post < ActiveRecord::Base
  after_save :expire_cache
  
@jmingtan
jmingtan / deps.edn
Created April 14, 2018 03:16
Clojure CLI setup with rebel-readline and cider middleware
{:aliases
{:dev {:extra-deps {com.bhauman/rebel-readline {:mvn/version "0.1.2"}
org.clojure/tools.nrepl {:mvn/version "0.2.12"}
cider/cider-nrepl {:mvn/version "0.17.0-SNAPSHOT"}}
:main-opts ["-m" "repl"]}}}
@yeyewangwang
yeyewangwang / Freenode IRC.md
Created June 26, 2016 14:01
Freenode Nickserv Commands

Connect

/server chat.freenode.net

Nick

@joakimk
joakimk / README.md
Last active January 1, 2022 23:21
CircleCI elixir build example

This runs a build for a small elixir (phoenix) project in about 40 seconds by caching as much of the compiled files as possible.

We've been using this for months in multiple projects without any issues. Please ping be if there is any issues with this script and I'll update it.

It should be generic enough to work on any elixir app using mix.

If you have a elixir_buildpack.config, then enable that section in the build script to keep versions in sync!

2016-08-09: Updated to newer Erlang and Elixir and fixed curl command.

@favila
favila / safe-merge.clj
Created February 28, 2020 22:11
merge, but throws on conflicts
(defn safe-merge
"Like merge, but throws if maps have the same keys but different values."
[& maps]
(reduce
(fn [m [m2k m2v :as re]]
(if-some [[_ mv :as le] (find m m2k)]
(if (= mv m2v)
m
(throw (ex-info "Attempted to safe-merge maps with conflicting entries"
@holyjak
holyjak / http-server.bb
Last active March 19, 2023 04:36
Babashka HTTP server for serving static files, similar to `python -m http.server` but more flexible :)
#!/usr/bin/env bb
#_" -*- mode: clojure; -*-"
;; Based on https://github.com/babashka/babashka/blob/master/examples/image_viewer.clj
(ns http-server
(:require [babashka.fs :as fs]
[clojure.java.browse :as browse]
[clojure.string :as str]
[clojure.tools.cli :refer [parse-opts]]
[org.httpkit.server :as server]
@pnc
pnc / observer.md
Last active September 9, 2023 23:32
Using Erlang observer/appmon remotely

Using OTP's observer (appmon replacement) remotely

$ ssh remote-host "epmd -names"
epmd: up and running on port 4369 with data:
name some_node at port 58769

Note the running on port for epmd itself and the port of the node you're interested in debugging. Reconnect to the remote host with these ports forwarded:

$ ssh -L 4369:localhost:4369 -L 58769:localhost:58769 remote-host
@Mel34
Mel34 / config
Created April 21, 2019 10:40
Sway config
# Default config for sway
#
# Copy this to ~/.config/sway/config and edit it to your liking.
#
# Read `man 5 sway` for a complete reference.
### Variables
#
# Logo key. Use Mod1 for Alt.
set $mod Mod4
@alanpeabody
alanpeabody / my_app.ex
Last active March 24, 2024 13:28
Websockets in Elixir with Cowboy and Plug
defmodule MyApp do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
Plug.Adapters.Cowboy.child_spec(:http, MyApp.Router, [], [
dispatch: dispatch
])

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style