Skip to content

Instantly share code, notes, and snippets.

View collegeimprovements's full-sized avatar
💭
☀️

Arpit Shah collegeimprovements

💭
☀️
View GitHub Profile
m1dnight [1:52 PM]
@mmacheerpuppy a first-class citizen in a language is anything you can assign to a variable, return from a function, or pass to a function. You’ll be amazed, but thi sis not possible in all languages!
So a function is like an integer, a first-class citizen in Elixir
hi! according to https://hexdocs.pm/ecto/Ecto.Query.html#module-bindingless-operations i'm expecting these two queries to be equivalent:
```> from(i in Item, select: i.name) |> Repo.all()
> from(Item, select: [:name]) |> Repo.all()```
but the first one gives me what i want (only the names) and the second gives me all columns.
what did i miss?
lostkobrakai [6:39 PM]
`from(Item, select: [:name]) |> Repo.all()` is equivalent to `from(i in Item, select: struct(i, [:name])) |> Repo.all()` and structs have fixed keys
@collegeimprovements
collegeimprovements / gitzip.sh
Created June 24, 2018 16:12 — forked from LeonardoCardoso/gitzip.sh
Zip folder ignoring files listed on .gitignore
#...
function gitzip() {
git archive -o [email protected] HEAD
}
#... gitzip ZIPPED_FILE_NAME
{:absinthe_ecto, "~> 0.1.3"},
{:absinthe_phoenix, "~> 1.4"},
{:cortex, "~> 0.5.0"},
{:cowboy, "~> 1.0"},
{:distillery, "~> 1.5"},
{:exldap, "~> 0.6.3"},
{:gettext, "~> 0.11"},
{:jamdb_oracle, "~> 0.1.4"},
# {:lapin, "~> 0.3.4"},
{:math, "~> 0.3.0"},
{:phoenix, "~> 1.3.3"},
{:phoenix_pubsub, "~> 1.0"},
{:phoenix_ecto, "~> 3.2"},
{:postgrex, ">= 0.0.0"},
{:gettext, "~> 0.11"},
{:cowboy, "~> 1.0"},
{:xlsxir, "~> 1.6"},
{:scribe, "~> 0.8"},
{:proper_case, "~> 1.2"},
{:retry, "~> 0.8.2"},
@collegeimprovements
collegeimprovements / tutorial.md
Created June 17, 2018 04:41 — forked from swalkinshaw/tutorial.md
Designing a GraphQL API

Tutorial: Designing a GraphQL API

This tutorial was created by Shopify for internal purposes. We've created a public version of it since we think it's useful to anyone creating a GraphQL API.

It's based on lessons learned from creating and evolving production schemas at Shopify over almost 3 years. The tutorial has evolved and will continue to change in the future so nothing is set in stone.

@collegeimprovements
collegeimprovements / gist:388266e63e8058e1f1837fd99ff5a473
Created June 1, 2018 03:52 — forked from komuw/gist:076231fd9b10bb73e40f
Shell script to generate server cert, key and client certs (all self-signed)
#! /usr/bin/env bash
# Create the CA Key and Certificate for signing Client Certs
openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
# Create the Server Key, CSR, and Certificate
openssl genrsa -des3 -out server.key 1024
openssl req -new -key server.key -out server.csr
const http = require('http');
var path = require('path');
var fs = require('fs');
console.log("server starting...");
var handler = function(req, res) {
defmodule MyApp.Schema.RemoveNil do
def call(res, _) do
arguments = fix_args(res.arguments)
%{res | arguments: arguments}
end
def fix_args(%_{} = struct), do: struct
def fix_args(%{} = args) do
for {key, val} <- args,
def do_thing(conn, _) do
things = ThingsManagement.get_all()
Enum.each(things, &(DynamicSupervisor.start_child(ThingWorkerSupervisor, child_spec(&1))))
render(conn, :do_thing)
end
defp child_spec(thing) do
Supervisor.child_spec({ThingWorker, thing}, id: "thing_worker_#{thing.id}")
end