Skip to content

Instantly share code, notes, and snippets.

@morhekil
morhekil / nginx.conf
Created August 14, 2014 12:18
Full request/response body logging in nginx
http {
log_format bodylog '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time '
'<"$request_body" >"$resp_body"';
lua_need_request_body on;
set $resp_body "";
body_filter_by_lua '
@morhekil
morhekil / guerrilla_fetch.md
Created November 2, 2014 05:32
How to fetch, download and save locally Guerrilla Mail inbox

Guerrilla Mail keeps all incoming emails for only an hour, so if you can't check in on your inbox for a while - the emails will be lost. A way around would be, of course, to periodically fetch and store emails locally.

There's a python client that automates low level operations for GM (list emails, get an email), so it's easy to add another command to it to combine list and get commands together, to get all emails and save them into files.

Here is a patch that adds the command, using it is easy:

$ mkdir inbox
$ while true; do python guerrillamail.py getall inbox && sleep 60; done
@morhekil
morhekil / config
Created March 15, 2022 10:36 — forked from ltk/config
Split Test Load Balancer Nginx Configuration
map $split_test_cookie_name $split_test_cookie {
default $cookie_split_test_version;
}
upstream app.com {
server old.app.com;
}
split_clients "app${remote_addr}${http_user_agent}${date_gmt}" $upstream_variant {
10% "test";
@morhekil
morhekil / anonsplat.rb
Created June 23, 2015 23:20
Destructuring Ruby hashes with named parameters and anonymous splat
def stuff
yield action: 'Boom', schedule: '7PM', color: :red, debug: true
end
# When a hash is yielded to a block, we can used named arguments to
# capture the keys we want, and an anonymous splat to ignore
# everything else
stuff { |action:, schedule:, **| p "Doing #{action} at #{schedule}" }
#
@morhekil
morhekil / rsync-incremental-backup.sh
Last active June 26, 2020 16:18
Shell script to handle incremental data backups with rsync. Optimised to handle large number of infrequently changing files, by using hard links to save on used disk space. For more details - http://localhost:4000/2014/01/12/automatic-backups-with-ruby-and-linux-shell-part-3/
#!/bin/bash
# Rsync based file backup script, with hard-linking enabled.
#
# Runtime options:
# -n - dry-run; do nothing, just display what is going to happen on a real run
# -v - verbose output; print out what is being backed up
#
# set to your rsync location

Validate JSON schema in Rails

Topics

  1. What/Why JSON schema
  2. Apply to rails model validation
  3. Test your API endpoint with schema matcher
  4. Homework for a curious reader
  5. References

Node.js Workshop

Prework:

  • Install node
  • Download repo and get it running
  • Sign up for trial account for lambda service

Day 1

# Some default enhancements/settings for IRB, based on
# http://wiki.rubygarden.org/Ruby/page/show/Irb/TipsAndTricks
require 'irb'
unless defined? ETC_IRBRC_LOADED
# Require RubyGems by default.
require 'rubygems'
# Activate auto-completion.
@morhekil
morhekil / ios-how-to-communicate-with-iframes.md
Last active January 24, 2018 14:58 — forked from wayne5540/ios-how-to-communicate-with-iframes.md
This article is to show how to inject JavaScript into iframs under iOS web view and so we can communicate with it.

[iOS - Swift] How to communicate with iFrames inside WebView

One of the core technologies at the heart of Onefill is its ability to auto-fill even the most complex form on a website with 100% precision, with a single tap. And the techology that built does allow us to do just that, but with one exception - iframes.

And while you might think that iframes are a thing of the past (who would use them these days, right?) - the reality is that they're often powering some of the most critical piece of functionality there is on online store - its payment

@morhekil
morhekil / case.js
Created August 29, 2017 14:37
mobx computed behaviour test case
import { whyRun, observable, computed } from 'mobx';
class Store {
@observable value = false;
@computed get notValue() {
whyRun();
return !this.value;
}
}