Skip to content

Instantly share code, notes, and snippets.

@queerviolet
queerviolet / Code.gs
Created April 5, 2017 02:22
Send sheet as email
// Load a menu item called "Project Admin" with a submenu item called "Send Status"
// Running this, sends the currently open sheet, as a PDF attachment
function onOpen() {
SpreadsheetApp.getActiveSpreadsheet().addMenu('Send sheet', [
{name: 'As email', functionName: 'send'}
]);
}
function getSheetAs(sheet, format) {
@queerviolet
queerviolet / index.html
Created December 7, 2016 18:21
Hiring Day Playlist
<!doctype html>
<html>
<head>
<style>
html, body {
width: 100%; height: 100%; margin: 0; padding: 0;
background: black url('grace-hopper-fullstack-hiring-day-clean.webp');
background-size: contain;
background-position: center center;
background-repeat: no-repeat;
@queerviolet
queerviolet / todo.jsx
Last active January 26, 2023 07:56
Component injection in React
const React = require('react')
const List = ({
items,
Item = Todo.Item // Components recieve any components they depend on via props.
// The default assignment keeps our public interface clean.
}) => <ul>{items.map((item, index) => <Item key={index}>{item}</Item>)}</ul>
const Item = ({
@queerviolet
queerviolet / types.js
Last active February 9, 2025 15:32
Type Annotation Comments in JS
/**
* I like annotating my functions with comments that contain type annotations.
* The annotation syntax I use is, obviously, not an actual language, but it's
* strict enough to be one. Perhaps some day I'll write a yet another type flow tool
* to check these things!
*
* The syntax is a mishmash of Swift and JS destructuring expressions.
**/
/***** Basic format *****/
@queerviolet
queerviolet / lazy.js
Last active February 9, 2025 15:32
Lazy
function lazy(promise) {
return new Proxy(lazy, {
get(target, prop, receiver) {
if (prop === lazy.promise) { return promise }
if (prop === 'catch' || prop === 'then') {
return ((...args) => promise[prop].apply(promise, args))
}
return lazy(promise.then(x => x[prop]))
},
@queerviolet
queerviolet / index.html
Last active June 24, 2016 01:18
Sudoku skeleton
<!doctype html>
<html>
<head>
<title>Sudoku solver</title>
<style>
td {
border: 1px solid black;
margin: 0;
padding: 5px;
text-align: center;
@queerviolet
queerviolet / angular-factory-demo.html
Created May 19, 2016 16:33
Angular Factories Example
<!doctype html>
<html ng-app=WeatherApp>
<head>
<title>You could just go outside</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<script src="angular-factory-demo.js"></script>
</head>
<body ng-controller=CurrentWeatherCtrl>
<h1>The current temperature is {{ forecast.currently.apparentTemperature }}</h1>
<p>At {{ address }} ({{ forecast.latitude }}lat, {{ forecast.longitude }}lng)</p>
@queerviolet
queerviolet / netcat-demo.js
Created May 17, 2016 19:46
socket.io demo
"use strict"
// Create an HTTP server that always serves a couple
// of script tags.
var http = require('http')
var httpServer = http.createServer(function(req, rsp) {
rsp.end(`
<script src="/socket.io/socket.io.js"></script>
<script>
// This JS is running on the client. Whee!
@queerviolet
queerviolet / index.html
Created May 13, 2016 16:55
Todo list jquery example
<!doctype html>
<html>
<head>
<link rel=stylesheet href=style.css>
</head>
<body>
<h1 id=header>trip planner</h1>
<ul class=todo-list>
<li class=todo-list-new-item>
INSERT INTO Users (name, pictureUrl) VALUES ('Donald Trump', 'http://i.imgur.com/CTil4ns.jpg');
INSERT INTO Users (name, pictureUrl) VALUES ('Ted Cruz', 'http://i.imgur.com/Ru6KUIm.jpg');
INSERT INTO Users (name, pictureUrl) VALUES ('Bernie Sanders', 'http://i.imgur.com/KhisgEO.jpg');
INSERT INTO Users (name, pictureUrl) VALUES ('Hillary Clinton', 'http://i.imgur.com/XbsjDcr.jpg');
INSERT INTO Users (name, pictureUrl) VALUES ('Marco Rubio', 'http://i.imgur.com/cYxVyyg.jpg');
INSERT INTO Users (name, pictureUrl) VALUES ('John Kasich', 'http://i.imgur.com/I8WtzSw.jpg');
INSERT INTO Users (name, pictureUrl) VALUES ('Kanye West', 'http://i.imgur.com/MItGWVS.jpg');
INSERT INTO Users (name, pictureUrl) VALUES ('Taylor Swift', 'http://i.imgur.com/JKInSVz.jpg');
INSERT INTO Tweets (userId, content) VALUES ((SELECT id from Users where name='Donald Trump'), 'Make Fullstack great again!');