Skip to content

Instantly share code, notes, and snippets.

View mndewitt's full-sized avatar

Mike DeWitt mndewitt

  • First Dollar
  • Austin, TX
View GitHub Profile
@gaearon
gaearon / connect.js
Last active May 3, 2025 05:27
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
@wuct
wuct / MapCanvas.js
Created May 13, 2015 06:49
react-google-map handle zoom and center changed
import React from 'react';
import {GoogleMaps, InfoWindow} from 'react-google-maps';
class MapCanvas extends React.Component {
constructor(...args) {
super(...args);
this.state = {
zoomLevel: 3,
center: new google.maps.LatLng(34.397, 60.644)
};
@muratpurc
muratpurc / gist:1341358
Created November 5, 2011 10:08
PHP/CSS: Extract all url definitions (e. g. background images) in CSS declarations
/**
* Extracts all url definitions (e. g. urls to background images) in CSS.
*
* This snippet could be usefull within a build process where css files are
* distributed in different folder during development and should be merged together.
* Existing url definitions could be invalid in some cases.
*/
// example css content, could be read from a file
$cssFileContent = <<<CSS