Skip to content

Instantly share code, notes, and snippets.


John O'Sullivan john-osullivan

Block or report user

Report or block john-osullivan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
john-osullivan / gist:7947988
Created Dec 13, 2013
Paragraph quoting Alexis Ohanian for "An Analysis of reddit as an Online Community Platform" term paper.
View gist:7947988
All of this evidence demonstrates that reddit the company seems like a welcoming community, but the key to their success lies in
how reddit the website is good at developing the feeling of community. This is achieved by the subreddit system, which lets any
user create a new subreddit for users to submit links to. Two months into the founding of reddit, the two co-founders, Alexis
Ohanian and Steve Huffman, had an argument over how to let people categorize their submissions to Their two
candidates were searchable tags, which were very popular athte time, and subreddits, a system where users could make their own
subsections of the site to submit to. The concept which Huffman said to Ohanian to explain the purpose of subreddits was:
Let’s say somebody submits a story about how the Nets aren’t doing well and we’re using the tag system. “Nets not performing up
to pre-season expectations this year. #Nets #Brooklyn #NYC #NBA” The problem is that each of those groups could have a
completely differe
john-osullivan / isSuccessResponse.ts
Last active Sep 16, 2019
Dev Diaries #2 - Sample Type Guard
View isSuccessResponse.ts
* Type guard; only returns `true` if object shape has a non-null
* `data` value and `err` has a null value.
* @param val
export function isSuccessResponse(val:any): val is SuccessResponse {
return (
isObject(val) && &&
val.err === null
john-osullivan / LoginScreen.tsx
Last active Sep 16, 2019
Dev Diaries #2 - Type Factory in useState
View LoginScreen.tsx
export function LoginScreen(props) {
const [loginArgs, setLoginArgs] = React.useState(Login.newArgs());
async function submitLogin() {
const res:Login.Response = await;
return (
john-osullivan / sample-payment-type.ts
Created Sep 16, 2019
Dev Daries #2 - Example namespace of types from Stripe
View sample-payment-type.ts
import AllStripeTypes from 'stripe';
export namespace StripeTypes {
export type Customer = AllStripeTypes.customers.ICustomer;
export type Card = AllStripeTypes.ICard;
export type Subscription = AllStripeTypes.subscriptions.ISubscription;
export type SubscriptionState = AllStripeTypes.subscriptions.SubscriptionStatus;
export type Invoice = AllStripeTypes.invoices.IInvoice;
john-osullivan / using-stripe-types.ts
Created Sep 16, 2019
Dev Diaries #2 - StripeTypes Import
View using-stripe-types.ts
import API from '@eximchain/dappbot-api-client';
import Payment, { StripeTypes } from '@eximchain/dappbot-types/spec/methods/payment';
// Nested namespaces make for legible collision-free names
const res:Payment.Read.Response = await;
// Helper namespace cuts down on extra text
const subscription:StripeTypes.Subscription =;
john-osullivan / auth.ts
Last active Sep 16, 2019
Dev Diaries #2 - Example API namespace
View auth.ts
import { XOR } from 'ts-xor';
import { ApiResponse } from '../../responses';
export namespace Login {
export const HTTP:HttpMethods.POST = 'POST';
export const Path = `${authBasePath}/${ResourcePaths.login}`
export interface Args {
username: string,
View sample-login-call.ts
import { Login } from '@eximchain/dappbot-types/spec/methods/auth';
import request from 'request-promise-native';
const baseApiUrl = '';
async function loginToDappbot(creds:Login.Args):Login.Result {
const res:Login.Response = await request({
headers : { 'Content-Type' : 'application/json' },
method : Login.HTTP,
john-osullivan / sample-validator-naming.ts
Last active Sep 16, 2019
Dev Diaries #2 - Types Naming Convention
View sample-validator-naming.ts
export interface SomeData {
foo: string
bar: string
export function newSomeData(): SomeData {
return {
foo: 'example',
bar: 'object'
john-osullivan / easy-imports.ts
Last active Sep 17, 2019
Dev Diaries #2 - Module layout for easy imports
View easy-imports.ts
// The type reference is so wordy! This isn't convenient.
import Types from '@eximchain/dappbot-types';
const args: Types.Methods.Auth.Login.Args = { ... };
// We can make the reference more compact by importing a
// more specific slice of the overall types.
import Auth from '@eximchain/dappbot-types/spec/methods';
const args: Auth.Login.Args = { ... };
john-osullivan / index.ts
Last active Sep 16, 2019
Dev Diaries #2 - Sample index file from the User submodule
View index.ts
// This line takes all of the exports from that
// file and wraps them into a single namespace.
// If we didn't do this "* as User" syntax here,
// then a consumer would have to do it in order
// to get a convenient namespace.
import * as User from './user';
// This line directly surfaces all of its non-default
// exports from right here, so that users can just
// grab one item from there, e.g.:
You can’t perform that action at this time.