Skip to content

Instantly share code, notes, and snippets.

View brysonian's full-sized avatar

Chandler McWilliams brysonian

View GitHub Profile
@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API
export const getImageWidthByUserContext = (width, MAX_WIDTH = 2880) => {
if (typeof(window) === 'undefined') return width;
// Pixel ratio
let qualityRatio = window.devicePixelRatio ? window.devicePixelRatio : 1;
// If bad connection, we downgrade
let type = null;
if (navigator && navigator.connection && navigator.connection.type) type = navigator.connection.type;
if (navigator && navigator.connection && navigator.connection.effectiveType) type = navigator.connection.effectiveType;
@christianalfoni
christianalfoni / AppLoader.js
Last active March 28, 2017 18:40
Webpack code splitting
import Inferno from 'inferno'
import Component from 'inferno-component'
import {connect} from 'cerebral/inferno'
import {state} from 'cerebral/tags'
import InvalidRoute from './InvalidRoute'
export default connect({
media: state`useragent.media`,
invalidRoute: state`app.invalidRoute`
},
@bluehat
bluehat / digital_freedom.markdown
Last active June 8, 2022 12:18
A Citizen's Guide to Digital Freedoms

A Citizen's Guide to Digital Freedoms

0: Background

0.0: What and Why

We're about to hand the architecture for a surveillance police state over to new leadership. Some of Trump's language around free speech and free press has been troubling, and a campaign advisor has already threatened a reporter. This seems like an excellent time for us to create nontechnical educational information on how technology can be used to protect citizen's civil liberties.

The goal of this guide is to create lesson plans which nontechnical people can then use to run classes for groups of nontechnical people. This guide will not make you safe. It will increase your chances of remaining safe for longer. If you are running Windows 10, or a Lenovo laptop, please skip to 4.0 for a discussion of your options before attempting to secure these machines.

0.1 Help Needed

@acdlite
acdlite / app.js
Last active January 20, 2023 08:23
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
@laziel
laziel / unlock.js
Created September 18, 2015 09:02
Unlock Web Audio in iOS 9 Safari
var ctx = null, usingWebAudio = true;
try {
if (typeof AudioContext !== 'undefined') {
ctx = new AudioContext();
} else if (typeof webkitAudioContext !== 'undefined') {
ctx = new webkitAudioContext();
} else {
usingWebAudio = false;
}
@guocheng
guocheng / .eslintrc
Last active January 3, 2018 19:18
A eslint config file for linting react/jsx and ES6 syntax. This file is based on (https://gist.github.com/cletusw/e01a85e399ab563b1236) and (https://github.com/kriasoft/react-starter-kit/blob/master/.eslintrc). Note that I use single quote in the rules, to change it, lookup 'quotes' and change it to `"quotes": [1, "double"].
{
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"es6": true
},
"ecmaFeatures": {
"jsx": true,
"modules": true,
@mvaneijgen
mvaneijgen / material-theme.terminal
Created June 15, 2015 20:27
material-theme.terminal
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGKSpYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKcHCBMXGyImVSRudWxs1QkKCwwNDg8QERJcTlNDb21wb25lbnRzVU5TUkdCXE5T
Q29sb3JTcGFjZV8QEk5TQ3VzdG9tQ29sb3JTcGFjZVYkY2xhc3NPECgwLjAyNzQ1MTAw
NjcgMC4yMTE3NjQ3MjMxIDAuMjU4ODIzNDg0MiAxTxAoMC4wMzkzODA3NDc4MiAwLjE2
@staltz
staltz / introrx.md
Last active July 15, 2024 15:43
The introduction to Reactive Programming you've been missing
@JChristensen
JChristensen / AVR Sleep
Last active March 31, 2024 18:42
AVR microcontroller sleep demonstrations
Simple demonstrations of putting AVR microcontrollers to sleep in power-down mode,
which results in minimum current. Coded with Arduino IDE version 1.0.4 (and with
the Arduino-Tiny core for the ATtiny MCUs, http://code.google.com/p/arduino-tiny/)
For ATmega328P, ~0.1µA.
For ATtinyX5 revisions that implement software BOD disable, ~0.1µA,
for ATtinyX5 revisions that don't, ~20µA.