Skip to content

Instantly share code, notes, and snippets.

View andrewhead's full-sized avatar

Andrew Head andrewhead

View GitHub Profile
@mathematicalmichael
mathematicalmichael / remove_output.py
Last active September 15, 2022 22:56 — forked from damianavila/remove_output.py
Remove output from IPython notebook from the command line (dev version 1.0)
"""
Usage: python remove_output.py notebook.ipynb
Modified from remove_output by Minrk
Modified from remove_output by mathematicalmichael
"""
import sys
import io
import os
from nbformat import read, write, NO_CONVERT
@evanpeck
evanpeck / ClassConduct.md
Last active September 20, 2025 20:45
A code of conduct that is inserted into the syllabus of CS courses. I'd love to improve it + make it more actionable. Don't hesitate to suggest changes!

Code of Conduct

You have two primary responsibilities:

  • Promote an inclusive, collaborative learning environment.
  • Take action when others do not.

Professionally, we adhere to ACM’s Code of Ethics. More broadly, a course like INSERT COURSE NAME involves reflection, collaboration, and communication. Computer science has a checkered history with respect to inclusion – in corporate environments, in our classrooms, and in the products we create. We strive to promote characteristics of transparency and inclusivity that reflect what we hope our field becomes (and not necessarily what it has been or is now).

We reject behavior that strays into harassment, no matter how mild. Harassment refers to offensive verbal or written comments in reference to gender, sexual orientation, disability, physical appearance, race, or religion; sexual images in public spaces; deliberate intimidation, stalking, following, harassing photography or recording, sustained d

@eldon
eldon / dontdothis.py
Last active June 13, 2020 00:38
spicy_python_oneliners
# create a one-hot embedding for labels from (labels, examples) pairs
examples_labels = [[np.insert(np.zeros(4, dtype=np.int64), i, 1)] * e.shape[0] for i, e in enumerate(examples)]
# filter a list of words for words with numbers in them
df_word[np.vectorize(lambda x: any(map(str.isnumeric, x)))(df_word.word)]
# What's the index of the first nonconsecutive integer stored in a list of strings?
unique_numbers = df_numstrs[np.vectorize(lambda x: x.isnumeric())(df_numstrs.word.astype(int, errors='ignore'))].astype(int).drop_duplicates('word').sort_values('word')['word'].values
np.argmax(np.ediff1d(unique_numbers) > 1)
@abersnaze
abersnaze / InlineInlineMonacoEditor.stories.tsx
Last active September 17, 2020 12:21
React component, in typescript, wrapping Monaco editor to automatically grow & shrink with content to avoid scroll.
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import InlineMonacoEditor from './InlineMonacoEditor';
export const LINES = [
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'Aenean aliquet, nulla eget auctor porttitor, lacus urna',
'posuere purus, at suscipit orci sapien quis est. Curabitur',
@samuelcastro
samuelcastro / antd_sc_example.js
Created October 5, 2018 21:45 — forked from newswim/antd_sc_example.js
Wrapping Ant Design components with Styled Components
import { Link } from 'react-router-dom'
import { Badge, Col, Menu } from 'antd'
const StyledBadge = styled(Badge)`
.ant-badge-count {
background-color: #7ECBBF;
color: white;
box-shadow: 0 0 0 1px #d9d9d9 inset;
}
`
@tkw1536
tkw1536 / example.tex
Last active October 10, 2019 02:02
Example for the new LaTeXML locators
\documentclass{article}
% to make sure that the binding is loaded, compile this with:
% latexml --preload example.tex.ltxml example.tex --dest=example.xml
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Morbi non nisl metus.
\begin{quote}
Nunc efficitur, elit id accumsan iaculis, nisl mauris sodales sapien, in rutrum turpis neque finibus eros.
@kgjenkins
kgjenkins / readme.md
Last active January 14, 2025 20:26
Labels with callout lines in QGIS

Labels with callout lines in QGIS


UPDATE: As of October 2019, QGIS 3.10 has built-in support for label callout lines!


Callouts, sometimes called leader lines, are lines between labels and features on a map. They are useful when constraints of space force a label to be moved away from the

@coinsandsteeldev
coinsandsteeldev / dialog.html
Last active September 8, 2024 11:18 — forked from arthurattwell/dialog.html
Google Sheets script to allow multi-select in cells with data-validation (adapted from https://www.youtube.com/watch?v=dm4z9l26O0I)
<!DOCTYPE html>
<html>
<head>
<script>
var data
var formId = 'form'
function drawForm() {
if (!data) return
var outputEl = document.getElementById(formId);
@a-h
a-h / 01-simple.test.js
Last active December 31, 2023 09:07
Testing styled Material UI components with Enzyme
import React from 'react';
import { shallow } from 'enzyme';
const Item = text => <p>Item {text}</p>;
const Composition = ({ showB }) => (
<p>
<Item text="A" />
{showB && <Item text="B" />}
</p>);
@psbolden
psbolden / gist:fdecf4ba95ba01a95c2ab20c799e30d8
Created April 14, 2017 21:45
Image to DataUrl using File Reader
//Source: http://stackoverflow.com/questions/6150289/how-to-convert-image-into-base64-string-using-javascript
$( "#imagetourl" ).click(function() {
function toDataUrl(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
var reader = new FileReader();
reader.onloadend = function() {
callback(reader.result);
}