Skip to content

Instantly share code, notes, and snippets.

View BrychanOdlum's full-sized avatar
🦄
Lorem ipsum dolor sit amet...

Brychan BrychanOdlum

🦄
Lorem ipsum dolor sit amet...
View GitHub Profile
@BrychanOdlum
BrychanOdlum / UIScrollView.swift
Created January 21, 2020 22:07
UIScrollView scroll target view to centre
extension UIScrollView {
func scrollToCenter(_ targetView: UIView) {
let viewportHeight = self.frame.height - self.contentInset.bottom
let posInViewport = targetView.frame.origin.y + (targetView.frame.height / 2) - self.contentOffset.y
let posDelta = (viewportHeight / 2) - posInViewport
var newYOffset = self.contentOffset.y - posDelta
if newYOffset < 0 {
newYOffset = 0
} else if newYOffset > self.subviews[0].frame.height - viewportHeight {
@BrychanOdlum
BrychanOdlum / deploy.yml
Created January 5, 2020 03:16
Webpack: Github Actions -> Github Pages
name: Deploy
on:
push:
branches:
- master
jobs:
build-deploy:
runs-on: ubuntu-latest
@BrychanOdlum
BrychanOdlum / deploy.yml
Created December 5, 2019 17:47
Build and deploy React app to Github Pages via Github Actions
name: Deploy
on:
push:
branches:
- master
jobs:
build-deploy:
runs-on: ubuntu-latest
FROM node:10-alpine AS base
WORKDIR /app
# Add python... because bcrypt...
RUN apk --no-cache add --virtual native-deps \
g++ gcc libgcc libstdc++ linux-headers autoconf automake make nasm python git && \
npm install --quiet node-gyp -g
FROM base AS build
@BrychanOdlum
BrychanOdlum / withPseudoRoute.jsx
Created May 26, 2019 09:42
React router pseudo route hoc
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import { withRouter } from 'react-router-dom';
import { setPseudoRoute } from '../utils/Utils';
function withPseudoRoute(Component, deeplink) {
return withRouter(props => {
useEffect(() => {
setPseudoRoute(deeplink);
@BrychanOdlum
BrychanOdlum / storefrontmappings.json
Last active April 17, 2024 05:47
Apple iTunes Storefront IDs
[
{
"name": "Algeria",
"code": "DZ",
"storefrontId": 143563
},
{
"name": "Angola",
"code": "AO",
"storefrontId": 143564
@BrychanOdlum
BrychanOdlum / keybase.md
Created January 7, 2019 21:15
keybase.md

Keybase proof

I hereby claim:

  • I am brychanodlum on github.
  • I am brychan (https://keybase.io/brychan) on keybase.
  • I have a public key ASCkNeY2Od3UQ3Bgp-iQB6dFSXwhNT6CNO7AxklBjZDDAgo

To claim this, I am signing this object:

@BrychanOdlum
BrychanOdlum / g.js
Created December 23, 2018 08:42
Genius example
const axios = require('axios');
const fetchdata = async function(event, context) {
try {
const res = await axios({
method: 'post',
url: `https://api.genius.com/search?q=test`,
headers: {
'Authorization': 'Bearer TOKEN'
},
@BrychanOdlum
BrychanOdlum / musickitjs-example.js
Created December 1, 2018 18:13
MusicKit-example.js
document.addEventListener('musickitloaded', function() {
// MusicKit global is now defined
MusicKit.configure({
developerToken: '**JWT_TOKEN**',
app: {
name: 'Apple Musish',
build: '0.01a'
}
});
@BrychanOdlum
BrychanOdlum / speedtester.js
Last active July 22, 2018 23:12
Speedtester
const speedTest = require('speedtest-net');
const mysql = require('mysql');
const cron = require('node-cron');
const ping = require('ping');
const dns = require('dns');
var pool = mysql.createPool({
host: 'localhost',
user: 'USER',
password: 'PASSWORD',