Skip to content

Instantly share code, notes, and snippets.

View diegogub's full-sized avatar
👽

Diego Guraieb diegogub

👽
View GitHub Profile
@krisleech
krisleech / 00-NOTES.md
Last active May 26, 2024 21:12
Notes on Clojure ring handlers and middleware

Ring handler a function which accepts a request (map) and returns a response (map).

Ring middleware

function (handler, &args -> function(request -> response) because it is a closure handler and &args are in scope within the returned handler function.

a function which accepts a "next handler" (the next handler in the chain) + any extra arguments and returns a handler (function), which will accept a request and return a response.

@hnakamur
hnakamur / memo.md
Last active May 27, 2019 10:46
badger, goleveldb, boltdb benchmark
hnakamur@express:~/go/src/github.com/zchee/go-benchmarks/db$ go test -count=10 -run='^$' -bench=. -benchmem
goos: linux
goarch: amd64
pkg: github.com/zchee/go-benchmarks/db
BenchmarkGetBadger-2             5000000               399 ns/op          22.50 MB/s          40 B/op          2 allocs/op
BenchmarkGetBadger-2             5000000               390 ns/op          23.04 MB/s          40 B/op          2 allocs/op
BenchmarkGetBadger-2             5000000               390 ns/op          23.03 MB/s          40 B/op          2 allocs/op
BenchmarkGetBadger-2             5000000               391 ns/op          22.97 MB/s          40 B/op          2 allocs/op
BenchmarkGetBadger-2             5000000               391 ns/op          22.96 MB/s          40 B/op          2 allocs/op
@SKempin
SKempin / Git Subtree basics.md
Last active May 9, 2025 19:37
Git Subtree basics

Git Subtree Basics

If you hate git submodule, then you may want to give git subtree a try.

Background

When you want to use a subtree, you add the subtree to an existing repository where the subtree is a reference to another repository url and branch/tag. This add command adds all the code and files into the main repository locally; it's not just a reference to a remote repo.

When you stage and commit files for the main repo, it will add all of the remote files in the same operation. The subtree checkout will pull all the files in one pass, so there is no need to try and connect to another repo to get the portion of subtree files, because they were already included in the main repo.

Adding a subtree

Let's say you already have a git repository with at least one commit. You can add another repository into this respository like this:

@bcardiff
bcardiff / list-deps.cr
Last active May 29, 2024 17:37
List binary dependencies to build a minimal docker image from scratch
unless ARGV.size > 0
puts " Missing executable file argument"
puts " Usage (in a Dockerfile)"
puts " RUN crystal run ./path/to/list-deps.cr -- ./bin/executable"
exit 1
end
executable = File.expand_path(ARGV[0])
unless File.exists?(executable)
@cszentkiralyi
cszentkiralyi / vim-sexp-cheatsheet.md
Last active March 19, 2025 10:44
vim-sexp cheatsheet

Prereqs

These are for the combined vim-sexp (https://github.com/guns/vim-sexp) and vim-sexp-mappings-for-regular-people (https://github.com/tpope/vim-sexp-mappings-for-regular-people) plugins. vim-sexp is neat on its own but Tim Pope makes common stuff much easier.

Note that some vim-sexp functionality depends on <LocalLeader> mappings. This is a different leader key than the global leader, and is the variable maplocalleader (instead of mapleader). To see if you have this set, use :echo maplocalleader; if it errors out you'll need to set it, otherwise it will echo the key. If you want to set your LocalLeader to <Space>, you'll need two commands in your .vimrc, since by default <Space> is bound to <Right> in normal mode:

nnoremap <Space> <Nop>
let maplocalleader=" "

TOC

@ianblenke
ianblenke / rethinkdb.cloud-init
Created March 13, 2015 21:59
Rethink-DB CoreOS cloud-init
#cloud-config
coreos:
units:
- name: rethinkdb-create-fleet-units.service
command: start
content: |
[Unit]
After=docker.service
ConditionFileIsExecutable=/srv/rethinkdb-create-fleet-units.sh
ConditionFileNotEmpty=/srv/[email protected]
@rain1024
rain1024 / tut.md
Last active April 30, 2025 08:37
Install pdflatex ubuntu

PdfLatex is a tool that converts Latex sources into PDF. This is specifically very important for researchers, as they use it to publish their findings. It could be installed very easily using Linux terminal, though this seems an annoying task on Windows. Installation commands are given below.

  • Install the TexLive base
sudo apt-get install texlive-latex-base
  • Also install the recommended and extra fonts to avoid running into the error [1], when trying to use pdflatex on latex files with more fonts.
@crosbymichael
crosbymichael / mesos-ubuntu-install.sh
Created July 9, 2014 18:43
Install mesos on ubuntu 14.04
#!/bin/bash
set -e
apt-get install -y curl python-setuptools python-pip python-dev python-protobuf
# zookeeper
apt-get install -y zookeeperd
echo 1 | dd of=/var/lib/zookeeper/myid
@perusio
perusio / gist:1326701
Created October 31, 2011 01:28
Mobile device detection in Nginx with just 7 lines of configuration
### Testing if the client is a mobile or a desktop.
### The selection is based on the usual UA strings for desktop browsers.
## Testing a user agent using a method that reverts the logic of the
## UA detection. Inspired by notnotmobile.appspot.com.
map $http_user_agent $is_desktop {
default 0;
~*linux.*android|windows\s+(?:ce|phone) 0; # exceptions to the rule
~*spider|crawl|slurp|bot 1; # bots
~*windows|linux|os\s+x\s*[\d\._]+|solaris|bsd 1; # OSes