Skip to content

Instantly share code, notes, and snippets.

Jeff Handley jeffhandley

Block or report user

Report or block jeffhandley

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 droppedstyle.cshtml
<style>
my-custom-class:before {
top: 0px;
/* this renders fine */
}
my-custom-class::before {
top: 0px;
/* this css class is not rendered */
}
@jeffhandley
jeffhandley / dont-need-do.jsx
Created Dec 7, 2017
You don't need `do` to have if statements in functions
View dont-need-do.jsx
function View({ loading, error, ...otherProps }) {
if (loading) {
return (<Loading />);
}
if (error) {
return (<Error error={error} />);
}
return (<MyLoadedComponent {...otherProps} />);
@jeffhandley
jeffhandley / PropDefinitions.jsx
Created Nov 6, 2017
Defining PropTypes for nested components
View PropDefinitions.jsx
/* NameDisplay.js */
import ReactPropTypes from 'prop-types';
const NameDisplay = ({name}) => (
<div>
<div>
First Name: {name.first}
</div>
<div>
Last Name: {name.last}
@jeffhandley
jeffhandley / magic.js
Created Aug 6, 2017
Process your OneDrive Camera Roll into year/month folders
View magic.js
function loadCameraRoll(url, max, done) {
url = url || "https://graph.microsoft.com/v1.0/me/drive/special/cameraRoll/children";
max = max || 200;
console.log('LOADING PHOTOS');
$.ajax({
url: url,
dataType: "json",
headers: { "Authorization": "Bearer " + window.token },
@jeffhandley
jeffhandley / open-slack-profile-pictures.js
Created Apr 25, 2017
Open profile pictures for all members of a slack channel
View open-slack-profile-pictures.js
document.querySelectorAll("#channel_page_all_members a.lazy.member_preview_link.member_image.thumb_20")
.forEach(function(member) {
window.open(member.dataset.original.replace(/^url\(\'(.*)-48\'\)$/, "$1-128"));
});
@jeffhandley
jeffhandley / package.json
Last active Sep 19, 2016
webpack configs
View package.json
{
"scripts": {
"build:core": "babel src -d lib && webpack",
"build": "NODE_ENV=production npm run build:core",
"postbuild": "echo 'Build Complete'",
"predev": "webpack --config webpack.dev.config.babel.js",
"dev": "NODE_ENV=development babel-node src/server",
"start": "nodemon --watch src/ -e js,jsx --exec npm run dev"
},
"devDependencies": {
@jeffhandley
jeffhandley / Greeting.jsx
Last active Jul 20, 2016
Is there a better way to build this React component other than using ReactDOMServer.renderToStaticMarkup and dangerouslySetInnerHTML?
View Greeting.jsx
// Returns a translated form of "Welcome back, <strong>Jeff</strong>. It's good to see you again."
// There are several messages that can be supplied and they can have different sentence structures
// Regardless of the message, the name needs to be wrapped in a <strong> tag
import React from 'react';
import ReactDOMServer from 'react-dom/server';
export default React.createClass({
displayName: 'Greeting',
@jeffhandley
jeffhandley / page.js
Last active Feb 13, 2016
A pattern for server-side async data loading with React components
View page.js
import React from 'react';
export default (req, res, callback) => {
// Do async work, consuming data off req if needed
// Potentially set headers or other data on res
// When all the data is loaded, call the callback with the component
callback(React.createClass({
render() {
return (
<html>
@jeffhandley
jeffhandley / gist:7883875
Created Dec 10, 2013
Named objects in a graph
View gist:7883875
// What Example 46 shows here: http://json-ld.org/spec/latest/json-ld
"@graph" : [
{
"@id": "#homer",
"http://example.com/vocab#name": "Homer"
},
{
"@id": "#bart",
"http://example.com/vocab#name": "Bart",
"http://example.com/vocab#parent": { "@id": "#homer" }
@jeffhandley
jeffhandley / Get-RandomPassword.ps1
Created Aug 22, 2013
Get a new random password
View Get-RandomPassword.ps1
<#
.SYNOPSIS
Returns a random, timestamped, password
#>
# Base64-encode the Guid to add some additional characters
[DateTime]::Now.ToString("MMMddyy") + "!" + [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes([Guid]::NewGuid().ToString()))
You can’t perform that action at this time.