Skip to content

Instantly share code, notes, and snippets.

View davidsharp's full-sized avatar

David Sharp davidsharp

View GitHub Profile
@avesus
avesus / September 2017 iOS WebKit input focus position: fixed.md
Created September 4, 2017 23:24
September 2017 iOS WebKit input focus position: fixed

Mobile Safari does not support position: fixed when an input focused and virtual keyboard displayed.

To force it work the same way as Mobile Chrome, you have to use position: absolute, height: 100% for the whole page or a container for your pseudo-fixed elements, intercept scroll, touchend, focus, and blur events.

The trick is to put the tapped input control to the bottom of screen before it activates focus. In that case iOS Safari always scrolls viewport predictably and window.innerHeight becomes exactly visible height.

Open https://avesus.github.io/docs/ios-keep-fixed-on-input-focus.html in Mobile Safari to see how it works.

Please avoid forms where you have several focusable elements because more tricks to fix position will be necessary, those were added just for demonstration purposes.

@xem
xem / readme.md
Last active April 5, 2024 23:16
Maths & trigonometry cheat sheet for 2D & 3D games

Conventions

  • A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
  • lengths are in any unit (ex: pixels)
  • code snippets are in JavaScript

Degrees to radians

angleRad = angleDeg * Math.PI / 180;

@addyosmani
addyosmani / README.md
Last active April 2, 2024 20:18 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active March 28, 2024 01:45
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@tomhicks
tomhicks / plink-plonk.js
Last active March 18, 2024 02:23
Listen to your web pages
@JShorthouse
JShorthouse / gba-gcc-compiling-linux.md
Last active February 25, 2024 01:44
Compiling GBA programs on Linux with GCC

Compiling GBA programs on Linux with GCC

There is a strange lack of guides and tools online for compiling Gameboy Advance homebrew programs on Linux. I didn't want to use devkitpro - their installation method of requiring you to use a forked version of pacman is extemely strange and I didn't want to install all of that on my system just to complile some programs.

The only other guides I found for Linux were this one and this one which both involve compiling custom versions of GCC and assosicated libraries. This lead me down a road of pain, after spending multiple hours fixing compiler errors only to create new errors I gave up. I thought that their had to be a simpler way, and there is!

The solution

Debian already has a version of GCC that can compile ARM programs in the repos, no manual compiling necessary! The package is called arm-none-eabi-gcc.

@marcgg
marcgg / notevalues.json
Created November 1, 2016 10:56
note frequency value
var noteValues = {
'C0': 16.35,
'C#0': 17.32,
'Db0': 17.32,
'D0': 18.35,
'D#0': 19.45,
'Eb0': 19.45,
'E0': 20.60,
'F0': 21.83,
'F#0': 23.12,
anonymous
anonymous / untitled
Created April 27, 2015 13:44
IFTTT Spotify Alarm Clock
Spotify Alarm
Utilizing [IFTT recipe](https://ifttt.com/recipes/283707-spotify-alarm-clock)
In your mail client:
Create a rule in your mail client with the following properties
- Message content contains #wakeup
- Actions: Delete Message, Run AppleScript
Create an AppleScript with the following statements.
@zfael
zfael / nodejs.checksum.js
Created June 20, 2017 13:57
NODE.JS - How to generate file's Checksum (CRYPTO)
var fs = require('fs');
var crypto = require('crypto');
fs.readFile('file.pdf', function(err, data) {
var checksum = generateChecksum(data);
console.log(checksum);
});
function generateChecksum(str, algorithm, encoding) {
return crypto
@tetsuok
tetsuok / answer_pic.go
Created April 2, 2012 02:40
An answer of the exercise: Slices on a tour of Go
package main
import "code.google.com/p/go-tour/pic"
func Pic(dx, dy int) [][]uint8 {
// Allocate two-dimensioanl array.
a := make([][]uint8, dy)
for i := 0; i < dy; i++ {
a[i] = make([]uint8, dx)
}