Skip to content

Instantly share code, notes, and snippets.

@ianfinch
ianfinch / rpi4-usb.sh
Last active July 7, 2024 01:54
Raspberry Pi 4 USB Gadget
#!/bin/bash
# Set up a Raspberry Pi 4 as a USB-C Ethernet Gadget
# Based on:
# - https://www.hardill.me.uk/wordpress/2019/11/02/pi4-usb-c-gadget/
# - https://pastebin.com/VtAusEmf
if ! $(grep -q dtoverlay=dwc2 /boot/config.txt) ; then
echo "Add the line dtoverlay=dwc2 to /boot/config.txt"
exit
fi

Install Android SDK on macOS

Install homebrew https://brew.sh/

brew cask install homebrew/cask-versions/adoptopenjdk8
brew cask install android-sdk
@mfellner
mfellner / graphql.ts
Created July 8, 2019 20:42
Using Apollo Server in Next.js 9 with API route in pages/api/graphql.ts
import { ApolloServer, gql } from 'apollo-server-micro';
const typeDefs = gql`
type Query {
sayHello: String
}
`;
const resolvers = {
Query: {
@wolverineks
wolverineks / InteractiveModal.jsx
Created March 31, 2018 06:39
Compound Components
// @flow
import React, { Component } from 'react'
import type { Node } from 'react'
import { StyleSheet, Text, View } from 'react-native'
import { default as Modal } from 'react-native-modal'
import { styles } from './styles.js'
// CONTAINER /////////////////////////////////////////////////////////////////////////////
@hew
hew / _readme.md
Last active June 10, 2022 19:13
Operator Mono w/ Italics on OSX VIm

Operator Mono w/ Italics on OSX Vim

@ludflu
ludflu / whyfp.md
Last active August 29, 2016 02:54
why functional programming is important (to me)

#Why Functional Programming Matters (to me)

This is my response to being asked not to use functional programming techniques.

###What I mean by "Functional Programming" Different people mean different things by "Functional Programming". Here's what it means to me:

  • Functions are first class, fundamental atoms of software, and proper functional programming languages allows passing functions as arguments, assigning them to variables, and composing them together to form new functions.
  • Strong Static Typing prevents many common programming errors automatically.
  • Null pointer dereferences can by virtually eliminated using Optional/Option/Maybe/Either data types to explicitly represent empty or error conditions.
  • Together with sum types, strongly typed languages can automatically perform local totality checking, informing the programmer when a logical branch is not handled.

The issue:

..mobile browsers will wait approximately 300ms from the time that you tap the button to fire the click event. The reason for this is that the browser is waiting to see if you are actually performing a double tap.

(from a new defunct https://developers.google.com/mobile/articles/fast_buttons article)

touch-action CSS property can be used to disable this behaviour.

touch-action: manipulation The user agent may consider touches that begin on the element only for the purposes of scrolling and continuous zooming. Any additional behaviors supported by auto are out of scope for this specification.

@gokulkrishh
gokulkrishh / media-query.css
Last active July 16, 2024 10:52
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
/* CSS */
@paulirish
paulirish / what-forces-layout.md
Last active July 25, 2024 07:49
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@colingourlay
colingourlay / example.js
Last active October 22, 2021 15:16
Lodash / Underscore sort object keys. Like _.sortBy(), but on keys instead of values, returning an object, not an array. Defaults to alphanumeric sort.
var obj = {b: 3, c: 2, a: 1};
_.sortKeysBy(obj);
// {a: 1, b: 3, c: 2}
_.sortKeysBy(obj, function (value, key) {
return value;
});
// {a: 1, c: 2, b: 3}