Skip to content

Instantly share code, notes, and snippets.

import {
Boolean,
Number,
String,
Literal,
Array,
Tuple,
Record,
Union,
Null,
@kestred
kestred / juniper-example-sync-batching.rs
Last active March 1, 2019 21:46
Example juniper batching in synchronous call
// use other::stuff::{not_a_working_example};
use std::cell::RefCell;
use std::rc::Rc;
graphql_object!(Queries: () |&self| {
field many_rules() -> Vec<ProductRules> {
// ....
}
});

Keybase proof

I hereby claim:

  • I am kestred on github.
  • I am kestred (https://keybase.io/kestred) on keybase.
  • I have a public key whose fingerprint is 0013 229F C2D4 2C50 E73F 0320 F188 D779 DBE0 F767

To claim this, I am signing this object:

@kestred
kestred / Monokai Sharp
Created November 13, 2014 08:59
A variation on the Monokai TextMate theme with more prominent comments and other colors slightly muted. Helpful to deter over-commenting and draw your attention to comments that actually matter!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Monokai Kestred</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
#include <set>
#include <boost/icl/interval_map.hpp>
typedef std::set<char> set_t;
typedef boost::icl::interval_map<unsigned long long, set_t> imap_t;
typedef boost::icl::discrete_interval<unsigned long long> interval_t;
imap_t testmap = imap_t();
interval_t intervalA = interval_t::closed(3043, 3475);
interval_t intervalB = interval_t::closed(1000, 5000);
" Vim syntax file
" Language: DC File
" Maintainer: Kevin Stenerson
" Latest Revision: 12 February 2014
if exists("b:current_syntax")
finish
endif
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>dc</string>
<string>dcf</string>
</array>
<key>foldingStartMarker</key>
# [PackageDev] target_format: plist, ext: tmLanguage
---
name: DC File
scopeName: source.dcfile
fileTypes: [dc, dcf]
uuid: 43bb3bb2-4a23-4b91-9e46-c934cb20ed60
foldingStartMarker: \{
foldingStopMarker: \{
@kestred
kestred / c++-simpler-decorators.cpp
Created November 10, 2013 02:09
Attempt two at coming up with decorators
#include <iostream>
#include <unordered_map>
#include <string>
#define DCLASS(cpp_class) \
public std::unordered_map<std::string, void (cpp_class::*)(int)> s_atomics;
// note, "int" would actually be a datagram iterator
#define ATOMIC(field_name, cpp_class, cpp_fn) \
cpp_class.s_atomics[field_name] = cpp_fn;
@kestred
kestred / c++-decorators.cpp
Created November 10, 2013 01:52
Attempting to implement python-style decorators in C++. Not sure I like it write now.
#include <iostream>
#include <functional>
#include <unordered_map>
#include <string>
using std::placeholders::_1;
#define DCLASS(name) \
typedef std::function<void(name&)> atomic_t; \
std::unordered_map<std::string, atomic_t> m_atomics;