Skip to content

Instantly share code, notes, and snippets.

In our application, we have a need to wrap Apollo Client, amongst other reasons we do this to pass default link context to operations. This works well for operations originating from the top-level APIs, but it doesn't for the subscribeToMore function that gets created by useQuery.

We could augment useQuery further and also wrap each subscribeToMore function object that's created, but it struck us that the relationship between the useQuery invocation and the created subscribeToMore function might actually imply that it should inherit the link context of the useQuery invocation. Below you can find a naive patch that does this.

// src/core/ObservableQuery.ts  

public subscribeToMore< 
      TSubscriptionData = TData, 
#!/usr/bin/env ruby
require 'pathname'
code_files = ARGV
code_files.each do |file|
file = Pathname(file)
contents = file.read
contents.gsub!(/(^#import .*\n)+/) do |imports|
imports = imports.split("\n")
imports.map! do |import|
# Option 1
info = if publication
"Title: #{ publication.title } (ID: #{ publication.id })"
else
'N/A'
end
# Option 2
info = case publication
when Publication then puts "Title: #{ publication.title } (ID: #{ publication.id })"
@alloy
alloy / 4.rb
Last active August 29, 2015 14:07 — forked from anonymous/4.rb
module ProMotion
class StaticPageView < PageView
def self.method_missing(method_name, obj_or_klass, *args)
options = args.last if args.last.is_a?(Hash)
options ||= {}
# then do rest
end
end
end
@alloy
alloy / 0_reuse_code.js
Created January 30, 2014 13:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
Pod::Spec.new do |s|
s.name = "PLCrashReporter"
s.version = "1.2-rc2"
s.summary = "Reliable, open-source crash reporting for iOS and Mac OS X."
s.description = <<-DESC
Plausible CrashReporter provides an in-process crash reporting
framework for use on both iOS and Mac OS X, and powers many of
the crash reporting services available for iOS, including HockeyApp,
Atlassian JMC, Crittercism, and Flurry.
require 'rubygems'
require 'cocoapods-downloader'
require 'cocoapods-core'
require 'cocoapods'
@spec = Pod::Spec.new do |s|
s.name = "MSActiveConfig"
s.version = "1.0.1"
s.summary = "Remote configuration and A/B Testing framework for iOS."
s.homepage = "https://github.com/mindsnacks/MSActiveConfig"
When he’s not sorting coloured LEDs, soldering DIY synthesisers,
or sharing/forcing his extensive hands-on ‘X design’/browser experience
knowledge with/on the twittersphere, he leads a small app consultancy
shop known for their continuous striving for doing things well.
#import <Foundation/Foundation.h>
#import <libkern/OSAtomic.h>
@interface NSArray (ConcurrentMap)
- (NSArray*)semaphore_map:(id (^)(id))block;
- (NSArray*)serial_map:(id (^)(id))block;
- (NSArray*)spinlock_map:(id (^)(id))block;
- (NSArray*)direct_map:(id (^)(id))block;
@end
Pod::Spec.new do |spec|
spec.name = 'DTLoupe'
spec.version = '1.3.0'
spec.platform = :ios, '4.3'
spec.license = 'COMMERCIAL'
spec.source = { :git => '[email protected]:parts/dtloupe.git', :tag => spec.version.to_s }
spec.source_files = 'Core/Source/*.{h,m}'
spec.frameworks = 'QuartzCore'
spec.requires_arc = true
spec.homepage = 'http://www.cocoanetics.com/parts/dtloupeview/'