Skip to content

Instantly share code, notes, and snippets.

@smoak
smoak / blog.ex
Last active March 29, 2018 21:09
defmodule Blog do
def fetch(limit, offset \\ 0) do
IO.inspect(limit: limit, offset: offset)
posts = 1..1000 |> Enum.map(fn i -> %{body: "body #{i}"} end)
%{
total_count: length(posts),
posts: posts |> Enum.slice(offset || 0, limit)
}
end
query {
user(id: "12345") {
id
}
viewer {
user {
id
}
}
}
object :user do
field :id, non_null(:id)
end
object :group do
field :id, non_null(:id)
field :members, list_of(:user)
end
query do
defmodule Schema do
use Absinthe.Schema
object :user do
field :id, non_null(:id)
end
object :viewer do
field :user, non_null(:user) do
resolve(fn _parent, _args, _ctx ->
@smoak
smoak / nhl_api.ex
Created January 26, 2018 05:03
Trying to use dataloader with absinthe
defmodule NhlGraphApi.NhlApi do
def data() do
Dataloader.KV.new(&fetch/2)
end
def fetch(_batch_key, arg_maps) do
IO.inspect(arg_maps: arg_maps)
%{%{id: "1"} => %{id: 1, name: "foo", city: "bar", abbreviation: "OMG"}}
end
end
@smoak
smoak / schema.ex
Last active November 16, 2017 03:38
defmodule ApiWeb.Schema do
use Absinthe.Schema
import Absinthe.Resolution.Helpers
import_types Absinthe.Type.Custom
@desc "A user"
object :user do
field :id, non_null(:string)
package com.reststopperpro.android.activity;
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
@smoak
smoak / BaseScreen.java
Created April 26, 2016 06:56
Trying to understand box2d
package com.mygdx.game.screen;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
$ winecfg
wine: created the configuration directory '/home/smoak/.wine'
err:ole:marshal_object couldn't get IPSFactory buffer for interface {00000131-0000-0000-c000-000000000046}
err:ole:marshal_object couldn't get IPSFactory buffer for interface {6d5140c1-7436-11ce-8034-00aa006009fa}
err:ole:StdMarshalImpl_MarshalInterface Failed to create ifstub, hres=0x80004002
err:ole:CoMarshalInterface Failed to marshal the interface {6d5140c1-7436-11ce-8034-00aa006009fa}, 80004002
err:ole:get_local_server_stream Failed: 80004002
err:ole:marshal_object couldn't get IPSFactory buffer for interface {00000131-0000-0000-c000-000000000046}
err:ole:marshal_object couldn't get IPSFactory buffer for interface {6d5140c1-7436-11ce-8034-00aa006009fa}
err:ole:StdMarshalImpl_MarshalInterface Failed to create ifstub, hres=0x80004002
@smoak
smoak / TilesGame.java
Created August 4, 2015 06:35
TiledGame trying to get it to work
package com.mygdx.game;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.*;
import com.badlogic.gdx.maps.MapLayers;
import com.badlogic.gdx.maps.tiled.TiledMap;