Skip to content

Instantly share code, notes, and snippets.

View pazaricha's full-sized avatar
😇

Paz Aricha pazaricha

😇
View GitHub Profile
@pazaricha
pazaricha / Map.Helpers
Created September 22, 2020 21:04 — forked from kipcole9/Map.Helpers
Helpers for Elixir Maps: underscore, atomise and stringify map keys
defmodule Map.Helpers do
@moduledoc """
Functions to transform maps
"""
@doc """
Convert map string camelCase keys to underscore_keys
"""
def underscore_keys(nil), do: nil
@pazaricha
pazaricha / cmd.sh
Created December 20, 2018 12:19 — forked from kelvinn/cmd.sh
Example of using Apache Bench (ab) to POST JSON to an API
# 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/
@pazaricha
pazaricha / Usefull postgres queries.sql
Last active August 1, 2019 20:20
Usefull postgres queries
-- 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
@pazaricha
pazaricha / postgres_queries_and_commands.sql
Created January 13, 2018 19:13 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- 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%'
@pazaricha
pazaricha / flight.rb
Last active October 13, 2016 11:51 — forked from royzinn/flight.rb
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
@pazaricha
pazaricha / slug_rack_app.rb
Last active August 29, 2015 14:28 — forked from elado/slug_rack_app.rb
Rails conditional controller
# 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]
<!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">
@pazaricha
pazaricha / SassMeister-input-HTML.html
Created January 20, 2015 22:27
Generated by SassMeister.com.
<!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>
@pazaricha
pazaricha / gist:471aa6f5e875c61702cf
Created December 31, 2014 10:14
Can't sync this to phrase app as it disappear after I pull it back...
he:
date:
abbr_day_names:
- א
- ב
- ג
- ד
- ה
- ו
- ש
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