Skip to content

Instantly share code, notes, and snippets.

View ddgromit's full-sized avatar

Derek Dahmer ddgromit

  • Alchemy
  • San Francisco, CA
View GitHub Profile
@ddgromit
ddgromit / snippets.cson
Last active December 6, 2017 22:57
Atom Snippets
'.source.js':
'[DD] query renderer':
prefix: 'queryrendererfile'
body: """
/* @flow */
import React from 'react';
import { graphql } from 'react-relay/compat';
import DefaultQueryRenderer from 'components/DefaultQueryRenderer';
import type { $1QueryResponse } from './__generated__/$1Query.graphql';
@ddgromit
ddgromit / groupByAdjacent.js
Created December 5, 2017 01:33
Groups adjacent elements of an array that satisfy an equality function.
/* @flow */
function groupByAdjacent<T>(arr: Array<T>, eq: (T, T) => boolean): Array<Array<T>> {
return arr.reduce((prev, curr) => {
if (prev.length && eq(curr, prev[prev.length - 1][0])) {
prev[prev.length - 1].push(curr);
} else {
prev.push([curr]);
}
return prev;
}, []);
import React from 'react'
import styled from 'styled-components';
class Blah extends React.Component {
render() { return <div />; }
}
styled(Blah);
@ddgromit
ddgromit / fisheryates.coffee
Created March 8, 2011 01:56
CoffeeScript Implementation of the Fisher-Yates array sorting algorithm
# Adapted from the javascript implementation at http://sedition.com/perl/javascript-fy.html
# Randomizes the order of elements in the passed in array in place.
fisherYates = (arr) ->
i = arr.length;
if i == 0 then return false
while --i
j = Math.floor(Math.random() * (i+1))
tempi = arr[i]
@ddgromit
ddgromit / gist:8365897
Created January 11, 2014 01:43
Octocat demo
HEADING 1: Octocat
HEADING 2: Official GitHub mascot
PARAGRAPH:
I'm part octopus and part cat and the official mascot of GitHub.
You can find all sorts of variations of me here.
PARAGRAPH LINKS
@ddgromit
ddgromit / gist:6819739
Created October 4, 2013 01:35
First Classification submission using average miles per year and a RBF Support Vector Classifier
"""
Define the problem: Car is a good buy (0) or bad buy (1)
Type of problem: Classification problem
"""
# Plot values to see what features actually contribute to car values (histograms, scatter plots)
# Drop outliers in training data
# Clean some columns, e.g. year bought -> number of years owned
### IMPORT MODULES
@ddgromit
ddgromit / gist:6811976
Created October 3, 2013 15:43
Apprentice Talk Resources
Site Terms and Conditions of Use
1. User’s Acknowledgment and Acceptance of Terms
Ticket Evolution INC ("Us" or "We") provides the Ticket Evolution site and various related services (collectively, the "site") to you, the user, subject to your compliance with all the terms, conditions, and notices contained or referenced herein (the "Terms of Use"), as well as any other written agreement between us and you. In addition, when using particular services or materials on this site, users shall be subject to any posted rules applicable to such services or materials that may contain terms and conditions in addition to those in these Terms of Use. All such guidelines or rules are hereby incorporated by reference into these Terms of Use.
These Terms of Use are effective as of 10/14/2010. We expressly reserve the right to change these Terms of Use from time to time without notice to you. You acknowledge and agree that it is your responsibility to review this site and these Terms of Use from time to time and to famili
// WeatherPage.js
class WeatherPage extends React.Component {
constructor() {
this.state = {
loading: true,
temperature: null,
error: null,
}
}
@ddgromit
ddgromit / render_partial.py
Created July 19, 2011 17:53
Django Template Tag to Render Partial
# Source: http://freeasinbeard.org/post/107743420/render-partial-in-django
# Author: Martin Häger
from django import template
register = template.Library()
class PartialNode(template.Node):
def __init__(self, partial, params):
self.partial = partial