Skip to content

Instantly share code, notes, and snippets.

View waterlink's full-sized avatar

Alex Fedorov waterlink

View GitHub Profile
@waterlink
waterlink / fetchhead__head.diff
Last active September 29, 2015 19:59
rack reverse proxy diffs
diff --git a/FETCH_HEAD:lib/rack/reverse_proxy.rb b/HEAD:lib/rack_reverse_proxy/middleware.rb
index 46416df..420f35b 100644
--- a/FETCH_HEAD:lib/rack/reverse_proxy.rb
+++ b/HEAD:lib/rack_reverse_proxy/middleware.rb
@@ -1,177 +1,175 @@
-require 'net/http'
-require 'net/https'
+require "net/http"
+require "net/https"
+require "rack-proxy"
require "bundler/inline"
gemfile(true) do
ruby "2.2.3"
source "https://rubygems.org"
gem "contracts", "0.11.0"
end
require "contracts"
require "contracts/version"
@waterlink
waterlink / x.rb
Created September 5, 2015 00:48
contracts issue 176
require "contracts"
class Something
module WithSettings
def self.included(base)
base.class_eval do
include Contracts
Contract Contracts::None => Contracts::ArrayOf[String]
def emails
⇒ GC_DONT_GC=1 bin/test
.
Finished in 0.41 milliseconds
1 examples, 0 failures, 0 errors, 0 pending
ActiveRecord::Model
.new
creates person
doesn't have id
doesn't have any else field
⇒ gdb integration/integration_spec
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
ActiveRecord::Model
.new
creates person
doesn't have id
doesn't have any else field
doesn't care about non-defined fields
.fields
returns fields defined on model
#==
is equal object to object with the same fields
@waterlink
waterlink / valgrind.txt
Created August 30, 2015 23:10
Valgrind output for waterlink/mysql_adapter.cr run
.where(query_hash)
finds multiple records==957== Invalid read of size 8
==957== at 0x4A0FB5: GC_generic_malloc_many (in /home/oleksii/code/github/waterlink/mysql_adapter.cr/integration_spec)
==957== by 0x4AA30E: GC_malloc_atomic (in /home/oleksii/code/github/waterlink/mysql_adapter.cr/integration_spec)
==957== by 0x4A06EC: GC_generic_or_special_malloc (in /home/oleksii/code/github/waterlink/mysql_adapter.cr/integration_spec)
==957== by 0x4A08AA: GC_realloc (in /home/oleksii/code/github/waterlink/mysql_adapter.cr/integration_spec)
==957== by 0x4142E5: __crystal_realloc (in /home/oleksii/code/github/waterlink/mysql_adapter.cr/integration_spec)
==957== by 0x42068E: *Pointer(UInt8)@Pointer(T)#realloc<Pointer(UInt8), Int32>:Pointer(UInt8) (in /home/oleksii/code/github/waterlink/mysql_adapter.cr/integration_spec)
==957== by 0x4199B6: *String::Builder#resize_to_capacity<String::Builder, Int32>:Pointer(UInt8) (in /home/oleksii/code/github/waterlink/mysql_adapter.cr/integration_spec)
==957==
@waterlink
waterlink / attr_t.c
Created August 22, 2015 17:54
Generates attr_t enum for curses
#include <curses.h>
#include <stdio.h>
#define pp(x, d) printf("% 15s = % 10lu # - %s\n", #x, x, #d);
int main() {
pp(A_NORMAL, Normal display (no highlight))
pp(A_STANDOUT, Best highlighting mode of the terminal.)
pp(A_UNDERLINE, Underlining)
pp(A_REVERSE, Reverse video)
# Smelly code
class Example
def do_stuff(something)
return if invalid_thing?(something)
@thing = something
end
private def invalid_thing?(thing)
# determine if thing is valid
end
@waterlink
waterlink / rebase.md
Created July 6, 2015 19:56
Example rebase workflow
# Add remote origin pointing to fork, if it is not added
git remote add origin git@github.com:waterlink/contracts.ruby.git

# Add remote upstream pointing to main repo, if it is not added
git remote add upstream git@github.com:egonSchiele/contracts.ruby.git

# Fetch latest master from upstream
git fetch upstream master