Skip to content

Instantly share code, notes, and snippets.

View dandean's full-sized avatar
🌧️
It's raining.

Dan Dean dandean

🌧️
It's raining.
View GitHub Profile
export interface Car {
doors: number;
}
export const Car: Car = {
doors: 4
};
window.__doPostBack = window.__doPostBack.wrap(function(original) {
var name = arguments[1],
argument = arguments[2] || "",
// Convert name to ID. Strip extranious garbage off of the end.
id = name.replace(/\$/g, '_').replace(/_ctl00$/, ''),
element = $(id);
if (element.hasClassName("ajax")) {
// Make the ajax request.
var form = element.up("form"),
@dandean
dandean / define-color.scss
Last active January 6, 2020 23:34
Given input CSS color, component parts are declared as CSS Custom Properties for use with rbg() and hsl() functions.
/**
* Defines a color as a CSS custom property, along with a custom property for
* all of the color's component parts in both RGB and HSL.
*
* Example:
*
* :root {
* @include defineColor("blue", #0000ff);
* }
*
### Keybase proof
I hereby claim:
* I am dandean on github.
* I am dandean (https://keybase.io/dandean) on keybase.
* I have a public key ASBxY7cqp9cbHPp4eGOlt6zX8kCdm3-y8H_bZ62sU-i5sAo
To claim this, I am signing this object:
@dandean
dandean / Contact.graphql
Last active June 3, 2019 08:24
GraphQL Directive to Rename a Field from Source to Schema Context
directive @fromSourceField(name: String!) on FIELD
"""
This is a Contact type where the data source uses type-specific field names
for their ID fields. In this case we're renaming this field to `id` instead
of `contact_id`, making it much more friendly to the consuming application.
"""
type Contact {
id: ID! @fromSourceField(name: "contact_id")
...
@dandean
dandean / cloneElement.js
Created July 18, 2016 18:18
Remove props...
// I haven't tested this one, but something like this should work?
class Component1 extends React.Component {
render() {
// Create a new `props` object without `foo` and `bar` properties
const {
...props,
foo,
bar
} = someComponent.props;
@dandean
dandean / private-npmjs-registry.md
Last active July 14, 2018 21:31
How I got the npmjs.org registry running on my mac.

Install CouchDB (1.5)

$ brew install couchdb

It may throw an exception while compiling erlang. If so, you need to install a different gcc, reinstall erlang, then try the couchdb install again:

$ brew install apple-gcc42
$ brew reinstall -v --use-gcc erlang
Element.addMethods("INPUT", {
whatever: function(element) {
// make this shit work.
return element;
}
});
let i = 0;
class UsesConditional extends React.Component {
render() {
i++;
return (
<div>
<Conditional if={i % 2}>
<span>Show Me</span>
</Conditional>
<div className="pricing" style={{ opacity: purchasing ? 0.25 : '' }}>
<Conditional if={purchaseComplete}>
<div className="purchase-complete">
<h2>Thanks!</h2>
<p>
Thank you for your purchase of {formatPrice(this.state.total)}.
We’ll send you a receipt shortly.
</p>
<p>
<button