Skip to content

Instantly share code, notes, and snippets.

View Copser's full-sized avatar
:octocat:
Something need doing?

p_pilipovic Copser

:octocat:
Something need doing?
View GitHub Profile
@Copser
Copser / big-o.md
Created July 4, 2023 07:22 — forked from PJUllrich/big-o.md
Big-O Time Complexities for Elixir Data Structures

Big-O Time Complexities for Elixir data structures

Map [1]

Operation Time Complexity
Access O(log n)
Search O(log n)
Insertion O(n) for <= 32 elements, O(log n) for > 32 elements [2]
Deletion O(n) for <= 32 elements, O(log n) for > 32 elements
@Copser
Copser / heroku-remote.md
Created April 19, 2022 05:32 — forked from randallreedjr/heroku-remote.md
Add a Heroku remote to an existing git repo

Working with git remotes on Heroku

Generally, you will add a git remote for your Heroku app during the Heroku app creation process, i.e. heroku create. However, if you are working on an existing app and want to add git remotes to enable manual deploys, the following commands may be useful.

Adding a new remote

Add a remote for your Staging app and deploy

Note that on Heroku, you must always use master as the destination branch on the remote. If you want to deploy a different branch, you can use the syntax local_branch:destination_branch seen below (in this example, we push the local staging branch to the master branch on heroku.

$ git remote add staging https://git.heroku.com/staging-app.git
@Copser
Copser / phx_sqlite_fly_launch.md
Created February 19, 2022 06:27 — forked from mcrumm/phx_sqlite_fly_launch.md
Phoenix + SQLite Deployment tips

Deploying to Fly.io with SQLite

Deploying a Phoenix app to Fly.io is a breeze...is what everyone kept telling me. In fairness, I imagine the process would have been breezier had I just used postgres, but all the sqlite and litestream talk has been far too intriguing to ignore. "Wait", you say. "It is just a flat file. How much harder can it be?"

It is easy to make something harder than it should be. It is hard to take something complex and make it truly simple. flyctl launch does an amazing job at providing a simple interface to the utterly complex task of generating deployment resources, especially now that we are living in a containerd (erm, firecracker) world.

This gist is for anyone who, like me, thinks they know better than to read all of the documentation and therefore necessari

### Keybase proof
I hereby claim:
* I am copser on github.
* I am copser (https://keybase.io/copser) on keybase.
* I have a public key ASAMxtVKcEvHNiRiJdqPpEdf2QMP_IjhmG-rwZb9tkwSTgo
To claim this, I am signing this object:
Erlang/OTP 22 [erts-10.4.4] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe] [dtrace]
Interactive Elixir (1.9.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> TwitterFeed.get_tweets("CandyCrushSaga")
%TwitterFeed.Feed{
last_tweet_retrieved: 1204476179719294976,
more_tweets_exist: true,
tweets: [
%TwitterFeed.Tweet{
display_name: "Candy Crush Saga",
@Copser
Copser / AppDelegate.m
Created August 8, 2019 05:46 — forked from markrickert/AppDelegate.m
Create NSDictionary based on a URL structure with keys and values
/*
* Example implementation
*/
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
NSLog(@"Launched with URL: %@", url.absoluteString);
NSDictionary *userDict = [self urlPathToDictionary:url.absoluteString];
@Copser
Copser / phoenix_heroku_reset_db.md
Created July 28, 2019 17:55 — forked from ventsislaf/phoenix_heroku_reset_db.md
Reset database on Heroku running Phoenix app

Note: Don't do this on a production evniroment!

Get the heroku database name:

heroku pg:info

Name can be found in the reponse from the command above. For example: Add-on: soaring-newly-1337.

@Copser
Copser / nosuchuser.html
Created July 13, 2019 16:05 — forked from mubix/nosuchuser.html
No Such User - Spam Deterrent
<html>
<head>
<style>
* {
font-family:Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
</style>
</head>
<body>
<table cellpadding="0" cellspacing="0" class="email-wrapper" style="padding-top:32px;background-color:#ffffff;"><tbody>
@Copser
Copser / gist:254972bc533327d7a6c9ad94b9a8547a
Created June 14, 2019 09:38
many to many associations ecto
user = Repo.get!(User, user_id) |> Repo.preload(:roles)
role = Repo.get!(Role, role_id)
user_changeset = Changeset.change(user) |> Changeset.put_assoc(:roles, [role | user.roles])
@Copser
Copser / context.ex
Created May 23, 2019 07:44 — forked from posilva/context.ex
Guardian Authentication with Absinthe GraphQL in Elixir
defmodule Languafy.Web.Context do
@behaviour Plug
import Plug.Conn
alias Languafy.User
def init(opts), do: opts
def call(conn, _) do
case build_context(conn) do
{:ok, context} ->