This file contains hidden or 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
declare module "vue-instantsearch" { | |
import Vue from "vue"; | |
import { InstantSearch, InstantSearchOptions } from "instantsearch.js/es/types/instantsearch"; | |
import { SearchClient } from "instantsearch.js/es/types/algoliasearch"; | |
export interface SearchItem { | |
value: string; | |
count: number; | |
label: string; | |
isRefined: boolean; |
This file contains hidden or 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
// | |
// MIT License | |
// | |
// Copyright (c) 2018 Ali Sharif | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is |
This file contains hidden or 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
import React from 'react' | |
const enhancedForm = Component => | |
class HigherOrderComponent extends React.Component { | |
constructor(props) { | |
super(props) | |
this.state = { form: props.initialState } | |
this.handleSubmit = this.handleSubmit.bind(this) | |
this.handleChange = this.handleChange.bind(this) |
This file contains hidden or 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
enum TaskState { | |
TASK_INBOX | |
TASK_PINNED | |
TASK_SNOOZED | |
TASK_ARCHIVED | |
} | |
type Task { | |
id: ID! | |
title: String! |
This file contains hidden or 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
import React, { Component, PropTypes, createElement } from 'react' | |
import { findDOMNode } from 'react-dom' | |
// usage: | |
// import { ScrollSpy, Link } = './wherever-this-file-is' | |
// | |
// <ScrollSpy> | |
// <Link ref={c => this._firstLink = c} section="1">Section 1</Link> | |
// <Link section="2">Section 2</Link> | |
// <Link section="3">Section 3</Link> |
This file contains hidden or 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
function translateError(msg) { | |
var newErr = new Error(msg); // placed here to get correct stack | |
return e => { | |
newErr.originalError = e; | |
throw newErr; | |
} | |
} | |
async function asyncTask() { | |
const user = await UserModel.findById(1).catch(translateError('No user found')) |
This file contains hidden or 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
// Epochs | |
const epochs = [ | |
['year', 31536000], | |
['month', 2592000], | |
['day', 86400], | |
['hour', 3600], | |
['minute', 60], | |
['second', 1] | |
]; |
This file contains hidden or 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
'use strict'; | |
class Abstract { | |
// A static abstract method. | |
static foo() { | |
if (this === Abstract) { | |
// Error Type 2. Abstract methods can not be called directly. | |
throw new TypeError("Can not call static abstract method foo."); | |
} else if (this.foo === Abstract.foo) { | |
// Error Type 3. The child has not implemented this method. | |
throw new TypeError("Please implement static abstract method foo."); |
This file contains hidden or 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
#!/usr/bin/env bash | |
# fresh-chrome | |
# | |
# Use this script on OS X to launch a new instance of Google Chrome | |
# with its own empty cache, cookies, and user configuration. | |
# | |
# The first time you run this script, it will launch a new Google | |
# Chrome instance with a permanent user-data directory, which you can | |
# customize below. Perform any initial setup you want to keep on every |
This file contains hidden or 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
// todo-list module | |
Application.addModule('todo-list', function(context) { | |
var xhr; | |
var TodoList = React.createClass({ | |
render: function() { | |
return ( | |
<div> | |
<TodoItems /> |
NewerOlder