Skip to content

Instantly share code, notes, and snippets.

@jeffhandley
jeffhandley / build-runtime.ps1
Created November 24, 2022 00:26
PowerShell alias for invoking the dotnet/runtime build script
# Yes, I hate having to type "./" _that_ much.
New-Alias -Name "build" -Value BuildRuntime
function BuildRuntime {
$root = $((git rev-parse --show-toplevel 2> $Null) ?? "").Replace("\", "/")
$runtime = (Resolve-Path "~/git/dotnet/runtime").Path.Replace("\", "/")
if ($root -eq $runtime) {
& "~/git/dotnet/runtime/build.cmd" $ARGS
@jeffhandley
jeffhandley / Scanner.cs
Last active April 17, 2021 21:35
Scan dotnet/runtime artifacts for assembly-level Platform Attributes
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace Scanner
{
class Program
{
@jeffhandley
jeffhandley / PropDefinitions.jsx
Created November 6, 2017 17:14
Defining PropTypes for nested components
/* NameDisplay.js */
import ReactPropTypes from 'prop-types';
const NameDisplay = ({name}) => (
<div>
<div>
First Name: {name.first}
</div>
<div>
Last Name: {name.last}
var strickland = require("strickland");
var validate = strickland.default;
var required = strickland.required;
var length = strickland.length;
var minLength = strickland.minLength;
var form = strickland.form;
var data = {
name: '',
phones: [
@jeffhandley
jeffhandley / droppedstyle.cshtml
Created January 31, 2018 22:49
Dropped Style
<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 December 7, 2017 15:39
You don't need `do` to have if statements in functions
function View({ loading, error, ...otherProps }) {
if (loading) {
return (<Loading />);
}
if (error) {
return (<Error error={error} />);
}
return (<MyLoadedComponent {...otherProps} />);
@jeffhandley
jeffhandley / magic.js
Created August 6, 2017 10:31
Process your OneDrive Camera Roll into year/month folders
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 April 25, 2017 05:13
Open profile pictures for all members of a slack channel
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 September 19, 2016 04:35
webpack configs
{
"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 July 20, 2016 13:45
Is there a better way to build this React component other than using ReactDOMServer.renderToStaticMarkup and dangerouslySetInnerHTML?
// 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',