This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Map.Helpers do | |
@moduledoc """ | |
Functions to transform maps | |
""" | |
@doc """ | |
Convert map string camelCase keys to underscore_keys | |
""" | |
def underscore_keys(nil), do: nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# post_loc.txt contains the json you want to post | |
# -p means to POST it | |
# -H adds an Auth header (could be Basic or Token) | |
# -T sets the Content-Type | |
# -c is concurrent clients | |
# -n is the number of requests to run in the test | |
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Get all tables in the db sorted by size. | |
-- Can be usefull in cases you want to do a pg_restore but want to know which tables you can exclude | |
-- and get the most amount of value from in terms of time saved | |
SELECT | |
relname as "Table", | |
pg_size_pretty(pg_total_relation_size(relid)) As "Size", | |
pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid)) as "External Size" | |
FROM pg_catalog.pg_statio_user_tables ORDER BY pg_total_relation_size(relid) DESC; | |
-- Get current postgres version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- show running queries (pre 9.2) | |
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(query_start, clock_timestamp()), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FlightManager | |
def self.search(search_criteria) | |
provider = search_criteria[:provider].camelize | |
flights = "FlightProviders::#{provider}".constantize.search_flights(search_criteria) | |
"FilghtsResponseAdapter::#{provider}".constantize.normazlize(flights) | |
end | |
end | |
## Have one of these for each unique provider/response | |
module FilghtsResponseAdapter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# routes.rb (very bottom route): | |
match '*path' => SlugRackApp | |
# slug_rack_app.rb | |
class SlugRackApp | |
def self.call(env) | |
path = env["action_dispatch.request.path_parameters"][:path] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery.min.js"></script> | |
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> | |
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script> | |
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script> | |
<script src="//code.jquery.com/jquery-1.9.1.min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<header> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
he: | |
date: | |
abbr_day_names: | |
- א | |
- ב | |
- ג | |
- ד | |
- ה | |
- ו | |
- ש |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2014-09-10T14:33:07.936647+00:00 app[web.2]: ** [NewRelic][09/10/14 14:33:07 +0000 796b66b8-1b5d-443c-9fcc-06797dcddc31 (8)] DEBUG : Sampled 1 / 1 (100.0 %) requests this cycle, 1 / 1 (100.0 %) since startup | |
2014-09-10T14:33:08.027552+00:00 app[web.2]: ** [NewRelic][09/10/14 14:33:08 +0000 796b66b8-1b5d-443c-9fcc-06797dcddc31 (8)] DEBUG : No thread profiles with data found to send. | |
2014-09-10T14:33:08.027611+00:00 app[web.2]: ** [NewRelic][09/10/14 14:33:08 +0000 796b66b8-1b5d-443c-9fcc-06797dcddc31 (8)] DEBUG : Closing shared TCP connection to collector-114.newrelic.com:443 | |
2014-09-10T14:33:07.936281+00:00 app[web.2]: ** [NewRelic][09/10/14 14:33:07 +0000 796b66b8-1b5d-443c-9fcc-06797dcddc31 (8)] DEBUG : Uncompressed content returned | |
2014-09-10T14:33:07.980660+00:00 app[web.2]: ** [NewRelic][09/10/14 14:33:07 +0000 796b66b8-1b5d-443c-9fcc-06797dcddc31 (8)] DEBUG : Uncompressed content returned | |
2014-09-10T14:33:08.027050+00:00 app[web.2]: ** [NewRelic][09/10/14 14:33:08 +0000 796b66b8-1b5d-443c-9fcc-06797dcdd |
NewerOlder