Skip to content

Instantly share code, notes, and snippets.

View pedromlcosta's full-sized avatar

Pedro Costa pedromlcosta

View GitHub Profile
defp get_all_results() do
initial_url = "www.somewebsite.com/api/somerequest/someitems?limit=50"
get_results(initial_url)
end
def get_results(nil, accumulated_results \\ []) do
# No next URL, return the accumulated results so far
{:ok, accumulated_results}
end
@pedromlcosta
pedromlcosta / cursor_pagination_streams.ex
Last active May 15, 2020 16:54
Cursor Pagination Calls With Streams in Elixir
defp get_all_results() do
initial_url = "www.somewebsite.com/api/somerequest/someitems?limit=50"
get_results(initial_url)
end
def get_results(initial_url) do
Stream.unfold(initial_url, fn
nil ->
nil
def get_shopify_products_cursor_based(project_id, api_token, store_name) do
base_url = "www.derp.com/some_listing?limit=50"
results =
Stream.unfold(base_url, fn
nil ->
nil
acc ->
response = HTTPoison.get(acc, [], [])
APP="your_app_name"
BUILD_HOST="your_aws_ec2_staging_machine_ip"
BUILD_USER="ubuntu"
BUILD_AT="/opt/your_app_name/builds"
STAGING_HOSTS="your_aws_ec2_staging_machine_ip"
STAGING_USER="ubuntu"
DELIVER_TO="/opt/your_app_name/api"
# .circleci/config.yml
defaults: &defaults
parallelism: 1 # run only one instance of this job in parallel
working_directory: ~/app # directory where steps will run
docker: # run the steps with Docker
- image: circleci/elixir:1.7.3 # ...with this image as the primary container; this is where all `steps` will run
environment: # environment variables for primary container
MIX_ENV: test
# .circleci/config.yml
defaults: &defaults
parallelism: 1 # run only one instance of this job in parallel
working_directory: ~/app # directory where steps will run
docker: # run the steps with Docker
- image: circleci/elixir:1.7.3 # ...with this image as the primary container; this is where all `steps` will run
environment: # environment variables for primary container
MIX_ENV: test
checkout master
git pull
mix deps.get
mix compile
mix test
checkout master
git pull
mix deps.get
mix compile
mix test
GIT_REVISION_HASH=$(git rev-parse HEAD)
GIT_USER=$(git config user.name) # Get username from your console
function migrate_start () {
echo " :: Migrate PRODUCTION database"
mix edeliver start production
if [ $? -eq 0 ]; then
echo " :: Start PRODUCTION server"