Skip to content

Instantly share code, notes, and snippets.

defmodule Bling.GraphQL.Schema do
use Absinthe.Schema
def middleware([]=middleware, _field, _object), do: middleware
def middleware(middleware, field, object) do
Bling.GraphQL.ScoutMiddleware.instrument(middleware, field, object)
end
query do
#...
@karmajunkie
karmajunkie / epmdless.ex
Last active April 5, 2018 23:39
Implementation of an epmd replacement
# A module containing the function that determines the port number
# based on a node name.
# Taken from https://www.erlang-solutions.com/blog/erlang-and-elixir-distribution-without-epmd.html
defmodule Epmdless do
def dist_port(name) when is_atom(name) do
dist_port Atom.to_string name
end
def dist_port(name) when is_list(name) do
dist_port List.to_string name
@karmajunkie
karmajunkie / new_relic_plug_absinthe.ex
Last active January 13, 2017 20:04
Gives limited tracing around absinthe calls. Shamelessly adapted from the Phoenix plug in new_relic.ex
defmodule NewRelic.Plug.Absinthe do
@moduledoc """
A plug that instruments Phoenix controllers and records their response times in New Relic.
Inside an instrumented controller's actions, `conn` can be used for further instrumentation with
`NewRelic.Plug.Instrumentation` and `NewRelic.Plug.Repo`.
```
defmodule MyApp.UsersController do
use Phoenix.Controller
@karmajunkie
karmajunkie / schedule_store.js.jsx
Created June 21, 2015 01:33
Doing React all wrong...
var ScheduleStore = Reflux.createStore({
init(){
this.listenToMany(ScheduleActions);
},
schedule(){
return this._schedule;
},
setSchedule(schedule){
this._schedule = schedule;

Keybase proof

I hereby claim:

  • I am karmajunkie on github.
  • I am karmajunkie (https://keybase.io/karmajunkie) on keybase.
  • I have a public key whose fingerprint is EC67 CF80 F69A A0F6 4495 ABF5 AD08 F721 9592 3238

To claim this, I am signing this object:

require_relative "../proofs_init.rb"
class ReplayTest
include Replay::EventSource
end
class ReplayTest
include Replay::EventSource
events do
SomeEvent(pid: Integer)
@karmajunkie
karmajunkie / replay_test.rb
Last active August 29, 2015 13:57
Replay events
class ReplayTest
include Replay::EventSource
#define an event inline to the class
event SomethingHappened(name: String, pid: Integer)
apply SomethingHappened do |event|
@name = event.name
@pid = event.pid
end
Blocktalk = {
Index: {
//with init function: Blocktalk.Index.init();
init: function(){
$(document).ready(function(){
});
}
},
//called directly: Blocktalk.Show()
Show: function(){
@karmajunkie
karmajunkie / gist:3953353
Created October 25, 2012 15:29
So a guy walks into a barbershop...

...And proceeds to sell me 30 tickets to paintball.

No, seriously. That really happened. I was getting my haircut at Roosters last night and a guy walks in selling discounted tickets to Stunt Ranch Paintball. So of course I said "I'll take 30", because I have at least that many people I want to shoot, right?

So now I have to figure out how to get 30 people into playing paintball with me. The tickets don't expire, and they include everything except the paint and CO2. I'm not an avid paintballer, but that sounds like a decent deal to me, since I got them for $2 apiece.

I'm thinking a geeky paintball extravaganza sometime in the near future. Maybe a geek father/son thing, maybe we all dress up like Rebels and Stormtroopers. I dunno, I'm open to suggestions.