Skip to content

Instantly share code, notes, and snippets.

@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active June 9, 2024 19:08
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@kumarharsh
kumarharsh / Select.jsx
Last active October 7, 2022 21:02
Shows how to use react-select with portals provided by react-overlay
import ReactSelect from 'react-select';
import Portal from 'react-overlays/lib/Portal';
import 'react-select/dist/react-select.css'; // I'm using css-modules, but you can use whatever you like
import css from './Select.css';
import defaultMenuRenderer from 'react-select/lib/utils/defaultMenuRenderer'; // this renders the actual menu - we can reuse the same component
class _SelectMenu extends React.Component {
props: { // flow types
selectProps: {},
@CalebEverett
CalebEverett / gist:712fb3948d2695a95957
Last active January 26, 2017 21:01
Help with material-ui leftNav,react-router and redux

I am having trouble getting this to work. I'm trying to get the material ui leftNav to work with react router and redux with nav going through the store and router. This was close, but didn't get all the way to the menu item.

TypeError: Cannot read property 'isActive' of undefined

I was also referring to these examples: https://github.com/callemall/material-ui/blob/master/docs/src/app/components/app-left-nav.jsx

http://codetheory.in/react-integrating-routing-to-material-uis-left-nav-or-other-components/

@ChuckJHardy
ChuckJHardy / reactjs-example.js
Last active September 15, 2016 09:23
ReactJS Example Structure
React.createClass({
displayName: 'Name',
propTypes: {},
mixins: [],
getInitialState: function() {
return {};
},
getDefaultProps: function() {
@amirouche
amirouche / getting.started.with.react.md
Last active August 29, 2015 14:12
Getting started with react
  • Install npm and nodejs (on debian I had to link /usr/bin/nodejs to /usr/bin/node
  • At the root of your project create package.js file with the an empty json object:
$ echo "{}" > package.js 

In the same directory, install all the project dependencies with the following command:

@kcargile
kcargile / ConfigurableFilterProvider.cs
Created August 8, 2014 13:32
Inject Castle Windsor Dependencies into ASP.NET Web API Filter C#
using System.Collections.Generic;
using System.Diagnostics;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
using Castle.Windsor;
using Algorythmic.Web.API.Filters;
namespace Algorythmic.Web.API.Windsor.Filters
{
@ryanlewis
ryanlewis / umbraco-jul-fix.ps1
Created July 22, 2014 10:54
Powershell script to resolve the Umbraco security advisory released 21 July 2014
Param(
[Parameter(Mandatory=$true)] $path
)
$proxyHtm = @"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Repo proxy</title>
</head>
@chaoaretasty
chaoaretasty / WebAPI HttpContext for Autofac
Created October 14, 2013 16:53
Hackily enable HttpContext in WebAPI and Autofac
/*
While generally using HttpContext, and all of the related properties such as
Cookies and Session, in WebAPI is not the right way sometimes it needs to be
done, especially when migrating existing code before doing a full rewrite but
could happen in any legacy MVC project you want to bring WebAPI into.
When using Autofac there is the AutofacWebTypesModule which allows you to resolve
these dependencies, all of which come from resolving HttpContextBase.
WebAPI doesn't provide HttpContext directly but if hosted in IIS rather than
@peaeater
peaeater / powershell filename replace
Created August 22, 2013 17:00
Replace a portion of a filename in a list of filenames with regex.
ls * -name | ren -newname {$_ -replace '^(.*)-replaceme-(.*)$', '$1-newvalue-$2'}
@azizmb
azizmb / carmen_country_input.rb
Created May 18, 2012 19:24
Carmen Country input field for SimpleForm
class CarmenCountryInput < SimpleForm::Inputs::PriorityInput
def input
@builder.send(:"country_select", attribute_name, input_options, input_html_options)
end
end