Skip to content

Instantly share code, notes, and snippets.

View c-spencer's full-sized avatar

Chris Spencer c-spencer

View GitHub Profile
var functions = {
add: function (args) {
return args.reduce(function (a, b) { return a + b });
},
twoarg: function (a, b) {
return a * b;
},
async: function (a, cb) {
var state = this.state;
setTimeout(function () {
defmodule MyApp.UserResource do
use Phoenix.Resource
defp get_user(%{"id" => id}) do
Repo.get(User, id)
end
def supported_formats do
["html", "json", "xml"]
end
@c-spencer
c-spencer / a.ex
Last active August 29, 2015 14:11
defmodule WrangleTest.Disabled do
use Wrangle
plug :serve
decide :service_available?, do: false
end
# compiled decision tree
defp(do_decide(:accept_charset_exists?, var!(conn))) do
if(has_header(var!(conn), "accept-charset")) do
case(handle_decision(var!(conn), (
charset = ConNeg.find_best(:charset, var!(conn).assigns().headers()["accept-charset"], @available_charsets)
{!is_nil(charset), assign(var!(conn), :charset, charset)}
))) do
{true, var!(conn)} ->
do_decide(:if_match_exists?, var!(conn))
{false, var!(conn)} ->
do_decide(:handle_not_acceptable, var!(conn))

Keybase proof

I hereby claim:

  • I am c-spencer on github.
  • I am cagspencer (https://keybase.io/cagspencer) on keybase.
  • I have a public key whose fingerprint is 6941 F445 2599 B7BC FF92 F7B1 E091 D260 3D41 E23C

To claim this, I am signing this object:

pub fn access_token() -> BoxedFilter<(String,)> {
let (set_token_value, token_value) =
tokio_sync::watch::channel::<Option<gcloud::GrantedToken>>(None);
let channel_lock = tokio_sync::lock::Lock::new(set_token_value);
warp::any()
.and_then(move || {
let current_value = token_value.get_ref().clone().filter(|t| t.is_valid());
let result = match current_value {