Skip to content

Instantly share code, notes, and snippets.

View looping over list
import React, { Component } from 'react';
class componentName extends Component {
constructor(props) {
super(props);
this.handleClicks = [];
this.props.friends.forEach(friend => {
this.handleClick[fiend.id] = this.handleClick.bind(this, friend.id);
})
}
View file upload
import React, { Component } from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import Ramda from 'ramda';
import FlatButton from 'material-ui/FlatButton';
import Dialog from 'material-ui/Dialog';
import { uploadBatch } from '../../../actions/batch-actions';
View map-drawing-tools.js
import React, { Component } from 'react';
import DrawingManager from 'react-google-maps/lib/drawing/DrawingManager';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { mapConfig } from '../../../../constants/component-configs';
import { setShapeEventListener, getGeomFilters, getShapeArea } from '../../../../utilities/map-tools-utilities';
const { drawingManager } = mapConfig;
import { setMapFilters, setDrawingMode } from '../../../../actions/map-actions';
import debounce from 'lodash.debounce';
import ShapeTool from './shape-tool';
View map-actions.spec.js
/* eslint-disable max-nested-callbacks */
import { expect } from 'chai';
import { toggleProjectInfoWindow, setDrawingMode, setMapFilters } from './map-actions';
import { MAP_CLOSE_INFO_WINDOW, MAP_SET_DRAWING_MODE, MAP_FILTERS_CHANGED } from '../constants/action-types';
import thunk from 'redux-thunk';
import configureMockStore from 'redux-mock-store';
describe('Map Actions', () => {
const state = {
map: {
View map-reducer.spec.js
import { expect } from 'chai';
import {
MAP_FILTERS_CHANGED,
MAP_OPEN_DIALOG,
MAP_SET_TYPE_ID,
MAP_TOGGLE_TRAFFIC,
MAP_OPEN_INFO_WINDOW,
MAP_CLOSE_INFO_WINDOW,
MAP_VIEWPORT_CHANGE,
MAP_SET_DRAWING_MODE,
View auth.controller.js
import GoogleAuth from "google-auth-library";
import { googleAuthClientId } from "../../src/constants/config";
import { User } from "../utilities/database";
import { path } from "ramda";
const checkUserToken = token => {
return new Promise((resolve, reject) => {
const auth = new GoogleAuth();
const client = new auth.OAuth2(googleAuthClientId, "", "");
client.verifyIdToken(token, googleAuthClientId, (error, login) => {
View RandomNameService.java
import java.util.*;
public class MyClass {
static String[] firstNames = {"John", "Frank", "Nick", "Amanda", "Brittany", "Amy", "Deborah", "Stirling"};
static String[] lastNames = {"Thompson", "Smith", "Jones", "Keribarian", "Lu", "Banafsheh", "Spielberg", "Jordan", "Castle", "Simpson"};
static Random generator = new Random();
static int outputLength = 50;
static Set<String> outputNames = new HashSet<String>();
View MinMethod.java
public class MinMethod {
static int getMin(int a, int b) {
if( a < b ) {
return a;
} else {
return b;
}
}
View HexagonArea.java
import java.lang.*;
public class HexagonArea {
static double getHexagonArea (double s) {
return (6 * s * s) / (4 * Math.tan(Math.PI / 6));
}
public static void main(String args[]) {
View map-tools.js
const polygonEvents = ['set_at', 'insert_at', 'remove_at'];
const circleEvents = ['center_changed', 'radius_changed'];
import turfCircle from '@turf/circle';
import { polygon as turfPolygon } from '@turf/helpers';
import { featureToWKT } from './map-utilities';
import { cond, has, hasIn, pipe, path } from 'ramda';
export const setShapeEventListener = (shape, action) => {
if (shape.radius) {
circleEvents.forEach(event => {