This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp.Scheduler do | |
@moduledoc """ | |
Schedules a Mix task to be run at a given interval in milliseconds. | |
## Options | |
- `:task`: The name of the Mix task to run. | |
- `:args`: A list of arguments to pass to the Mix task's `run/1` function. | |
- `:interval`: The time interval in millisconds to rerun the task. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This will write private.pem and public.pem in the current directory | |
# The default key strenght is 2048 bits | |
# usage: | |
# # ./gen-jwt-rsa-keys.sh mykey | |
# # ls | |
# gen-jwt-rsa-keys.sh mykey-private.key mykey-public.pem | |
# first time you have to give execution permission or use bash and the filename | |
# # chmod +x gen-jwt-rsa-keys.sh | |
KEYNAME=${1:-jwtrsa} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ElasticSearchConnection < GraphQL::Relay::BaseConnection | |
def has_next_page | |
!nodes.last_page? | |
end | |
def has_previous_page | |
!nodes.first_page? | |
end | |
def cursor_from_node(node) |
I've been following this blog post on how to set up an api-only Rails 5 application. One of the sections talks about creating a subdomain for your api
Rails.application.routes.draw do
constraints subdomain: "api" do
scope module: "api" do
Inspired by dannyfritz/commit-message-emoji
See also gitmoji.
Commit type | Emoji |
---|---|
Initial commit | 🎉 :tada: |
Version tag | 🔖 :bookmark: |
New feature | ✨ :sparkles: |
Bugfix | 🐛 :bug: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env ruby | |
# (C) 2015 Thomas R. Koll, <info@ananasblau.com> | |
# licensed under WTFPL | |
# | |
# This script generates entries for the ledger format. | |
# Think of it as an envelope generator | |
require 'highline' | |
require 'date' | |
require 'active_support/core_ext/date/calculations' |
In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.
At the moment GraphQL allows 2 types of queries:
query
mutation
Reference implementation also adds the third type: subscription
. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @author Erik Elmore <erik@erikelmore.com> | |
# This is getting a little out of hand... :dizzy_face: | |
# For printing trace output for demonstration | |
module Status | |
def status( method_name, args = [], extra = nil ) | |
extra = ' => %s' % extra if extra | |
puts '%s#%s(%s)%s' % [self.class, method_name, args.join(', '), extra] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Optional do | |
defmacro __using__(_opts) do | |
quote do | |
require unquote(__MODULE__) | |
import unquote(__MODULE__) | |
end | |
end | |
def unit(nil), do: {:err, nil} | |
def unit(value), do: {:ok, value} |