Skip to content

Instantly share code, notes, and snippets.

View jrmedd's full-sized avatar

James Medd jrmedd

View GitHub Profile
@sujinleeme
sujinleeme / useRect.tsx
Last active March 21, 2024 15:27 — forked from morajabi/useRect.js
useRect — getBoundingClientRect() React Hook with resize handler (TypeScript)
// Require to install a package from npm with ResizeObserver typings.
// yarn --dev @types/resize-observer-browser
import { useCallback, useLayoutEffect, useRef, useState } from "react";
import ResizeObserver from 'resize-observer-polyfill'
type RectResult = {
bottom: number;
height: number;
left: number;
@gingemonster
gingemonster / main.c
Created January 12, 2019 11:31
Simple sound effect sample GameBoy GBDK
#include <gb/gb.h>
#include <stdio.h>
void main(){
// these registers must be in this specific order!
NR52_REG = 0x80; // is 1000 0000 in binary and turns on sound
NR50_REG = 0x77; // sets the volume for both left and right channel just set to max 0x77
NR51_REG = 0xFF; // is 1111 1111 in binary, select which chanels we want to use in this case all of them. One bit for the L one bit for the R of all four channels
@robertknight
robertknight / using-nvda-in-a-windows-vm-on-mac.md
Created July 3, 2017 13:23
Testing the Windows screenreader NVDA on a Mac

How to test NVDA screen reader behaviour on a Mac:

  1. Download Microsoft Edge VM from https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/
  2. Download Virtualbox and import the Edge VM image.

Then in the VM:

  1. Install guest addons in the VM
  2. Download & install latest NVDA from nvaccess.org
  3. Download & install SharpKeys and use it to map left an alternative key (eg. Left Ctrl) to the Insert key. This is needed because Macs do not typically have an “Insert” key which is the prefix for many NVDA commands.
@sergeysova
sergeysova / generate-icns-from-svg.sh
Last active July 17, 2017 13:46 — forked from adrianorsouza/generate-icns.sh
Generate icns from iconset
#!/bin/bash
mkdir icon.iconset
convert -background none -size 16x16 -gravity center -extent 16x16 icon.svg icon.iconset/icon_16x16.png
convert -background none -size 32x32 -gravity center -extent 32x32 icon.svg icon.iconset/icon_16x16@2x.png
convert -background none -size 32x32 -gravity center -extent 32x32 icon.svg icon.iconset/icon_32x32.png
convert -background none -size 64x64 -gravity center -extent 64x64 icon.svg icon.iconset/icon_32x32@2x.png
convert -background none -size 64x64 -gravity center -extent 64x64 icon.svg icon.iconset/icon_64x64.png
convert -background none -size 128x128 -gravity center -extent 128x128 icon.svg icon.iconset/icon_64x64@2x.png
convert -background none -size 128x128 -gravity center -extent 128x128 icon.svg icon.iconset/icon_128x128.png
@gbaman
gbaman / HowToOTGFast.md
Last active May 14, 2024 10:26
Simple guide for setting up OTG modes on the Raspberry Pi Zero, the fast way!

Setting up Pi Zero OTG - The quick way (No USB keyboard, mouse, HDMI monitor needed)

More details - http://blog.gbaman.info/?p=791

For this method, alongside your Pi Zero, MicroUSB cable and MicroSD card, only an additional computer is required, which can be running Windows (with Bonjour, iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu has it built in).
1. Flash Raspbian Jessie full or Raspbian Jessie Lite onto the SD card.
2. Once Raspbian is flashed, open up the boot partition (in Windows Explorer, Finder etc) and add to the bottom of the config.txt file dtoverlay=dwc2 on a new line, then save the file.
3. If using a recent release of Jessie (Dec 2016 onwards), then create a new file simply called ssh in the SD card as well. By default SSH i

@jamielaundon
jamielaundon / create-pfx
Created January 22, 2016 22:02
Create IIS .pfx from Let's Encrypt fullchain and privkey
sudo openssl pkcs12 -export -in /etc/letsencrypt/live/domain.com/fullchain.pem -inkey /etc/letsencrypt/live/domain.com/privkey.pem -out domain.com.pfx
@francis2110
francis2110 / LG infrared codes
Created January 22, 2015 10:01
Lg infrared codes for making your own remote
on-off->20DF10EF
energy->20DFA956
av. mode->20DF0CF3
input->20DFD02F
tv/rad->20DF0FF0
1->20DF8877
2->20DF48B7
3->20DFC837
4->20DF28D7
5->20DFA857
@AugustMiller
AugustMiller / map.js
Last active October 2, 2021 14:14
Map a number in one range to a number in another.
function mapNumber (number, inMin, inMax, outMin, outMax) {
return (number - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
}
@ismaels
ismaels / polyline_decoder.js
Created September 20, 2013 12:50
Javascript function to decode google maps api polyline
// source: http://doublespringlabs.blogspot.com.br/2012/11/decoding-polylines-from-google-maps.html
function decode(encoded){
// array that holds the points
var points=[ ]
var index = 0, len = encoded.length;
var lat = 0, lng = 0;
while (index < len) {
var b, shift = 0, result = 0;