Skip to content

Instantly share code, notes, and snippets.

Ian Obermiller ianobermiller

Block or report user

Report or block ianobermiller

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View use-onclick-outside-example.jsx
import { useState, useEffect, useRef } from 'react';
// Usage
function App() {
// Create a ref that we add to the element for which we want to detect outside clicks
const ref = useRef();
// State for our modal
const [isModalOpen, setModalOpen] = useState(false);
const openModal = useCallback(() => setModalOpen(true), []);
const closeModal = useCallback(() => setModalOpen(false), []);
View use-on-screen-example.jsx
import { useState, useEffect, useRef } from 'react';
// Usage
function App() {
// Ref for the element that we want to detect whether on screen
const ref = useRef();
// Call the hook passing in ref and root margin
// In this case it would only be considered onScreen if more ...
// ... than 300px of element is visible.
const onScreen = useOnScreen(ref, '-300px');
View radium-issue-462.jsx
import Radium from 'radium';
import React from 'react';
import ReactDOM from 'react-dom';
// import Radium, { Style } from 'radium';
var FakeUser = React.createClass({
getInitialState: function() {
return {firstname: '', lastName: '', gender: '', location: '', email: '', username: '', password: '', picture: ''};
@ianobermiller
ianobermiller / example.js
Last active Dec 27, 2015
Saw this post on HN about optimizing AngularJS (http://blog.scalyr.com/2013/10/31/angularjs-1200ms-to-35ms/) and I wondered how React would fare. Turns out it can be pretty fast. I did have to use a similar trick of breaking up the line only when the mouse is over it, but no messing with custom directives needed. You can try it yourself by dropp…
View example.js
/**
* @jsx React.DOM
*/
var text1 = document.getElementById('text1').textContent;
var text2 = document.getElementById('text2').textContent;
var LinksDemo = React.createClass({
getInitialState: function() {
return {text: text1};
@ianobermiller
ianobermiller / gist:5381688
Created Apr 14, 2013
Histogram image in C#
View gist:5381688
public static class Histogram
{
public static SortedDictionary<int, int> ToHistogram(this IEnumerable<int> nums)
{
var dict = new SortedDictionary<int, int>();
foreach (var n in nums)
{
if (!dict.ContainsKey(n))
dict[n] = 1;
else
View gist:5360760
{
"00C1": "A WITH ACUTE, LATIN CAPITAL LETTER",
"00E1": "A WITH ACUTE, LATIN SMALL LETTER",
"0103": "A WITH BREVE, LATIN SMALL LETTER",
"01CE": "A WITH CARON, LATIN SMALL LETTER",
"00C2": "A WITH CIRCUMFLEX, LATIN CAPITAL LETTER",
"00E2": "A WITH CIRCUMFLEX, LATIN SMALL LETTER",
"00C4": "A WITH DIAERESIS, LATIN CAPITAL LETTER",
"00E4": "A WITH DIAERESIS, LATIN SMALL LETTER",
"0227": "A WITH DOT ABOVE, LATIN SMALL LETTER",
You can’t perform that action at this time.